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
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
# region imports
from AlgorithmImports import *
from QuantConnect.DataSource import *
# endregion

class FuturesPractice4(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 1, 1)
        self.SetEndDate(2024, 1, 1)
        self.SetCash(100000)
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
        
        self.esContinuous = self.AddFuture(Futures.Indices.SP_500_E_MINI,
                                           Resolution.DAILY, 
                                           dataMappingMode=DataMappingMode.OpenInterest,
                                           dataNormalizationMode = DataNormalizationMode.Raw,
                                           extendedMarketHours=True, fillForward=True)
        self.esContinuous.SetFilter(0, 3*182)
        self._atr = AverageTrueRange(20, MovingAverageType.Simple)

    
    
    def OnData(self, slice: Slice) -> None:
        for changedEvent in slice.SymbolChangedEvents.Values:
            if changedEvent.Symbol == self.esContinuous.Symbol:
                self.Log(f"SymbolChanged event: {changedEvent}")
        
        if self.esContinuous.Symbol in slice.Keys:
            bar = slice[self.esContinuous.Symbol]
            if bar:
                self._atr.update(bar)
            if self._atr.is_ready:
                self.plot("AverageTrueRange", "atr", self._atr.current.value)
                self.plot("AverageTrueRange", "true_range", self._atr.true_range.current.value)