Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0.00%
Compounding Annual Return
-0.054%
Drawdown
0.000%
Expectancy
-1
Net Profit
-0.006%
Sharpe Ratio
-238.533
Sortino Ratio
-67.656
Probabilistic Sharpe Ratio
0.019%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-2.968
Tracking Error
0
Treynor Ratio
0
Total Fees
$1.00
Estimated Strategy Capacity
$6000.00
Lowest Capacity Asset
FAST X5IQJTFWPOQU|FAST R735QTJ8XC9X
Portfolio Turnover
0.00%
# region imports
from AlgorithmImports import *
# endregion

class OSLBug(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 5, 19)
        self.SetEndDate(2019, 6, 30)
        self.SetCash(100000)
        self.SetSecurityInitializer(self.CustomSecurityInitializer)
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
        self.symbol = self.AddEquity("FAST", Resolution.Minute, dataNormalizationMode=DataNormalizationMode.Raw).Symbol
        self.traded = False

    def CustomSecurityInitializer(self, security: Security):
        seeder = FuncSecuritySeeder(self.GetLastKnownPrices)
        seeder.SeedSecurity(security)

    def OnData(self, data: Slice):
        if not self.traded and not self.Portfolio.Invested:
            contracts = self.OptionChainProvider.GetOptionContractList(self.symbol, self.Time)
            filtered_symbols = [symbol for symbol in contracts
                    if symbol.ID.Date - self.Time >= timedelta(days=7)]
            sorted_symbols = sorted(filtered_symbols, key=lambda x: x.ID.Date)
            contract_symbol = sorted_symbols[0]
            self.AddOptionContract(contract_symbol)
            self.MarketOrder(contract_symbol, 1)
            self.traded = True

        if self.Time.day > 22:
            self.Liquidate(tag="Try to liquidate")