The monthly option expiry of 4/14/22 is not recognized in WL8 (though it is in WLD6.9).
Test code:
Debug window output:
Chart shows the bar is not highlighted:
CBOE Options Expiration Calendar (I circled the missing date):
Monthly options typically expire on the 3rd Friday. This year that was a Good Friday (4/15/22) and the US markets were closed so the option expiration was 1 day ahead i.e. on 4/14/22 as the calendar shows.
Please fix.
P.S. I only checked the last 2 years of data.
Test code:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript2 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (bars.DateTimes[idx].IsOptionExpiry()) { SetBackgroundColor(bars, idx, WLColor.FromArgb(64, WLColor.LightPink)); WriteToDebugLog(bars.DateTimes[idx].ToShortDateString()); } } //declare private variables below } }
Debug window output:
Chart shows the bar is not highlighted:
CBOE Options Expiration Calendar (I circled the missing date):
Monthly options typically expire on the 3rd Friday. This year that was a Good Friday (4/15/22) and the US markets were closed so the option expiration was 1 day ahead i.e. on 4/14/22 as the calendar shows.
Please fix.
P.S. I only checked the last 2 years of data.
Rename
April 14, 2022 is NOT a Friday (it's Thursday) and therefore cannot be recognized by IsOptionExpiry. By design. NextOptionExpiryDate should handle this case correctly, though.
I know its a Thursday and the option expiry happened on that day by circumstance.
Are you saying the developers are not going to fix it?
Are you saying the developers are not going to fix it?
It serves its purpose which is being fast in the first place, not precise. You can use NextOptionExpiryDate which is programmed to be precise (calendar wise).
IsOptionExpiry() won't change. If we don't know the BarHistory we're dealing with (and therefore the holidays), this function will only be true on the 3rd Friday.
We can make an overloaded method for IsOptionExpiry that takes a BarHistory, as takes NextOptionExpiryDate - and that's why this one works.
We can make an overloaded method for IsOptionExpiry that takes a BarHistory, as takes NextOptionExpiryDate - and that's why this one works.
We've got that in place for Build 17, but for now, you can get the result you're looking for just by replacing IsOptionExpiry() with this:
CODE:
if (bars.DateTimes[idx] == bars.DateTimes[idx].NextOptionExpiryDate(bars))
Maybe we could default the method to use the US Stocks holidays when no market is specified? I think that would be the expected behavior.
Your Response
Post
Edit Post
Login is required