Overall Statistics
Total Trades
12
Average Win
1.22%
Average Loss
-0.38%
Compounding Annual Return
90.947%
Drawdown
2.800%
Expectancy
0.394
Net Profit
0.890%
Sharpe Ratio
2.202
Probabilistic Sharpe Ratio
56.182%
Loss Rate
67%
Win Rate
33%
Profit-Loss Ratio
3.18
Alpha
1.481
Beta
-4.387
Annual Standard Deviation
0.175
Annual Variance
0.031
Information Ratio
0.668
Tracking Error
0.203
Treynor Ratio
-0.088
Total Fees
$0.72
import numpy as np
import decimal as d
from datetime import timedelta, datetime

class FirstProject(QCAlgorithm):

    def Initialize(self):
    
        self.SetCash(100)
        self.SetStartDate(2019, 12, 23)
        self.equity = 'AMD'
        self.AddEquity(self.equity, Resolution.Minute).Symbol
        self.SetWarmUp(timedelta(minutes=1))
        self.Securities[self.equity].FeeModel = ConstantFeeModel(.06)
        self.EMAFAST = self.EMA(self.equity, 20, Resolution.Minute)
        self.EMASLOW = self.EMA(self.equity, 200, Resolution.Minute)
        
        #Consolidate Heiken Ashi
        fiveMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=5))
        fiveMinuteConsolidator.DataConsolidated += self.OnDataConsolidated
        self.SubscriptionManager.AddConsolidator(self.equity, fiveMinuteConsolidator)                                                                                          
        self.RegisterIndicator(self.equity,self.EMAFAST,  fiveMinuteConsolidator)
        self.RegisterIndicator(self.equity,self.EMASLOW,  fiveMinuteConsolidator)


        
    def OnDataConsolidated(self, sender, data):
        holdings = self.Portfolio[self.equity].Quantity
        
        EMA_current = round(self.EMAFAST.Current.Value, 3), round(self.EMASLOW.Current.Value, 3)
        self.Log(str(self.Time)+" - EMA fast & slow: "+ str(EMA_current) + " Symbol price: " + str(self.Securities["AMD"].Close))
        
        if self.Portfolio[self.equity].Quantity == 0 and self.EMASLOW.Current.Value < self.EMAFAST.Current.Value : ####
           self.MarketOrder(self.equity, 2)
           
        if self.Portfolio[self.equity].Quantity > 0 and self.EMAFAST.Current.Value < self.EMASLOW.Current.Value : ####
           self.MarketOrder(self.equity, -2)