| Overall Statistics |
|
Total Trades 39 Average Win 9.86% Average Loss -4.22% Compounding Annual Return 27.928% Drawdown 27.200% Expectancy 1.634 Net Profit 278.833% Sharpe Ratio 1.254 Probabilistic Sharpe Ratio 66.295% Loss Rate 21% Win Rate 79% Profit-Loss Ratio 2.34 Alpha 0.199 Beta 0.01 Annual Standard Deviation 0.16 Annual Variance 0.026 Information Ratio 0.346 Tracking Error 0.221 Treynor Ratio 19.367 Total Fees $146487.61 Estimated Strategy Capacity $410000.00 Lowest Capacity Asset BTCUSD E3 |
# 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 = ['BTCUSD']
#################################
########### Brokerage ------------------
self.SetBrokerageModel(BrokerageName.AlphaStreams)
for symbol in self.symbols:
self.AddCrypto(symbol, Resolution.Hour, Market.Bitfinex)
def OnData(self, data):
########## # 25 - 2
if self.Time.day >= 25 and self.Time.day <= 27 and not self.Securities["btcusd"].Invested :# 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("BTCUSD", self.Portfolio.CashBook["USD"].Amount / self.Securities["BTCUSD"].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["BTCUSD"].Price)