Overall Statistics |
Total Trades 1300 Average Win 0.58% Average Loss -0.51% Compounding Annual Return 15.887% Drawdown 15.000% Expectancy 0.639 Net Profit 645.817% Sharpe Ratio 1.015 Probabilistic Sharpe Ratio 43.257% Loss Rate 24% Win Rate 76% Profit-Loss Ratio 1.15 Alpha 0.101 Beta 0.135 Annual Standard Deviation 0.113 Annual Variance 0.013 Information Ratio 0.088 Tracking Error 0.167 Treynor Ratio 0.849 Total Fees $7186.52 Estimated Strategy Capacity $810000.00 Lowest Capacity Asset SCHC UJANHQ8376N9 Portfolio Turnover 4.75% |
from AlgorithmImports import * from datetime import datetime, timedelta class CustomDataWeighAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2010,2, 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", "SPY", "SCHC","VGLT", "TLT", "UUP" # 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}, SPY: {index_data['SPY']}") self.Debug(f"Data Time: {index_data.Time}, VINEX: {index_data['VINEX']}") self.Debug(f"Data Time: {index_data.Time}, VUSTX: {index_data['VUSTX']}") self.Debug(f"Data Time: {index_data.Time}, TLT: {index_data['TLT']}") self.Debug(f"Data Time: {index_data.Time}, UUP: {index_data['UUP']}") self.SetHoldings("QQQ",index_data['QQQ']*0.97) self.SetHoldings("SPY",index_data['SPY']*0.97) self.SetHoldings("SCHC",index_data['VINEX']*0.97) self.SetHoldings("VGLT",index_data['VUSTX']*0.97) self.SetHoldings("TLT",index_data['TLT']*0.97) self.SetHoldings("UUP",index_data['UUP']*0.97) class Weigh(PythonData): '''Weigh Custom Data Class''' def GetSource(self, config, date, isLiveMode): return SubscriptionDataSource("https://www.dropbox.com/scl/fi/23pzvp0fiupylx4o8gm2i/TAADualMomTotTransactionsv1_ALL.csv?rlkey=jeuxksndfzwjqyqua33ccr643&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[2]) index["SPY"] = float(data[3]) index["VINEX"] = float(data[6]) index["VUSTX"] = float(data[7]) index["TLT"] = float(data[8]) index["UUP"] = float(data[9]) except ValueError as e: self.Debug(f"Errore nella lettura dei dati: {str(e)}") return None return index