Overall Statistics |
Total Trades 181 Average Win 1.29% Average Loss -0.28% Compounding Annual Return 14.039% Drawdown 7.600% Expectancy 1.880 Net Profit 55.021% Sharpe Ratio 0.999 Probabilistic Sharpe Ratio 44.277% Loss Rate 49% Win Rate 51% Profit-Loss Ratio 4.63 Alpha 0.103 Beta -0.018 Annual Standard Deviation 0.1 Annual Variance 0.01 Information Ratio -0.327 Tracking Error 0.191 Treynor Ratio -5.724 Total Fees $703.37 Estimated Strategy Capacity $16000000.00 Lowest Capacity Asset BIL TT1EBZ21QWKL Portfolio Turnover 4.44% |
from AlgorithmImports import * from datetime import datetime, timedelta class CustomDataWeighAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020,4, 1) self.SetEndDate(2023, 8, 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","UUP","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"] #self.AddRiskManagement(MaximumDrawdownPercentPerSecurity(0.10)) # 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']*0.95) self.SetHoldings("SSO",index_data['SSO']*0.95) self.SetHoldings("BIL",index_data['BIL']*0.95) self.SetHoldings("QLD",index_data['QLD']*0.95) self.SetHoldings("UUP",index_data['USD']*0.95) # self.SetHoldings("QQQ",index_data['QQQ']) def BeforeClose(self): # Put the code you want to execute before market close here pass class Weigh(PythonData): '''Weigh Custom Data Class''' def GetSource(self, config, date, isLiveMode): return SubscriptionDataSource("https://www.dropbox.com/scl/fi/c8fclsnt05pyxp5j6rzf0/Weightss_0.csv?rlkey=9259nmjn0xp2u6pnsui9ad1kt&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