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 1.203 Tracking Error 0.068 Treynor Ratio 0 Total Fees $0.00 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Data.Consolidators import * from datetime import timedelta from QuantConnect.Indicators import CommodityChannelIndex, Stochastic from QuantConnect.Data import Slice class NotebookProject(QCAlgorithm): wti_thirtyMinute = None gold_thirtyMinute = None naturalgas_thirtyMinute = None def Initialize(self): self.SetTimeZone("Europe/London") self.SetBrokerageModel(BrokerageName.OandaBrokerage) #self.SetStartDate(DateTime(2020, 6, 29)) #Set Start Date self.SetStartDate(datetime.now() - timedelta(2)) #Set Start Date #self.SetEndDate(DateTime(2020, 7, 1)) #Set End Date self.SetEndDate(datetime.now()) #Set End Date self.wticousd = self.AddCfd("WTICOUSD", Resolution.Minute, Market.Oanda) self.gold = self.AddCfd("XAUUSD", Resolution.Minute, Market.Oanda) self.natgasusd = self.AddCfd("NATGASUSD", Resolution.Minute, Market.Oanda) self.wticousd.SetDataNormalizationMode(DataNormalizationMode.Raw) self.gold.SetDataNormalizationMode(DataNormalizationMode.Raw) self.natgasusd.SetDataNormalizationMode(DataNormalizationMode.Raw) #WEST TEXAS thirtyMinuteConsolidator = QuoteBarConsolidator(timedelta(minutes=15)) thirtyMinuteConsolidator.DataConsolidated += self.ThirtyMinuteQuoteBarHandler self.SubscriptionManager.AddConsolidator("WTICOUSD", thirtyMinuteConsolidator) #GOLD gold_thirtyMinuteConsolidator = QuoteBarConsolidator(timedelta(minutes=15)) gold_thirtyMinuteConsolidator.DataConsolidated += self.gold_ThirtyMinuteQuoteBarHandler self.SubscriptionManager.AddConsolidator("XAUUSD", gold_thirtyMinuteConsolidator) #NATURAL GAS naturalgas_thirtyMinuteConsolidator = QuoteBarConsolidator(timedelta(minutes=15)) naturalgas_thirtyMinuteConsolidator.DataConsolidated += self.naturalgas_ThirtyMinuteQuoteBarHandler self.SubscriptionManager.AddConsolidator("NATGASUSD", naturalgas_thirtyMinuteConsolidator) self.sto_wti = Stochastic("WTICOUSD", 350, 21, 21) self.cci_wti = CommodityChannelIndex("WTICOUSD", 175) self.sto_gold = Stochastic("XAUUSD", 172, 21, 95) self.cci_gold = CommodityChannelIndex("XAUUSD", 200) self.sto_naturalgas = Stochastic("NATGASUSD", 210, 21, 260) self.cci_naturalgas = CommodityChannelIndex("NATGASUSD", 200) self.PlotIndicator("Indicator-WTICOUSD ", self.sto_wti.StochD) self.PlotIndicator("Indicator-CommodityChannelIndex_WTI ", self.cci_wti.TypicalPriceAverage) self.PlotIndicator("Indicator-XAUUSD ", self.sto_gold.StochD) self.PlotIndicator("Indicator-CommodityChannelIndex_GOLD", self.cci_gold.TypicalPriceAverage) self.PlotIndicator("Indicator-NATGASUSD ", self.sto_naturalgas.StochD) self.PlotIndicator("Indicator-CommodityChannelIndex_GOLD", self.cci_naturalgas.TypicalPriceAverage) self.SetWarmup((210+21+260)*15, Resolution.Minute) def OnData(self, data): pass def ThirtyMinuteQuoteBarHandler(self, sender, consolidated): self.sto_wti.Update(consolidated) self.cci_wti.Update(consolidated) sto_value_wti = self.sto_wti.StochD cci_value_wti = self.cci_wti.ComputeNextValue if self.IsWarmingUp: return #TESTING #if (str(consolidated.Symbol) == "WTICOUSD" and (self.Time.month == 6 and self.Time.day == 18 and self.Time.hour == 9 and self.Time.minute == 0)): #self.Debug(f'{self.Time} >> STO >> {sto_value_wti} CCI >> {cci_value}') #self.Notify.Email("martintolmusk@gmail.com", "WTICOUSD Stochastic above 60", str(sto_value_wti)) # self.Debug(f'{self.Time} >> STO >> {sto_value_wti}') #LIVE #if (self.Time.month == 7 and self.Time.day == 10 and self.Time.hour == 10 and self.Time.minute == 0) and (float(str(sto_value_wti.Current.Value)) >= float(62) and float(str(sto_value_wti.Current.Value)) <= float(68)): #if float(str(sto_value_wti.Current.Value)) <= float(20) and float(str(cci_value_wti)) <= float(100): # self.Notify.Email("martintolmusk@gmail.com", "WTICOUSD Stochastic between Less Than 20", "BUY ALERT below 20 for 1,300 pips = Stochastic", str(sto_value_wti.Current.Value)) # self.Notify.Email("martintolmusk@gmail.com", "WTICOUSD CCI Must Be Less than -100", "BUY ALERT for 1,300 pips", str(cci_value_wti)) self.Debug(f'{self.Time} STO >> {cci_value_wti}') #self.Log(f'{self.Time} STO >> {sto_value_wti.Current.Value}') # #elif float(str(sto_value_wti.Current.Value)) <= float(14): #self.Debug(f'I am in elif') #self.Debug(f'{self.Time} STO >> {sto_value_wti.Current.Value}') # self.Notify.Email("martintolmusk@gmail.com", "WTICOUSD Stochastic < 30", "Buy for 1300 pips at below @14", str(sto_value_wti.Current.Value)) #else: #self.Notify.Email("martintolmusk@gmail.com", "Nonsense", "Nonsense email") #self.Log(f'{self.Time} >> STO >> {sto_value_wti.Current.Value} ') #self.Debug(f'{self.Time} >> STO >> {sto_value_wti.Current.Value} ') # return #self.Debug(f'{self.Time} >> STO >> {consolidated.Symbol}') self.wti_thirtyMinute = consolidated def gold_ThirtyMinuteQuoteBarHandler(self, sender, consolidated): self.sto_gold.Update(consolidated) self.cci_gold.Update(consolidated) sto_value_gold = self.sto_gold.StochD cci_value_gold = self.cci_gold.TypicalPriceAverage if self.IsWarmingUp: return #TESTING #if self.Time.month == 6 and self.Time.day == 18 and self.Time.hour >= 7 and self.Time.hour <= 11: #self.Debug(f'{self.Time} >> STO >> {sto_value_gold} CCI >> {cci_value}') #self.Notify.Email("martintolmusk@gmail.com", "WTICOUSD Stochastic above 60", str(sto_value_gold)) #self.Debug(f'{self.Time} >> STO >> {sto_value_gold}') #LIVE if float(str(sto_value_gold.Current.Value)) >= float(62) and float(str(sto_value_gold.Current.Value)) < float(68): self.Notify.Email("martintolmusk@gmail.com", "GOLD Stochastic between 62 and 67", "BUY ALERT for 15 dollars @66", str(sto_value_gold.Current.Value)) self.Notify.Email("martintolmusk@gmail.com", "GOLD CCI", "BUY ALERT for 15 dollars @66", str(cci_value_gold)) #self.Debug(f'{self.Time} STO >> {sto_value_gold.Current.Value}') #else: #self.Notify.Email("martintolmusk@gmail.com", "Nonsense", "Nonsense email") #self.Debug(f'{self.Time} >> STO >> {sto_value_gold.Current.Value} ') self.gold_thirtyMinute = consolidated def naturalgas_ThirtyMinuteQuoteBarHandler(self, sender, consolidated): self.sto_naturalgas.Update(consolidated) self.cci_naturalgas.Update(consolidated) sto_value_naturalgas = self.sto_naturalgas.StochD cci_value_naturalgas = self.cci_naturalgas.TypicalPriceAverage if self.IsWarmingUp: return #TESTING #if self.Time.month == 6 and self.Time.day == 18 and self.Time.hour >= 7 and self.Time.hour <= 11: #self.Debug(f'{self.Time} >> STO >> {sto_value_gold} CCI >> {cci_value}') #self.Notify.Email("martintolmusk@gmail.com", "WTICOUSD Stochastic above 60", str(sto_value_gold)) #self.Debug(f'{self.Time} >> STO >> {sto_value_gold}') #LIVE if float(str(sto_value_naturalgas.Current.Value)) <= float(20): self.Notify.Email("martintolmusk@gmail.com", "GOLD Stochastic between 62 and 67", "BUY ALERT 15 dollars below @20", str(sto_value_naturalgas.Current.Value)) self.Notify.Email("martintolmusk@gmail.com", "GOLD CCI", "BUY ALERT 15 dollars if CCI less than -150", str(cci_value_naturalgas)) #self.Debug(f'{self.Time} STO >> {sto_value_gold.Current.Value}') #else: #self.Notify.Email("martintolmusk@gmail.com", "Nonsense", "Nonsense email") #self.Debug(f'{self.Time} >> STO >> {sto_value_gold.Current.Value} ') self.naturalgas_thirtyMinute = consolidated