Multi-Instrument Strategy Backtesting

75 views
Skip to first unread message

Brian Sherman

unread,
Jul 14, 2013, 7:00:36 PM7/14/13
to tbg-quant...@googlegroups.com
Hi,

I am trying to create a strategy that requires monitoring two stocks in parallel.  When the first stock does something special, buy the second stock at its current price and when the first stock does something else, sell the second stock.

I tried running a backtest and the yahoo market data feed appears to not synchronize the historical data.  Clumps of one stock will be passed though the strategy and then clumps of the other.

Does TBG-Quant support synchronizing the backtesting of multiple symbols?  I tried the triple moving average strategy and it too does not synchronize the data playback either.

Finally, what is the status of TBG-Quant.  Is this a product that will be launched to make money? It appears there has not been much development / news in several months? You currently are on GitHub but there is no source available. Is there a plan to ever release the source?

Thanks.

the BonnotGang

unread,
Jul 15, 2013, 4:26:03 AM7/15/13
to tbg-Quant-community
Hi,
tbg-Quant has an event-driven architecture, if you run your system on a real streaming feed it will work correctly.
The issue you are talking about is about YahooMarketDataFeed and, in general, about the BackTesterBase class.

Adding the synchronizing task to the YahooMarketDataFeed is something we need to do. We will try to be more clear and post here a list of  TODOs.

What you can do now is:

1) onEvent() method you will take care of synchronization data before send to your system core.( dirty solution )
2) You wait for our solution ( we'll embedding the synchronizer inside the DataFeeder )
3) You will help us :)

tbg-Quant is not opensource, we do not belive we can get major advantages by opensource the core framework but we are always ready to change our mind.
We have been busy during the last months because we started a customization for a future project we will be eager to announce later this year, at the same time we implemented the NeuralBox package.
If we ever won't be able to spend time on tbg-quant, we will release the full sourcecode to the community.

Please all feedbacks are welcomed, I will update you about the synchronization issue.
Thank you


tbg-Quant-community

unread,
Jul 15, 2013, 9:49:23 AM7/15/13
to tbg-quant...@googlegroups.com, in...@thebonnotgang.com
Hello,

We did it.
We included the synchronizing filter inside the BackTester class, this works only for CandleEvents.


We submitted to my git repository ( MASTER ), please test it and give us feedbacks.
We will include this feature inside the tbg-quant 1.1beta6.


By setting FORCE_SYNCHRONIZATION variable to true, means you want to receive only synchronized events, ex: if for the day d exists the quote of XOM and BHP then push the events, if for the day d exists only one of the two quote, it does not push the event. By default this is set to false, means that we push events if XOM or BHP quote exist.

See the code:
marketDataFeed.FORCE_SYNCHRONIZATION = false; 

Please note that if  we are waiting for candles of 3 stocks, we expect to receive 3 events, 1 for stocks (if the candle exists for that day), to better understand this please run the example above. 

