Back

Import Custom Date: Overrider Reader and set Time field

I've read two documents:
https://www.quantconnect.com/lean/documentation/topic16.html
https://www.quantconnect.com/docs/algorithm-reference/importing-custom-data#Importing-Custom-Data-Initializing-Custom-Data

For me, there's not enough clarity in regards to the Time field. First, I know that we override GetSource to provide the URL or local data file for the datafeed.Second, we override Reader to parse the datafeed. At a minimum, we set the following fields:

Symbol - Should always be set to config.Symbol
Time - Required synchronization of custom data
Value - Required for purchasing and portfolio calculations

I know the DateTime.Parse() function is available. My question is, does the Time field need Date only, Time only or Date and Time?

If the datafeed only provides the Date (YYYY-MM-DD) only, then that implies Daily resolution. If the datafeed only provides the Time (HH:MM), then QuantConnect can't sync on the dates. If the datafeed provides Date and Time (YYYY-MM-DD HH:MM), then QuantConnect can sync on the date and time.

If my custom datafeed is a Resolution of one Minute, then it seems to me that my custom datafeed should provide Date and Time to the Time field. So then, if my datafeed's first field is YYYY-MM-DD HH:MM and I use the DateTime.Parse() function, then it should work?

Time = DateTime.Parse(customdata[0]); 

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.


Hi Michael,

Yes, this would be the correct method although I would suggest using the CultureInfo.InvariantCulture parameter as well to make sure that the date format is completely standardized and compatible with QuantConnect's API.

Time = DateTime.Parse(customdata[0], CultureInfo.InvariantCulture);

 

1

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