I tried getting the data range for a backtest using two different properties called from my strategy's Initialize() method:
StrategyHost.Strategy.DataRange
Backtest.Strategy.DataRange
but both of those properties always return start and end dates of 01/01/0001 12:00 AM. I searched through the online help, but could not find an alternative way that worked. Is there some method I can call to get the actual backtest dates?
And, I do realize the StartDate and EndDate are available from the bars in Initialize(), but I need to know what was set for the strategy, because the bars may end up with a smaller date range due to a smaller data set available from the provider (like Schwab limiting one-minute bars to about 6 weeks).
StrategyHost.Strategy.DataRange
Backtest.Strategy.DataRange
but both of those properties always return start and end dates of 01/01/0001 12:00 AM. I searched through the online help, but could not find an alternative way that worked. Is there some method I can call to get the actual backtest dates?
And, I do realize the StartDate and EndDate are available from the bars in Initialize(), but I need to know what was set for the strategy, because the bars may end up with a smaller date range due to a smaller data set available from the provider (like Schwab limiting one-minute bars to about 6 weeks).
Rename
CODE:
WriteToDebugLog(Backtester.Strategy.DataRange);
In my original post I should have stated, in the second option, Backtester.Strategy.DataRange.
While you can get the string equivalent (e.g. 1 month), as you have shown, the start and end dates are still 01/01/0001 12:00 AM if you use the following:
If there is no other alternative, and the above can't be changed, then I guess I can build new unlinked datasets that are the equivalent of my Schwab-linked data sets. Then I can snag the Alpaca data (by having it as the second provider) if there is insufficient Schwab data.
While you can get the string equivalent (e.g. 1 month), as you have shown, the start and end dates are still 01/01/0001 12:00 AM if you use the following:
CODE:
WriteToDebugLog($"Backtester start date: {Backtester.Strategy.DataRange.StartDate}, end date: {Backtester.Strategy.DataRange.EndDate}");
If there is no other alternative, and the above can't be changed, then I guess I can build new unlinked datasets that are the equivalent of my Schwab-linked data sets. Then I can snag the Alpaca data (by having it as the second provider) if there is insufficient Schwab data.
I see now how it works. If the data range specified in the strategy settings is a Date Range, as opposed to say Recent n Months, then you get the correct StartDate and EndDate values.
You're aware of the quality of free Alpaca data?
All About WealthLab Intraday and Realtime Data Providers
All About WealthLab Intraday and Realtime Data Providers
Yes, thanks Cone.
Your Response
Post
Edit Post
Login is required