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 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 |
# region imports from AlgorithmImports import * # endregion class LearningFutures(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 4, 16) # Set Start Date self.SetEndDate(2020, 4, 23) #self.SetCash(1000000) # Set Strategy Cash self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) self.f = self.AddFuture(Futures.Energies.CrudeOilWTI, resolution=Resolution.Daily, extendedMarketHours=False, dataNormalizationMode = DataNormalizationMode.ForwardPanamaCanal, dataMappingMode=DataMappingMode.LastTradingDay, contractDepthOffset=0) def OnData(self, data: Slice): if self.IsWarmingUp: return if (len(data.SymbolChangedEvents.Values) > 0): for changed_event in data.SymbolChangedEvents.Values: if changed_event.OldSymbol in self.Portfolio: self.Debug(f"{self.Time.date}: Contract rollover from {changed_event.OldSymbol} to {changed_event.NewSymbol}") return d = str(self.Time) hist_mapped = self.History(self.f.Mapped, 1, Resolution.Daily) offset_c = data[self.f.Symbol].Close - hist_mapped['close'][0] offset_o = data[self.f.Symbol].Open - hist_mapped['open'][0] offset_h = data[self.f.Symbol].High - hist_mapped['high'][0] self.Debug(f"{d}: Mapped contract: {self.f.Mapped.Value}; Mapped close: {hist_mapped['close'][0]}; Continuous close: {data[self.f.Symbol].Close}; Offset_close: {offset_c}; Offset_open: {offset_o}; ; Offset_high: {offset_h}")