Overall Statistics |
Total Trades 649 Average Win 0.79% Average Loss -0.40% Compounding Annual Return 10.652% Drawdown 10.200% Expectancy 0.613 Net Profit 117.808% Sharpe Ratio 0.783 Probabilistic Sharpe Ratio 18.383% Loss Rate 45% Win Rate 55% Profit-Loss Ratio 1.95 Alpha 0.067 Beta 0.104 Annual Standard Deviation 0.099 Annual Variance 0.01 Information Ratio -0.124 Tracking Error 0.17 Treynor Ratio 0.745 Total Fees $3198.59 Estimated Strategy Capacity $12000000.00 Lowest Capacity Asset BIL TT1EBZ21QWKL Portfolio Turnover 6.50% |
from AlgorithmImports import * from datetime import datetime, timedelta class CustomDataWeighAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2016,1, 1) # self.SetEndDate(2023, 2, 1) self.SetCash(100000) # Define the symbol and "type" of our generic data: self.AddData(Weigh, "Weigh") self.symbols = "SPY", "SPXL", "UVXY", "SSO","BIL","TQQQ","QLD","USD","SOXL" # 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}, SPY: {index_data['SPY']}") self.Debug(f"Data Time: {index_data.Time}, SPXL: {index_data['SPXL']}") self.Debug(f"Data Time: {index_data.Time}, UVXY: {index_data['UVXY']}") self.Debug(f"Data Time: {index_data.Time}, SSO: {index_data['SSO']}") self.Debug(f"Data Time: {index_data.Time}, BIL: {index_data['BIL']}") self.Debug(f"Data Time: {index_data.Time}, TQQQ: {index_data['TQQQ']}") self.Debug(f"Data Time: {index_data.Time}, QLD: {index_data['QLD']}") self.Debug(f"Data Time: {index_data.Time}, USD: {index_data['USD']}") self.Debug(f"Data Time: {index_data.Time}, SOXL: {index_data['SOXL']}") #self.SetHoldings("MDY",index_data['QQQ']) self.SetHoldings("UVXY",index_data['UVXY']) self.SetHoldings("SSO",index_data['SSO']) self.SetHoldings("BIL",index_data['BIL']) self.SetHoldings("QLD",index_data['QLD']) self.SetHoldings("USD",index_data['USD']) # 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/x0yq2s83yvcwuy1m7kay7/Weightss_0.csv?rlkey=i2jdzdb1g9xhuradamnf150wg&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["SPY"] = float(data[1]) index["SPXL"] = float(data[2]) index["UVXY"] = float(data[3]) index["SSO"] = float(data[4]) index["BIL"] = float(data[5]) index["TQQQ"] = float(data[6]) index["QLD"] = float(data[7]) index["USD"] = float(data[8]) index["SOXL"] = float(data[9]) # index["QQQ"] = float(data[5]) except ValueError as e: self.Debug(f"Errore nella lettura dei dati: {str(e)}") return None return index