Overall Statistics |
Total Trades 1399 Average Win 0.09% Average Loss -0.07% Compounding Annual Return 21.486% Drawdown 13.600% Expectancy 1.081 Net Profit 88.919% Sharpe Ratio 1.157 Probabilistic Sharpe Ratio 56.474% Loss Rate 11% Win Rate 89% Profit-Loss Ratio 1.33 Alpha 0.089 Beta 0.594 Annual Standard Deviation 0.133 Annual Variance 0.018 Information Ratio 0.39 Tracking Error 0.116 Treynor Ratio 0.259 Total Fees $1436.10 Estimated Strategy Capacity $230000.00 Lowest Capacity Asset DBMF X4BEVPB5F3HH Portfolio Turnover 0.75% |
from AlgorithmImports import * from datetime import datetime, timedelta class CustomDataWeighAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020,6, 1) # self.SetEndDate(2023, 2, 1) self.SetCash(100000) # Define the symbol and "type" of our generic data: self.AddData(Weigh, "Weigh") self.symbols = "QQQ", "JEPI", "DBMF", "TQQQ" # Inizializza un dizionario per memorizzare le allocazioni iniziali degli asset #self.AddRiskManagement(MaximumDrawdownPercentPerSecurity(0.10)) # Aggiungi tutti gli asset con risoluzione giornaliera (daily) for symbol in self.symbols: self.AddEquity(symbol, Resolution.Daily) def OnData(self, data): if not data.ContainsKey("Weigh"): return index_data = data["Weigh"] # Stampa i valori degli indici self.Debug(f"Data Time: {index_data.Time}, QQQ: {index_data['QQQ']}") self.Debug(f"Data Time: {index_data.Time}, JEPI: {index_data['JEPI']}") self.Debug(f"Data Time: {index_data.Time}, DBMF: {index_data['DBMF']}") self.Debug(f"Data Time: {index_data.Time}, TQQQ: {index_data['TQQQ']}") #self.SetHoldings("MDY",index_data['QQQ']) self.SetHoldings("JEPI",index_data['JEPI']) self.SetHoldings("DBMF",index_data['DBMF']) self.SetHoldings("TQQQ",index_data['TQQQ']) # self.SetHoldings("QQQ",index_data['QQQ']) class Weigh(PythonData): '''Weigh Custom Data Class''' def GetSource(self, config, date, isLiveMode): return SubscriptionDataSource("https://www.dropbox.com/scl/fi/f5adhujnq46chtec27srp/weights_2.csv?rlkey=wogufd7t32ozbuozr7d4fgrzc&dl=1", SubscriptionTransportMedium.RemoteFile) def Reader(self, config, line, date, isLiveMode): if not (line.strip() and line[0].isdigit()): return None index = Weigh() index.Symbol = config.Symbol try: # Example File Format: data = line.split(',') index.Time = datetime.strptime(data[0], "%Y-%m-%d") index.EndTime = index.Time + timedelta(days=1) index.Value = data[4] index["QQQ"] = float(data[1]) index["JEPI"] = float(data[2]) index["DBMF"] = float(data[3]) index["TQQQ"] = float(data[4]) # index["QQQ"] = float(data[5]) except ValueError as e: self.Debug(f"Errore nella lettura dei dati: {str(e)}") return None return index