Overall Statistics |
Total Orders 15 Average Win 13.52% Average Loss -7.10% Compounding Annual Return 45.836% Drawdown 28.300% Expectancy 1.541 Start Equity 100000 End Equity 196206.52 Net Profit 96.207% Sharpe Ratio 0.989 Sortino Ratio 1.243 Probabilistic Sharpe Ratio 49.030% Loss Rate 12% Win Rate 88% Profit-Loss Ratio 1.90 Alpha 0.28 Beta 0.293 Annual Standard Deviation 0.315 Annual Variance 0.099 Information Ratio 0.623 Tracking Error 0.324 Treynor Ratio 1.064 Total Fees $0.00 Estimated Strategy Capacity $190000.00 Lowest Capacity Asset BTCUSD E3 Portfolio Turnover 1.53% |
# region imports from AlgorithmImports import * # endregion class TrumpFactorOnBitcoinPerformanceAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2022, 11, 1) self.set_end_date(2024, 8, 13) # These start/end dates align with the data file self.set_cash(100_000) self.add_crypto('BTCUSD', market=Market.BITFINEX) self._election_lead = self.add_data(TrumpLead, 'TrumpLead').symbol def on_data(self, data): if self._election_lead in data: self.set_holdings('BTCUSD', int(data[self._election_lead].value > 0)) class TrumpLead(PythonData): def get_source(self, config, date, is_live_mode): # Original source: https://www.realclearpolling.com/polls/president/general/2024/trump-vs-harris return SubscriptionDataSource("https://www.dropbox.com/scl/fi/f87o5azouo09sqecpebw2/parsed_election_data.csv?rlkey=abuch8e53oi8jlgmnt0s58jbj&st=05wgpd6s&dl=1", SubscriptionTransportMedium.REMOTE_FILE) def reader(self, config, line, date, is_live_mode): if not line[0].isdigit(): return None lead = TrumpLead() lead.symbol = config.symbol data = line.split(',') lead.end_time = datetime.fromisoformat(data[0]) lead.value = float(data[2]) - float(data[1]) - float(data[3]) # Lead = Trump - Harris - Biden return lead