Connected to YahooMarketDataFeed.
Fetching SPY from Yahoo...
Fetching ^GDAXI from Yahoo...
Active MarketDataFeed...
onEvent():  S: ^GDAXI D : Mon Jul 01 00:00:00 CEST 2013 O : 8000.02 H : 8023.15 L : 7890.28 C : 7983.92 V : 30610300
onEvent():  S:    SPY D : Mon Jul 01 00:00:00 CEST 2013 O : 161.26 H : 162.48 L : 161.08 C : 161.36 V : 131954800
onEvent():  S: ^GDAXI D : Tue Jul 02 00:00:00 CEST 2013 O : 7988.92 H : 7988.96 L : 7873.97 C : 7910.77 V : 29054900
onEvent():  S:    SPY D : Tue Jul 02 00:00:00 CEST 2013 O : 161.12 H : 162.3 L : 160.5 C : 161.21 V : 154863700
onEvent():  S: ^GDAXI D : Wed Jul 03 00:00:00 CEST 2013 O : 7841.18 H : 7841.87 L : 7730.37 C : 7829.32 V : 34236500
onEvent():  S:    SPY D : Wed Jul 03 00:00:00 CEST 2013 O : 160.48 H : 161.77 L : 160.22 C : 161.28 V : 75216400
onEvent():  S: ^GDAXI D : Thu Jul 04 00:00:00 CEST 2013 O : 7877.91 H : 8015.08 L : 7863.76 C : 7994.31 V : 33496000
onEvent():  S: ^GDAXI D : Fri Jul 05 00:00:00 CEST 2013 O : 8010.44 H : 8031.71 L : 7805.36 C : 7806.0 V : 35643800
onEvent():  S:    SPY D : Fri Jul 05 00:00:00 CEST 2013 O : 162.47 H : 163.08 L : 161.3 C : 163.02 V : 122416900
onEvent():  S: ^GDAXI D : Mon Jul 08 00:00:00 CEST 2013 O : 7865.92 H : 8015.21 L : 7848.14 C : 7968.54 V : 31059500
onEvent():  S:    SPY D : Mon Jul 08 00:00:00 CEST 2013 O : 163.86 H : 164.39 L : 163.08 C : 163.95 V : 108092500
onEvent():  S: ^GDAXI D : Tue Jul 09 00:00:00 CEST 2013 O : 8021.13 H : 8086.95 L : 8005.73 C : 8057.75 V : 26183800
onEvent():  S:    SPY D : Tue Jul 09 00:00:00 CEST 2013 O : 164.98 H : 165.33 L : 164.27 C : 165.13 V : 119298000
onEvent():  S: ^GDAXI D : Wed Jul 10 00:00:00 CEST 2013 O : 8056.51 H : 8081.21 L : 7990.65 C : 8066.48 V : 17189200
onEvent():  S:    SPY D : Wed Jul 10 00:00:00 CEST 2013 O : 164.97 H : 165.75 L : 164.63 C : 165.19 V : 121410100
onEvent():  S: ^GDAXI D : Thu Jul 11 00:00:00 CEST 2013 O : 8163.56 H : 8176.7 L : 8130.48 C : 8158.8 V : 25814400
onEvent():  S:    SPY D : Thu Jul 11 00:00:00 CEST 2013 O : 167.11 H : 167.61 L : 165.18 C : 167.44 V : 135592200
onEvent():  S: ^GDAXI D : Fri Jul 12 00:00:00 CEST 2013 O : 8192.91 H : 8244.13 L : 8178.2 C : 8212.77 V : 29697900
onEvent():  S:    SPY D : Fri Jul 12 00:00:00 CEST 2013 O : 167.39 H : 167.93 L : 167.13 C : 167.51 V : 104191300
onStop(): 

As you can see it streams 2 events per day except for Jul4 where we got only 1 event ( becasue SPY is close ).
If the variable FORCE_SYNCHRONIZATION was setted to true, we did not receive any event on july 4.

Please we are looking forward to receive some feedbacks.
Thank you
Alberto

Brian Sherman

unread,
Jul 15, 2013, 7:54:05 PM7/15/13
to tbg-quant...@googlegroups.com, in...@thebonnotgang.com, tbg-quant...@googlegroups.com
Wow!  Thank you so much for such a quick turn around.  I'll take a look at it and let you.  Keep up the awesome work.  TBG-Quant is one of the easiest frameworks to use!


tbg-Quant-community

unread,
Jul 16, 2013, 5:56:17 AM7/16/13
to tbg-quant...@googlegroups.com, in...@thebonnotgang.com

Hi,

I just pushed a new version (git MASTER). BackTesterBase now handles both CANDLE_EVENT and TICK_EVENT.
We did other important changes, we need to pass the test stage before releasing the 1.1beta6.

thank you
bye
Reply all
Reply to author
Forward
0 new messages