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.031 Tracking Error 0.675 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
from System import * from QuantConnect import * from QuantConnect.Data.Consolidators import * from QuantConnect.Data.Market import * from QuantConnect.Orders import OrderStatus from QuantConnect.Algorithm import QCAlgorithm from QuantConnect.Indicators import * import numpy as np from datetime import timedelta, datetime class MultipleSymbolMultipleIndicatorDatapoint(QCAlgorithm): def Initialize(self): self.SetBrokerageModel(BrokerageName.FTX, AccountType.Cash) self.DefaultOrderProperties = FTXOrderProperties() self.DefaultOrderProperties.PostOnly = True self.Data = {} # The dictionary to use self.VolumeLong = {} self.VolumeShort = {} self.LastTransactionPrice = {} self.CurrentPrice = {} self.HoldingsInvested = {} self.MinuteMACD = {} self.HourMACD = {} self.DailyMACD = {} self.EntryPrice = {} self.Channel = {} self.ChannelQuick = {} self.ChannelLong = {} self.ChannelShort = {} self.InitialHoldings = {} self.sellAmount = {} self.bull = {} self.ExitPrice = {} self.Sales = {} self.DailyAverage = {} self.SMALong = {} self.ExitTrigger = {} self.EquitySymbols = ["SOLUSD", "MATICUSD", "FTMUSD"] # As many as you like. This can also work with a QC Universe # Date bookends self.SetStartDate(2021, 1, 1) self.SetEndDate(2022, 1, 4) self.SetCash(10000) self.buffer = 0 #Buffer - adjust to allow extra money for purchases. # initialize our equity data for symbol in self.EquitySymbols: equity = self.AddCrypto(symbol, Resolution.Minute) self.buffer += 1.05 #Averaging indicators self.VolumeShort[symbol] = self.SMA(equity.Symbol, 20, Resolution.Hour, Field.Volume) self.VolumeLong[symbol] = self.SMA(equity.Symbol, 100, Resolution.Hour, Field.Volume) self.DailyAverage[symbol] = self.SMA(equity.Symbol, 1, Resolution.Daily) self.SMALong[symbol] = self.SMA(equity.Symbol, 200, Resolution.Daily) self.ExitTrigger[symbol] = self.EMA(equity.Symbol, 100, Resolution.Daily) #MACD indicators self.MinuteMACD[symbol] = self.MACD(equity.Symbol, 12, 26, 9, MovingAverageType.Exponential, Resolution.Minute) self.HourMACD[symbol] = self.MACD(equity.Symbol, 12, 26, 9, MovingAverageType.Exponential, Resolution.Hour) self.DailyMACD[symbol] = self.MACD(equity.Symbol, 12, 26, 9, MovingAverageType.Exponential, Resolution.Daily) #DCH indicators self.Channel[symbol] = self.DCH(equity.Symbol,2,10,Resolution.Daily) self.ChannelQuick[symbol] = self.DCH(equity.Symbol,30,20,Resolution.Hour) self.ChannelLong[symbol] = self.DCH(equity.Symbol,200,200,Resolution.Daily) self.ChannelShort[symbol] = self.DCH(equity.Symbol,100,100,Resolution.Daily) #Price and Settings self.LastTransactionPrice[symbol] = round(self.Securities[symbol].Price * 1.00, 2) self.EntryPrice[symbol] = round(self.Securities[symbol].Price * 1.00, 2) self.ExitPrice[symbol] = round(self.Securities[symbol].Price * 1.00, 2) self.bull[symbol] = 0 self.Sales[symbol] = 0 asset = symbol.replace("USD","") holdings = self.Portfolio.CashBook[asset].Amount self.InitialHoldings[symbol] = holdings self.Day = 0 self.SetWarmup(200, Resolution.Daily) # this number should be 1 less than the indicator that we are waiting for to avoid premature trades. def OnData(self,data): usdTotal = self.Portfolio.CashBook["USD"].Amount tolerance = 0.00015; # loop through each symbol in our structure for symbol in self.EquitySymbols: if not self.SMALong[symbol].IsReady: return if 1 == 1: self.CurrentPrice[symbol] = round(self.Securities[symbol].Price * 1.00, 2) asset = symbol.replace("USD","") holdings = self.Portfolio.CashBook[asset].Amount if self.Time.hour % 2 == 0 and self.Time.minute == 11: if holdings > 0 and not self.Transactions.GetOpenOrders(): self.bull[symbol] = 1 if self.Time.hour % 1 == 0 and self.Time.minute == 0: self.Debug(str(symbol) + str(" minute/hour MACD: ") + str(self.MinuteMACD[symbol]) + str("/") + str(self.HourMACD[symbol])) if not self.Portfolio[symbol].Invested: self.Debug(str(symbol) + str(" Donchian 30-hour high/2-day/price: ") + str(self.ChannelQuick[symbol].UpperBand) + str( "/") + str(self.Channel[symbol].UpperBand) + str("/") + str(self.CurrentPrice[symbol])) elif self.Portfolio[symbol].Invested: self.Debug(str(symbol) + str(" Donchian 10-day low/price: ") + str(self.Channel[symbol].LowerBand) + str("/") + str(self.CurrentPrice[symbol])) self.Debug(str(symbol) + str(" current/average volume: ") + str(self.VolumeShort[symbol]) + str("/") + str(self.VolumeLong[symbol])) self.Debug(str(symbol) + str(" bull: ") + str(self.bull[symbol])) for cash in self.Portfolio.CashBook.Values: self.Debug(f"Holding {cash.Amount} of {cash.Symbol} (${cash.ValueInAccountCurrency} USD value)") def OnEndOfDay(self, symbol): for symbol in self.EquitySymbols: #Log the end of day prices: self.Plot(symbol, "Price", str(self.DailyAverage[symbol]))