Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
2.173
Tracking Error
0.457
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
class WellDressedTanChimpanzee(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 5, 1)
        self.SetEndDate(2021, 5, 4)
        self.SetCash(10000)  # Set Strategy Cash
        self.SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Cash)
        self.btc = self.AddCrypto('BTCUSD', Resolution.Hour, Market.Bitfinex)
        
        self.ema1 = self.EMA(self.btc.Symbol, 1, Resolution.Hour)
        self.slow1 = self.EMA(self.btc.Symbol, 200, Resolution.Hour)
        self.fast1 = self.EMA(self.btc.Symbol, 21, Resolution.Hour)
        self.SetWarmUp(timedelta(200), Resolution.Hour)
        
        # Plot Chart 
        stockPlot = Chart('Trade Plot')
        stockPlot.AddSeries(Series('Price', SeriesType.Candle, 0))
        stockPlot.AddSeries(Series('Slow', SeriesType.Line, 0))
        stockPlot.AddSeries(Series('Fast', SeriesType.Line, 0))
        self.AddChart(stockPlot)
        
        self.Debug('CHIMPANZEE INITIALIZED')
        
    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
        '''
        if self.slow1.IsReady == True:
            self.Debug('slow is ready')
        if self.fast1.IsReady == True:
            self.Debug('fast is ready')
        
        if not self.slow1.IsReady and not self.fast1.IsReady:
            return 
        
        if self.Portfolio.CashBook['BTC'].Amount == 0: 
            # Identify bullish trend
            if self.slow1 > self.fast1: 
                # Identify if price has crossed ema21 
                if self.ema1 > self.slow1:
                    # buy 
                    amount = (0.5 * self.Portfolio.CashBook['USD'].Amount) / self.btc.Price
                    self.Buy('BTCUSD', amount)
                    
        if self.Portfolio.CashBook['BTC'].Amount > 0:
            if self.ema1 <= self.slow1:    
                self.Liquidate()
                
        self.Plot('Trade Plot', 'Price', data.Bars["BTCUSD"].Close)
        self.Plot('Trade Plot', 'Slow', self.slow1.Current.Value)
        self.Plot('Trade Plot', 'Fast', self.fast1.Current.Value)