Back

Custom Data Questions

Hi, two questions:

One of my newer custom sources has two lines of data as "headers" in the csv file.  In my custom code, I invoke base subscription reader, etc, but not sure if it will throw warnings or errors when attempting to read a line that doesn't parse correctly.  Is there a way to control how many lines are skipped in reading custom files?

Also, is there a way to invoke custom data so that it redownloads a new file every day in live mode, but only download the file once in backtesting mode (so that during backtesting the custom data source doesn't get pinged millions of times within the span of five minutes)?

Thanks!

-Stephen

Update Backtest








And in traditional fashion, I shall answer my first question!  Apparently headers don't matter at all to the LEAN engine; I just used a csv file with header rows and it skipped right over them.

However if anyone has an answer to the second question, I'd much appreciate it.

0

Regarding you first answer, we can either check whether the line is a header or use a try-catch to return null. nulls are skipped. If we have a try-catch statement with a catch that doesn't return/throw, when we try to parse a header into a DateTime, the result is an instance with EndTime equals to DateTime.MinValue. That instance will be skipped since DateTime.MinValue is lower than StartDate.

In backtesting, a file is pinged and redownloaded only once during the execution.

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.


Its downloaded anytime the URL changes; so if you want to fix it in

backtesting use the same URL each time,
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.


Ah fantastic, thanks!

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.


Loading...

This discussion is closed