Overall Statistics |
Total Trades 2 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 $19.87 Estimated Strategy Capacity $10000.00 Lowest Capacity Asset MATICUSD 2S7 |
#region imports from AlgorithmImports import * #endregion class MATICana_USD(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 10, 20) # Set Start Date self.SetEndDate(2022, 10, 25) #Set End Date self.SetCash(10000) # 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.highestPrice = 0 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): if data.QuoteBars.ContainsKey(self.symbol): self.sto.Update(data.QuoteBars[self.symbol]) if self.sto.IsReady: indicator_value = self.sto.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 <= 15 and MATIC_stoch_d > 3 and self.Time > self.next_trade_time: quantity = self.CalculateOrderQuantity("MATICUSD", 1) self.entryTicket = self.MarketOrder("MATICUSD", quantity) self.entryPrice = price if self.Portfolio[self.symbol].Invested: if MATIC_stoch_k >= 96 and MATIC_stoch_k < 105: quantity = self.CalculateOrderQuantity(self.symbol, 0) self.Quit(f"Liquidation quantity: {quantity}") self.Liquidate("MATICUSD") self.next_trade_time = self.Time + timedelta(hours = 4) if price > self.highestPrice: self.highestPrice = price if self.Securities["MATICUSD"].Price < (self.highestPrice * .95): self.Liquidate("MATICUSD") self.next_trade_time = self.Time + timedelta(hours = 4)