How to write your own Historical MarketDataFeed

124 views
Skip to first unread message

Sfl

unread,
Jul 16, 2013, 9:53:08 AM7/16/13
to tbg-quant...@googlegroups.com
How to write your own Historical MarketDataFeed
_____________________________________________________________________________
 

Write your own historical marketDataFeed for backtesting purpose is quite easy and requires a common knowlede of java language.

We want to introduce you with the example provided on GitHub repository: 




WHAT TO DO ( Steps ):

1) Identify your data source
    It can be an online website, a CSV file, a TXT file, etc...
2) Write your own code to access the data source

3) Write your own code to map your data source data with MarketDataEventTypes: CandleEvent or TickEvent (in according with your data source).

4) Put it all togheter

5) Write a Skel strategy to test your customMarketDataFeed
   See the Strategy on GitHub.

6) Feel free to share it with us


Here is the example of a customMarketDataFeed:

[...]
public class MyCustomMarketDataFeed extends BacktestMarketDataFeedBase implements IMarketDataFeed{

 
protected final static Logger log = Logger.getLogger(MyCustomMarketDataFeed.class);

 
private BufferedReader input;
 
private boolean skipFirstLine = true;


 
public MyCustomMarketDataFeed(){
     
this.setMarketDataEvent(MarketDataEventType.CANDLE_EVENT);
 
}




 
/*
 * (non-Javadoc)
 * @see com.tbg.core.model.marketDataFeed.BacktestMarketDataFeedBase#onSubscribeMarketData(com.tbg.core.model.Security)
 */

 
@Override
 
public void onSubscribeMarketData(Security security) {
     downloadQuotes
(security);
 
}


 
/**
 * Downloads Quotes
 * @param security
 */

 
private void downloadQuotes(Security security){


   
// Put here your code to access your Data Source
   
// -> Get the historical data for the given security
 
   
// define an empty list of events (in this examples candles)
   
ArrayList<CandleEvent> candles = new ArrayList<CandleEvent>();
 
   
// for each dataRow map the MarketEventType
 
   
CandleEvent candleEvent = new CandleEvent();
   candleEvent
.setSymbol(security.getSymbol().toString());
   candleEvent
.setOpenPrice(OPEN);
   candleEvent
.setHighPrice(HIGH);
   candleEvent
.setLowPrice(LOW);
   candleEvent
.setClosePrice(CLOSE);
   candleEvent
.setTimeStamp(TIMESTAMP);
   candleEvent
.setVolume(VOLUME);
 
   
if (debug) log.info(" ====> Csv Candle: "+candleEvent.toString());
 
   
// add the single CandleEvent to the candle list
   candles
.add(candleEvent);
 
   
// end of for each row
 
   
// Finally
   candleEvents
.put(security, candles);
 
 
}

 
@Override
 
public void connectToMarketFeed() {
   log
.info("Connected to YahooMarketDataFeed.");
 
}


 
@Override
 
public void disconnectFromMarketDataFeed() {
   log
.info("Connection to YahooMarketDataFeed closed.");
 
}

}





We are looking for someone who wants to implement the Quandl MarketDataFeed ( www.quandl.com ).
Other historical data sources are welcomed, expecially for Indian or Asian markets.

Please contact us for more details.

Thank you
:-)

ancien...@gmail.com

unread,
Oct 22, 2013, 2:30:39 PM10/22/13
to tbg-quant...@googlegroups.com
I am interested in developing a market data and order execution adapter to Rithmic RAPI. Right now I'm evaluating platforms where I can most easily integrate. The problem is that the RAPI is C/C++ so the adapter will not be easy to go back from C++ to Java. I might have to use a socket connection worst case.

I am also interested in seeing if I run into build problems etc. how helpful the community will be to support the code base. So far it looks like the IB connection is just about the only broker connection.

the BonnotGang

unread,
Oct 23, 2013, 5:03:51 AM10/23/13
to tbg-Quant-community
Hello,

Yes, InteractiveBrokers is now the only adapter available for free.
We are all very busy in this period but we can support you if occours in any issues related with the implementation of the Adapter, we will be less helpfull if you get some issue with C/C++ bridging.

thank you


---
You received this message because you are subscribed to the Google Groups "tbg-Quant-community" group.
To post to this group, send email to tbg-quant...@googlegroups.com.

kanek...@gmail.com

unread,
Jun 7, 2014, 11:34:43 AM6/7/14
to tbg-quant...@googlegroups.com
This should get your started.
https://github.com/iamtrask/quandl-java
Reply all
Reply to author
Forward
0 new messages