def main():
    # Go to http://dev.twitter.com and create an app.
    # The consumer key and secret will be generated for you after that.
    consumer_key="gIRVUzcuPWdWo4pbAfaRqt0xM"
    consumer_secret="1xJj33TrSQsKBt6Szh9PJz4AORvpwB69QWs4Ry8joRpu71a5tO"

    # After the step above, you will be redirected to your app's page.
    # Create an access token under the the "Your access token" section
    access_token="2164180933-9VW0NbvTzeQ6hw7CdQYwVe1Sy4J6JYfpTdMxSAf"
    access_token_secret="MXrstxWpW9fduwp4KaYr0L2fO79hbgVyiLaQlhQ9cwU3V"

    # Create a twitter feed to track BitCoin related events.
    track = ["bitcoin", "btc", "mtgox"]
    follow = []
    languages = ["en"]
    twitterFeed = twitterfeed.TwitterFeed(consumer_key, consumer_secret, access_token, access_token_secret, track, follow, languages)

    # Create a client responsible for all the interaction with MtGox
    mtgoxClient = client.Client("USD", None, None)
    mtgoxClient.setEnableReconnection(False)

    # Create a real-time feed that will build bars from live trades.
    feed = barfeed.LiveTradeFeed(mtgoxClient)

    # Create a backtesting broker.
    brk = broker.BacktestingBroker(200, feed)

    # Run the strategy with the feed and the broker.
    strat = Strategy("BTC", feed, brk, mtgoxClient, twitterFeed)
    strat.run()
Example #2
0
def main():
    # Go to http://dev.twitter.com and create an app.
    # The consumer key and secret will be generated for you after that.
    consumer_key = "<YOUR-CONSUMER-KEY-HERE>"
    consumer_secret = "<YOUR-CONSUMER-SECRET-HERE>"

    # After the step above, you will be redirected to your app's page.
    # Create an access token under the the "Your access token" section
    access_token = "<YOUR-ACCESS-TOKEN-HERE>"
    access_token_secret = "<YOUR-ACCESS-TOKEN-SECRET-HERE>"

    # Create a twitter feed to track BitCoin related events.
    track = ["bitcoin", "btc", "mtgox"]
    follow = []
    languages = ["en"]
    twitterFeed = twitterfeed.TwitterFeed(consumer_key, consumer_secret,
                                          access_token, access_token_secret,
                                          track, follow, languages)

    # Create a client responsible for all the interaction with MtGox
    mtgoxClient = client.Client("USD", None, None)
    mtgoxClient.setEnableReconnection(False)

    # Create a real-time feed that will build bars from live trades.
    feed = barfeed.LiveTradeFeed(mtgoxClient)

    # Create a backtesting broker.
    brk = broker.BacktestingBroker(200, feed)

    # Run the strategy with the feed and the broker.
    strat = Strategy("BTC", feed, brk, mtgoxClient, twitterFeed)
    strat.run()
Example #3
0
def main():
    # Create a client responsible for all the interaction with MtGox
    cl = client.Client("USD", None, None)

    # Create a real-time feed that will build bars from live trades.
    feed = barfeed.LiveTradeFeed(cl)

    # Create a backtesting broker.
    brk = broker.BacktestingBroker(200, feed)

    # Run the strategy with the feed and the broker.
    strat = mtgox_scalper.Strategy("BTC", feed, brk)
    # It is VERY important to add the client to the event dispatch loop before running the strategy.
    strat.getDispatcher().addSubject(cl)
    # This is just to get each bar printed.
    strat.setVerbosityLevel(0)
    strat.run()
Example #4
0
def main(plot):
    # Load the trades from the CSV file
    print "Loading bars"
    feed = barfeed.CSVTradeFeed()
    feed.addBarsFromCSV("trades-mtgox-usd-2013-03.csv")

    # Create a backtesting broker.
    brk = broker.BacktestingBroker(200, feed)

    # Run the strategy with the feed and the broker.
    print "Running strategy"
    strat = mtgox_scalper.Strategy("BTC", feed, brk)

    if plot:
        plt = plotter.StrategyPlotter(strat, plotBuySell=False)
        plt.getOrCreateSubplot("volatility").addDataSeries(
            "Volatility", strat.returnsVolatility)

    strat.run()
    print "Result: %.2f" % strat.getResult()

    if plot:
        plt.plot()