- ago
Notice in the code below, I call the BarHistory.TradingDaysBetweenDates(...) property twice with its date parameters switched. I one case I get "trading days" between dates. In the other case, I get "calendar days" between dates. Is this inconsistent behavior by design or a bug? I think this behavior is confusing. I do want the negative value, but I want it to represent "trading days", not "calendar days".

CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; using WealthLab.Data; //* Fundamental event data here *// using WealthLab.Fundamental; namespace WealthScript2 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) {          List<EventDataPoint> earnings = bars.GetEventDataPoints("Earnings"); //most recent earnings          if (earnings.Count != 0)          {             EventDataPoint fiEPSmrq = earnings[earnings.Count-1];             int tradingDaysUntilEarnings = bars.TradingDaysBetweenDates(bars.DateTimes[bars.Count-1], fiEPSmrq.Date); //in past, so negative             WriteToDebugLog(tradingDaysUntilEarnings.ToString("0=tradingDaysUntilEarnings"));             tradingDaysUntilEarnings = bars.TradingDaysBetweenDates(fiEPSmrq.Date, bars.DateTimes[bars.Count-1]); //in past, so negative             WriteToDebugLog(tradingDaysUntilEarnings.ToString("0=tradingDaysUntilEarnings"));          }       }       public override void Execute(BarHistory bars, int idx) { } } }
0
102
Solved
2 Replies

Reply

Bookmark

Sort
Cone8
 ( 25.44% )
- ago
#1
Interesting. I'll check it out.
0
Cone8
 ( 25.44% )
- ago
#2
It's initializing to the full time span (there's a reason for it) and only completing the Trading Days calculation when the first date is less than the second. We'll get that fixed. Thanks for reporting it.
1
Best Answer

Reply

Bookmark

Sort