Overall Statistics |
Total Orders 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 100000 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic 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 -1.959 Tracking Error 0.189 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
from AlgorithmImports import * from QuantConnect.DataSource import * class USEquityOptionsDataAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2020, 6, 1) self.set_end_date(2020, 8, 1) self.set_cash(100000) self.universe_settings.asynchronous = True # Requesting data self.underlying = self.add_equity("GOOG").symbol option = self.add_option("GOOG") self.option_symbol = option.symbol # To speculate trade the underlying with a low cost, filter for the ATM calls that expiring in the current week # -2/+2 strike buffer is given for small price change option.set_filter(lambda u: u.include_weeklys().calls_only().strikes(-2, +2).expiration(0, 6)) self.contract = None def on_data(self, slice: Slice) -> None: # Close the underlying position if the option contract is exercised if self.portfolio[self.underlying].invested: self.liquidate(self.underlying) # Select with the lastest option chain data only chain = slice.option_chains.get(self.option_symbol) if self.contract and chain : # Select the call contracts with the furthest expiration (week end) furthest_expiry = sorted(calls, key = lambda x: x.expiry, reverse=True)[0].expiry furthest_expiry_calls = [contract for contract in calls if contract.expiry == furthest_expiry] # Get the ATM call for speculate trade with low cost and limited loss self.contract = sorted(furthest_expiry_calls, key = lambda x: abs(chain.underlying.price - x.strike))[0] self.market_order(self.contract.symbol, 1) def on_securities_changed(self, changes: SecurityChanges) -> None: for security in changes.added_securities: # Historical data history = self.history(security.symbol, 10, Resolution.MINUTE) self.debug(f"We got {len(history)} from our history request for {security.symbol}")