Overall Statistics
Total Trades
1112
Average Win
0.73%
Average Loss
-0.59%
Compounding Annual Return
6.808%
Drawdown
50.200%
Expectancy
0.186
Net Profit
43.486%
Sharpe Ratio
0.317
Probabilistic Sharpe Ratio
2.604%
Loss Rate
47%
Win Rate
53%
Profit-Loss Ratio
1.25
Alpha
-0.051
Beta
1.538
Annual Standard Deviation
0.285
Annual Variance
0.081
Information Ratio
-0.013
Tracking Error
0.133
Treynor Ratio
0.059
Total Fees
$18760.90
Estimated Strategy Capacity
$1600000000.00
Lowest Capacity Asset
ES Y9CDFY0C6TXD
Portfolio Turnover
5.98%
# region imports
from AlgorithmImports import *
# endregion

class CreativeOrangeBull(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 1)
        self.SetEndDate(2023, 6, 25)
        self.SetCash(10_000_000)
        
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)

        self.future = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Hour, leverage = 1.0, extendedMarketHours = False)
        self.future.SetFilter(timedelta(0), timedelta(180))
        self.Settings.MinimumOrderMarginPortfolioPercentage = 0.0

        benchmark = self.AddEquity("SPY")
        self.SetBenchmark(benchmark.Symbol)
        self.lastDay = None


    def OnData(self,slice):
        if (not self.IsMarketOpen(self.future.Symbol) or self.Time.hour != 10):
            return
        if (self.lastDay == self.Time.day):
            return

        self.lastDay = self.Time.day
        contracts = slice.FuturesChains.get(self.future.Symbol)
        if not contracts:
            return
        
        dscContracts = sorted(contracts, key = lambda x: x.OpenInterest, reverse=True)
        if len(dscContracts) < 1: 
            return
        contract = dscContracts[0]

        self.SetHoldings([
            PortfolioTarget(contract.Symbol, 0.1),
        ], liquidateExistingHoldings = True)