| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 418.763% Drawdown 61.500% Expectancy 0 Net Profit 356.787% Sharpe Ratio 4.209 Probabilistic Sharpe Ratio 80.315% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 3.615 Beta -0.065 Annual Standard Deviation 0.837 Annual Variance 0.701 Information Ratio 2.077 Tracking Error 1.028 Treynor Ratio -54.124 Total Fees $248.75 Estimated Strategy Capacity $92000.00 Lowest Capacity Asset ETHUSD XJ |
class BuyAndHold(QCAlgorithm):
#Rigby - 3875
def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2020, 12, 1)
self.cryptoSymbol = "ETHUSD"
#self.Portfolio.SetCash("BTC", .5, Decimal(1.1)) # Set Strategy Cash
self.SetCash(100000) # Set Strategy Cash
self.cryptoEquity = self.AddCrypto("ETHUSD", Resolution.Daily, Market.GDAX)
self.minutesBeforeMarketClose = 10
self.counter = 0
self.investmentInterval = 14
self.esppInterval = 90
#1. Update the AddEquity command to request Crypto data
#self.SetBrokerageModel (BrokerageName.GDAX, AccountType.Cash)
self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
# = self.AddCrypto("ETHUSD", Resolution.Daily, Market.GDAX)
self.cryptoEquity.SetDataNormalizationMode(DataNormalizationMode.Adjusted)
self.Schedule.On(self.DateRules.EveryDay(self.cryptoSymbol), self.TimeRules.BeforeMarketClose(self.cryptoSymbol, self.minutesBeforeMarketClose), self.dollarCostAverage)
def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
#self.Debug("Time: "+str(self.Time)+", Price: "+str(self.Portfolio["SOXL"].Price))
#This conditional will only purchase one single share
if not self.Portfolio.Invested:
#2. Place an order for 100 shares of TQQQ and print the average fill price
self.SetHoldings(self.cryptoSymbol, 1.0)
#3. Display the Quantity of TQQQ Shares You Own
#self.SetHoldings([PortfolioTarget("SOXL", 0.6), PortfolioTarget("TQQQ", 0.2)])
#self.Debug("Time: " + str(self.UtcTime) + ", Buying Power: " + str(self.Portfolio.GetBuyingPower) + ", SOXL Shares: " + str(self.Portfolio["SOXL"].Quantity) + ", TQQQ Shares: " + str(self.Portfolio["TQQQ"].Quantity) + "Cash: " + str(self.Portfolio.Cash) )
#4. Debug the AveragePrice of TQQQ
#self.Debug("Time: " + str(self.Time) + ", Average Share Price: " + str(self.Portfolio["TQQQ"].AveragePrice) + ", " + str(self.Portfolio["TQQQ"].Price))
def dollarCostAverage(self):
self.counter += 1
if self.counter % self.investmentInterval == 0:
investment = 1230
#priceOfETH = self.Portfolio["ETHUSD"].Price
#investmentConertedToETH = investment/priceOfETH
#self.Portfolio.SetCash(self.cryptoSymbol, investmentConertedToETH, Decimal(1.1))
#self.Portfolio.SetCash(self.Portfolio.Cash + investment)
if self.counter % self.esppInterval == 0:
investment = 4250
#self.Portfolio.SetCash(self.Portfolio.Cash + investment)
#self.SetHoldings(self.cryptoSymbol, 1)
self.Debug("Cash: " + str(self.Portfolio.CashBook))