| Overall Statistics |
|
Total Trades 209 Average Win 0% Average Loss -0.07% Compounding Annual Return -45.459% Drawdown 5.000% Expectancy -1 Net Profit -4.966% Sharpe Ratio -3.082 Probabilistic Sharpe Ratio 0.015% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.317 Beta 0.091 Annual Standard Deviation 0.084 Annual Variance 0.007 Information Ratio -5.793 Tracking Error 0.152 Treynor Ratio -2.849 Total Fees $212.55 Estimated Strategy Capacity $2000.00 Lowest Capacity Asset BTC TLQHZ0DZBGPX |
import numpy as np
### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class BasicTemplateAlgorithm(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
def Initialize(self):
self.SetStartDate(2021,12,1) #Set Start Date
self.SetEndDate(2021,12,31) #Set End Date
self.SetCash(6000) #Set Strategy Cash
self.AddEquity("BTC", Resolution.Minute)
#self.SetBrokerageModel(BrokerageName.Bitfinex)
self.rsi = self.RSI("BTC", 7)
self.BuyIn = 0.0
CurrentPrice = self.Securities["BTC"].Price
self.BuyIn = CurrentPrice
take_profit = 0.2
def OnData(self, data):
if not self.rsi.IsReady:
return
if self.rsi.Current.Value < 30 and self.Portfolio["BTC"].Invested <= 0:
self.MarketOrder("BTC", 10)
self.Debug("BO order was placed")
if self.rsi.Current.Value < 20:
self.MarketOrder("BTC", 20)
self.Debug("SO order was placed")
if self.rsi.Current.Value > 40:
self.Liquidate()
#if CurrentPrice > self.BuyIn*(1 + take_profit):
#self.SetHoldings("AAPL", 0) # A market sell
#return
def OnEndOfDay(self):
self.Plot("Indicators","RSI", self.rsi.Current.Value)