Overall Statistics |
Total Trades 119 Average Win 1.86% Average Loss -1.51% Compounding Annual Return 6.457% Drawdown 13.800% Expectancy 0.399 Net Profit 40.268% Sharpe Ratio 0.636 Probabilistic Sharpe Ratio 14.358% Loss Rate 37% Win Rate 63% Profit-Loss Ratio 1.23 Alpha 0.018 Beta 0.236 Annual Standard Deviation 0.074 Annual Variance 0.005 Information Ratio -0.572 Tracking Error 0.134 Treynor Ratio 0.199 Total Fees $2600.29 Estimated Strategy Capacity $150000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# Hold for 1 month and then rebalance. import pandas as pd from datetime import datetime class AssetClassMomentumAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2016, 1, 1) self.SetCash(1000000) self.SetCash("BTC",0) self.symbols = ['SPY'] ################################# ########### Brokerage ------------------ self.SetBrokerageModel(BrokerageName.AlphaStreams) for symbol in self.symbols: self.AddEquity(symbol, Resolution.Hour) def OnData(self, data): ########## # 25 - 2 if self.Time.day >= 25 and self.Time.day <= 27 and not self.Portfolio.Invested: #self.Portfolio.CashBook["BTC"].Amount == 0 : # usdTotal = self.Portfolio.CashBook ["USD"]. Amount # limitPrice = round (self.Securities ["BTCUSD"]. Price * 0.99, 2) # # use only half of our total USD # quantity = usdTotal / limitPrice # self.DefaultOrderProperties.TimeInForce = TimeInForce.Day # self.LimitOrder("BTCUSD", quantity, limitPrice) self.MarketOrder("SPY", self.Portfolio.CashBook["USD"].Amount / self.Securities["SPY"].Price) # self.SetHoldings("BTCUSD",1) # if self.Time.day >= 28 or self.Securities["btcusd"].Invested : if self.Time.day >= 3 and self.Time.day <= 5 and self.Portfolio.Invested: self.Liquidate() def OnEndOfDay(self, symbol): self.Plot('Strategy Q', 'Q',self.Portfolio.CashBook["USD"].Amount / self.Securities["SPY"].Price)