I would like to do backtest some of the strategies that we automate. We need data of expired contracts to, let's say "9000PE" of JAN Expiry is what we need. since we don't have the instrument token, gone through the documentation and used the "NIFTY20MAY9000PE" and changed the dates whichever we need and tried to get the data but all in vain.
Was going through ht he forum and learned we don't have data for option contracts? Is that true still? How to do backtest in that case?
Please suggest some options to move forward with backtesting our logic.
this is the sample code String instrument = "NFO:NIFTY20MAY9000PE"; KiteConnect kiteConnect = algoUtils.getKiteConnect(); String[] instruments = {instrument}; Map quotes = kiteConnect.getQuote(instruments); System.out.println(quotes.get(instrument).instrumentToken+"");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date from = new Date(); Date to = new Date(); try { from = formatter.parse("2020-01-03 09:15:00"); to = formatter.parse("2020-01-03 15:30:00"); }catch (ParseException e) { e.printStackTrace(); } HistoricalData historicalData = kiteConnect.getHistoricalData(from, to, "12175106", "15minute", true, true); System.out.println(historicalData.dataArrayList.size());
this is the sample code
String instrument = "NFO:NIFTY20MAY9000PE";
KiteConnect kiteConnect = algoUtils.getKiteConnect();
String[] instruments = {instrument};
Map quotes = kiteConnect.getQuote(instruments);
System.out.println(quotes.get(instrument).instrumentToken+"");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date from = new Date();
Date to = new Date();
try {
from = formatter.parse("2020-01-03 09:15:00");
to = formatter.parse("2020-01-03 15:30:00");
}catch (ParseException e) {
e.printStackTrace();
}
HistoricalData historicalData = kiteConnect.getHistoricalData(from, to, "12175106", "15minute", true, true);
System.out.println(historicalData.dataArrayList.size());