- ago
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).
0
265
Solved
5 Replies

Reply

Bookmark

Sort
Cone8
 ( 5.88% )
- ago
#1
CODE:
WriteToDebugLog(Backtester.Strategy.DataRange);
0
Best Answer
- ago
#2
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:

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.
0
- ago
#3
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.
0
Cone8
 ( 5.88% )
- ago
#4
You're aware of the quality of free Alpaca data?

All About WealthLab Intraday and Realtime Data Providers
0
- ago
#5
Yes, thanks Cone.
0

Reply

Bookmark

Sort