Overall Statistics |
Total Trades 2 Average Win 1.43% Average Loss 0% Compounding Annual Return 26.544% Drawdown 3.800% Expectancy 0 Net Profit 1.432% Sharpe Ratio 3.949 Probabilistic Sharpe Ratio 92.254% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.302 Beta 0.009 Annual Standard Deviation 0.074 Annual Variance 0.006 Information Ratio 1.827 Tracking Error 0.633 Treynor Ratio 32.45 Total Fees $1.00 Estimated Strategy Capacity $8000.00 Lowest Capacity Asset MATICUSD 2S7 |
#region imports from AlgorithmImports import * #endregion class Solana_USD(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 10, 20) # Set Start Date self.SetEndDate(2022, 11, 11) #Set End Date #self.SetAccountCurrency("USD") self.SetCash(500) # Set Strategy Cash self.SetBrokerageModel(BrokerageName.BinanceUS, AccountType.Cash) self.symbol = self.AddCrypto("MATICUSD", Resolution.Hour, Market.BinanceUS).Symbol self.sto = Stochastic(14, 1, 3) #self.sto = self.Stochastic("MATICUSD", 14, 1, 3, Resolution.Hour) #closing_prices = self.History(self.symbol, 14, Resolution.Hour)["close"] #for time, price in closing_prices.loc[self.symbol].items(): # self.rsi.Update(time, price) chart = Chart("My Indicators") #chart.AddSeries(Series('faststoch', SeriesType.Line, "0")) chart.AddSeries(Series('MATIC stochk', SeriesType.Line, "0")) chart.AddSeries(Series('MATIC stochd', SeriesType.Line, "0")) chart.AddSeries(Series('MATIC stochastic', SeriesType.Line, "0")) #chart.AddSeries(Series('Price', SeriesType.Line, "0")) self.highestPrice = 0 self.AddChart(chart) self.next_trade_time = datetime.min self.entryPrice = 0 self.entryTicket = None self.month = 0 def IsRebalanceDue(self, time): if time.month == self.month or time.month not in [1, 4, 7, 10]: return None self.month = time.month return time def OnData(self, data): self.PlotIndicator() if data.QuoteBars.ContainsKey(self.symbol): self.sto.Update(data.QuoteBars[self.symbol]) if self.sto.IsReady: indicator_value = self.sto.Current.Value #MATIC_fast_stoch = self.sto.FastStoch.Current.Value MATIC_stoch_k = self.sto.StochK.Current.Value MATIC_stoch_d = self.sto.StochD.Current.Value price = self.Securities[self.symbol].Price if not self.Portfolio[self.symbol].Invested and not self.Transactions.GetOpenOrders(self.symbol): if MATIC_stoch_d <= 16 and MATIC_stoch_d > 3 and self.Time > self.next_trade_time: quantity = self.CalculateOrderQuantity("MATICUSD", 1.0) self.Log("MATIC order quantity set") self.Log("MATIC buy Order @ >> {0}".format(self.Securities["MATICUSD"].Price)) self.Log("MATIC buy stoch D @ >> {0}".format(self.sto.StochD.Current.Value)) self.entryTicket = self.MarketOrder("MATICUSD", quantity) self.entryPrice = price if self.Portfolio[self.symbol].Invested: if MATIC_stoch_k >= 98 and MATIC_stoch_k < 110: self.Log("MATIC price liquidate @ >> {0}".format(self.Securities["MATICUSD"].Price)) self.Log("MATIC sell stoch @ >> {0}".format(self.sto.StochK.Current.Value)) self.Liquidate("MATICUSD") self.next_trade_time = self.Time + timedelta(hours = 5) if price > self.highestPrice: self.highestPrice = price if self.Securities["MATICUSD"].Price < (self.highestPrice * .85): self.Liquidate("MATICUSD") self.Log("MATIC stop loss triggered") def PlotIndicator(self): #self.Plot("My Indicators", "faststoch", self.sto.FastStoch.Current.Value) self.Plot("My Indicators", "MATIC stochk", self.sto.StochK.Current.Value) self.Plot("My Indicators", "MATIC stochd", self.sto.StochD.Current.Value) self.Plot("My Indicators", "MATIC Price", self.Securities["MATICUSD"].Price) #def ExitPositions(self): #self.Liquidate(self.uvxy) #self.Log(f"30 min before close on Friday: Fired at: {self.Time}") def OnBrokerageDisconnect(self) -> None: self.Debug("Brokerage connection lost") def OnBrokerageReconnect(self) -> None: self.Debug("Brokerage connection restored")