Back

Weekly Options Get ATM Contract Periodically

I am attempting to scan for the current Weekly ATM contracts -1/+1 on SPY on each slice.

I have setup my "Options Filter Universe" like so (0-6 days)

var option = AddOption("SPY", Resolution.Minute);
option.SetFilter(u => u.WeeklysOnly()
.Strikes(-1, 1)
.Expiration(TimeSpan.Zero, TimeSpan.FromDays(6)));

So at any given point I should be returning the contract that expires on the Friday of the current trading week - correct?  

Next I want to extract the symbol of those two contracts on each data slice:

public override void OnData(Slice slice)
{
foreach (KeyValuePair<Symbol, OptionChain> chain in slice.OptionChains){
if (chain.Key != option_symbol) continue;
OptionChain optionsChain = chain.Value;
OptionContract[] contracts = optionsChain.ToArray();
if(contracts != null && contracts.Length > 0){
// find the day the contract expires
// (all options in chain should have same Expiry due to filters?)
this.last_trading_day = contracts[0].Expiry.Date;
}
}
}

And finally, I want to print that date as a sanity check:

Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 0), () => {
if(this.last_trading_day != null){
Debug("Time: "+Time+" Next Expiry is: "+this.last_trading_day.ToShortDateString());
});

But Instead I am getting debug entires like (using 9/1 to 10/31/18), Fridays are: (9/7, 9/14, 9/21, 9/28):

Time: 9/4/2018 9:30:00 AM Next Expiry is: 1/1/0001
771 | 03:24:14:
Time: 9/5/2018 9:30:00 AM Next Expiry is: 9/5/2018
772 | 03:24:16:
Time: 9/6/2018 9:30:00 AM Next Expiry is: 9/5/2018
773 | 03:24:19:
Backtest deployed in 18.532 seconds
774 | 03:24:19:
Time: 9/7/2018 9:30:00 AM Next Expiry is: 9/7/2018
775 | 03:24:21:
Time: 9/10/2018 9:30:00 AM Next Expiry is: 9/10/2018
776 | 03:24:23:
Time: 9/11/2018 9:30:00 AM Next Expiry is: 9/10/2018
777 | 03:24:25:
Time: 9/12/2018 9:30:00 AM Next Expiry is: 9/12/2018
778 | 03:24:27:
Time: 9/13/2018 9:30:00 AM Next Expiry is: 9/12/2018
779 | 03:24:30:
Time: 9/14/2018 9:30:00 AM Next Expiry is: 9/14/2018
780 | 03:24:32:
Time: 9/17/2018 9:30:00 AM Next Expiry is: 9/17/2018
781 | 03:24:34:
Time: 9/18/2018 9:30:00 AM Next Expiry is: 9/17/2018
782 | 03:24:35:
Time: 9/19/2018 9:30:00 AM Next Expiry is: 9/19/2018
783 | 03:24:37:
Time: 9/20/2018 9:30:00 AM Next Expiry is: 9/19/2018
784 | 03:24:39:
Time: 9/21/2018 9:30:00 AM Next Expiry is: 9/19/2018
785 | 03:24:41:
Time: 9/24/2018 9:30:00 AM Next Expiry is: 9/19/2018
786 | 03:24:43:
Time: 9/25/2018 9:30:00 AM Next Expiry is: 9/19/2018
787 | 03:24:45:
Time: 9/26/2018 9:30:00 AM Next Expiry is: 9/19/2018
788 | 03:24:47:
Time: 9/27/2018 9:30:00 AM Next Expiry is: 9/19/2018
789 | 03:24:49:
Time: 9/28/2018 9:30:00 AM Next Expiry is: 9/19/2018
790 | 03:24:51:
Time: 10/1/2018 9:30:00 AM Next Expiry is: 9/19/2018
791 | 03:24:53:
Time: 10/2/2018 9:30:00 AM Next Expiry is: 9/19/2018
792 | 03:24:55:
Time: 10/3/2018 9:30:00 AM Next Expiry is: 9/19/2018
Update Backtest







I've realized that CBOE SPX Weekly Options have Monday, Wednesday, and Friday (EOW) contract expirations! 

http://www.cboe.com/products/stock-index-options-spx-rut-msci-ftse/s-p-500-index-options/spx-weeklys-options-spxw

This explains a lot!

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