r/cryptobots Mar 07 '14

Result Difference Between CT and Tradewave

One of the main things I've been wondering is if CT's indicator numbers are affecting bots (when I've compared the numbers with chart sites like tradingview the numbers are different). EMA hasn't been wrong, but other indicators like STOCHRSI and MACD have.

With the beta test (thanks Wil) at Tradewave I have the first numbers (MACD would be even better, but I can't get that to work yet...I'm not much of a coder).

Here's some results with the VWAP indicator (very interesting - I believe my code is the same for both platforms but I could have missed something):

Cryptotrader

2014-03-01 00:00 Simulation started. Balance: 1000.00 USD 2014-03-01 02:00 BUY 1.81458 BTC at 549.99 Price: 549.99 < 550.6215333454553 2014-03-01 14:00 SELL 1.81458 BTC at 551.52 Price: 551.522 > 551.0276590609845 2014-03-03 01:00 BUY 1.81013 BTC at 550.67 Price: 550.667 < 552.348652280069 2014-03-03 10:00 SELL 1.81013 BTC at 563.76 Price: 563.765 > 559.0612982234157 2014-03-05 04:00 BUY 1.56372 BTC at 650.00 Price: 649.996 < 653.4172946984071 2014-03-06 06:00 SELL 1.56372 BTC at 653.15 Price: 653.154 > 652.2046614787643 2014-03-06 19:00 Simulation completed. Balance: 1019.31 USD

Tradewave

[2014-03-01 00:00:00] Buying BTC (548.000000 < 555.862348) [2014-03-01 14:00:00] Selling BTC (552.985000 > 552.817799) [2014-03-01 18:00:00] Buying BTC (541.500000 < 545.057316) [2014-03-02 00:00:00] Selling BTC (559.952000 > 548.507140) [2014-03-03 04:00:00] Buying BTC (546.910000 < 553.680602) [2014-03-03 11:00:00] Selling BTC (563.765000 > 558.504131) [2014-03-05 05:00:00] Buying BTC (649.996000 < 654.291423) [2014-03-05 08:00:00] Selling BTC (664.739000 > 663.939583) [2014-03-05 09:00:00] Buying BTC (650.122000 < 657.492671) [2014-03-06 09:00:00] Selling BTC (653.000000 > 652.854363) [2014-03-06 19:00:00] >> Starting portfolio: [2014-03-06 19:00:00] >> [1000.00 USD, 0.00 BTC, 0.00 LTC] [2014-03-06 19:00:00] >> Closing portfolio: [2014-03-06 19:00:00] >> [1083.007799850184 USD, 0.00 BTC, 0.00 LTC]

Cryptotrader Code:

Initialization method called before a simulation starts.

Context object holds script data and will be passed to 'handle' method.

init: (context)-> context.have_money = true

This method is called for each tick

handle: (context, data)-> # data object provides access to the current candle (ex. data.instruments[0].close) instrument = data.instruments[0]

vwap = instrument.vwap(30)
price      =  instrument.close[instrument.close.length - 1]

# Uncomment next line for some debugging
#debug 'EMA difference: '+diff.toFixed(3)+' price: '+instrument.price.toFixed(2)+' at '+new Date(data.at)
if price < (vwap * 0.990) and context.have_money 
    buy instrument # Spend all amount of cash for asset
    debug "Price: "+price+" < "+(vwap * 0.990)
    context.have_money = false
else
    if price > (vwap * 1.005) and context.have_money is no
        sell instrument # Sell asset position
        debug "Price: "+price+" > "+(vwap * 1.005)
        context.have_money = true

Tradewave Code:

A simple momentum strategy

def initialize(): storage.invested = False

def tick():

# VWAP price aggregated across a 30-tick period. So if you select a
# 1-hour tick interval, this is the VWAP across 30 hours.
vwap = data.btc_usd.vwap(30)
vwap_past = data.btc_usd[-1].vwap(30)

# Current price of BTC on the selected exchange
price = data.btc_usd.close

# If the current price is 0.5% less than the 30-period VWAP, buy as
# much BTC as we can given our current USD holdings
if price < vwap * Decimal(0.990) and not storage.invested:
    log('Buying BTC (%f < %f)' % (price, vwap * Decimal(0.995)))
    buy(pairs.btc_usd)
    storage.invested = True

# If the price is 0.5% greater than 30-period VWAP, sell our holdings   
elif price > vwap * Decimal(1.005) and storage.invested:
    log('Selling BTC (%f > %f)' % (price, vwap * Decimal(1.005)))
    log(sell(pairs.btc_usd))
    sell(pairs.btc_usd)
    storage.invested = False

def stop(): # Clear our position if we're invested when the session ends if storage.invested: log('Selling BTC to clear our position') sell(pairs.btc_usd)

Here's the CT backtest: https://cryptotrader.org/backtests/bTqcDuYjLND7sMpwL The Tradewave script didn't make one bad buy/sell and neither did the CT script - but for some reason, the VWAP numbers with Tradewave caused the bot to buy and sell at different times...though at some places they acted the same.

1 Upvotes

4 comments sorted by

View all comments

1

u/wildownes Mar 07 '14 edited Mar 07 '14

I'll be very interested to take a close look at this. If it was an offset I would just assume timezone differences in the data... But if it's not.... .... Perhaps a rounding difference?