How to use TBGMarketDataFeed

52 views
Skip to first unread message

Brian Sherman

unread,
Apr 29, 2013, 9:43:12 PM4/29/13
to tbg-quant...@googlegroups.com
Hi,

I'm trying to write a strategy for the VXX.  I'm trying to use the VXX TBG one minute data.  In the documentation it mentions the following for a TBGMarketDataFeed with no other documentation.

private final TBGMarketDataFeed marketDataFeed = new TBGMarketDataFeed();
    {
        marketDataFeed.setMarketDataFeedId(112);
        marketDataFeed.setTbgMode(TBGMarketDataFeed.TBG_MODE_ONLINE);
        marketDataFeed.setTBGParameters("3", "8", "2011", "17", "9", "2012");
        // set the MarketDataEvent type, trades or candles ? 
        //marketDataFeed.setMarketDataEvent(MarketDataEventType.TRADE_EVENT); 
        marketDataFeed.setMarketDataEvent(MarketDataEventType.CANDLE_EVENT);
    }

What is the setMarketDataFeedId(112) ?  How would I select VXX data?  Also if I set it to mode OFFLINE, how do I point my strategy to the CSV file I downloaded off the TBG website?

Finally, does this data behave similar to the Yahoo historical data where you can zip through large timespans of data in minutes for back testing?

Thanks for your help.

Sfl

unread,
Apr 30, 2013, 5:04:10 AM4/30/13
to tbg-quant...@googlegroups.com
Hello Brian,

I posted an example on GitHub   ( HelloTBG.java ) :  


>What is the setMarketDataFeedId(112) ?  
Skip it, it just set an ID to the object.

>How would I select VXX data?  
>Also if I set it to mode OFFLINE, how do I point my strategy to the CSV file I downloaded off the TBG website?


Ok, we have two different entity:

1 - MarketDataFeed 
2 - Security

In the MarketDataFeed you define how ( Online or Offline ) get the data,  the event type ( Candles or Ticks ) and a data range.
TBG data comes with 1 minute candles, if you set the EventType to CANDLES means that you are using the natural data.
If you set the EventType to TICKS, the backtester generates some "random" ticks within the single candle.

In the Security entity you set which security you want to subscribe to the MarketDataFeed. 
Let's see here an example:

/**
 * Sets the security
 */
private final Security s = new Security();
{
s.setSymbol(new Symbol("VXX")); // ONLINE MODE
s.setSecurityType(SecurityType.STK);
s.setExchange("SMART");
s.setCurrency(Currency.USD);  
}; 

If you save the CSV offline, just set the OFFLINE mode inside the MarketDataFeed and set the Symbol like this:   s.setSymbol(new Symbol("C:\YourPathTo\VXX_1m.csv")); // OFFLINE

I hope the example on GitHub can help you, contact me if you have any issues.

>Finally, does this data behave similar to the Yahoo historical data where you can zip through large timespans of data in minutes for back testing?

TBG historical data are raw data, I would not suggest to backtest directly without apply some cleaning filters.

bye
Alberto

Brian Sherman

unread,
Apr 30, 2013, 10:23:00 AM4/30/13
to tbg-quant...@googlegroups.com
Hi Alberto,

Thanks so much for your quick response.  This is exactly what I needed.

-Brian
Reply all
Reply to author
Forward
0 new messages