Back

Key Not Present in TradeBar Dictionary

Odd thing.

I am backtesting looking at just 2 currencies in Second resolution. When I set start date to SetStartDate(2011, 07, 01) it runs fine.

When I try LESS data i.e. SetStartDate(2012, 07, 01) I get:

Runtime Error: The given key was not present in the dictionary.

Why might that be?
Update Backtest








Its probably not about the data period -- but that there wasn't any data on that day (Weekend or no data in that particular second). To be safe you should always use:

if (data.ContainsKey("EURUSD")) {
//Use data
}

We're changing the data format very shortly, we're moving it all to a generic data handler but it will still work like a dictionary.
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


That worked fine. Thank you
0

Perfect, in theory it should fill forward with the previous TradeBar but if its the first TradeBar of the day it might cause this error. I'll see about inserting empty TradeBars or returning null when there isn't any data yet to fix this going forward -
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed