Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
import numpy as np from datetime import timedelta ### <summary> ### Basic template algorithm simply initializes the date range and cash. This is a skeleton ### framework you can use for designing an algorithm. ### </summary> class BasicTemplateAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def Initialize(self): self.SetStartDate(2017, 6, 1) self.SetEndDate(2017, 6, 15) self.AddEquity("IBM", Resolution.Minute) self.option = self.AddOption("IBM", Resolution.Minute) self.option.SetFilter(-3, +3, timedelta(0), timedelta(30)) self.Schedule.On(self.DateRules.EveryDay("IBM"),self.TimeRules.AfterMarketOpen("IBM", 60),Action(self.print_first_hour)) def OnData(self, slice): self.option_data = slice def print_first_hour(self): for chain in self.option_data.OptionChains.Values: contracts = sorted(sorted(chain, key = lambda x: abs(chain.Underlying.Price - x.Strike)), key = lambda x: x.Expiry, reverse=True) price = contracts[0].LastPrice self.Debug(str(price))