Overall Statistics
Total Trades
326
Average Win
1.08%
Average Loss
-0.88%
Compounding Annual Return
-0.557%
Drawdown
11.500%
Expectancy
-0.038
Net Profit
-6.193%
Sharpe Ratio
-0.21
Probabilistic Sharpe Ratio
0.000%
Loss Rate
57%
Win Rate
43%
Profit-Loss Ratio
1.23
Alpha
-0.005
Beta
0.003
Annual Standard Deviation
0.021
Annual Variance
0
Information Ratio
-0.871
Tracking Error
0.157
Treynor Ratio
-1.663
Total Fees
$1874.82
Estimated Strategy Capacity
$13000000.00
Lowest Capacity Asset
IVE RV0PWMLXVHPH
import pandas as pd

class HyperActiveGreenHyena(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2010, 1, 1)
        self.SetCash(100000) 
        self.AddEquity("SPY", Resolution.Daily)
        self.value_symbol=self.AddEquity('IVE',Resolution.Daily).Symbol
        self.growth_symbol=self.AddEquity('IVW',Resolution.Daily).Symbol
        self.lookback=60
        self.value_bb=self.BB(self.value_symbol,self.lookback,2)
        self.growth_bb=self.BB(self.growth_symbol,self.lookback,2)
        self.SetWarmUp(timedelta(self.lookback*2))
        self.ratio_df=pd.DataFrame(columns=['value','growth','ratio'])


    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 (data.Bars.ContainsKey(self.value_symbol)) & (data.Bars.ContainsKey(self.growth_symbol)):
            new_df=pd.DataFrame({'value':data.Bars[self.value_symbol].Close, 'growth':data.Bars[self.growth_symbol].Close, 'ratio':data.Bars[self.value_symbol].Close/data.Bars[self.growth_symbol].Close}, index=[self.Time.date()])
            self.ratio_df=pd.concat([self.ratio_df.loc[:,['value','growth','ratio']],new_df],axis=0)
            self.ratio_df['ma']=self.ratio_df['ratio'].rolling(self.lookback).mean()
                
            self.Log('last value number is {}'.format(self.ratio_df['value'].iloc[-1]))
            self.Log('last growth number is {}'.format(self.ratio_df['growth'].iloc[-1]))
            self.Log('last ratio is {}'.format(self.ratio_df['ratio'].iloc[-1]))
            self.Log('last ma is {}'.format(self.ratio_df['ma'].iloc[-1]))
            
            
        if (self.ratio_df['ratio'].iloc[-1])>(self.ratio_df['ma'].iloc[-1]):
            if not self.Portfolio.Invested:
                self.SetHoldings(self.value_symbol, 0.45)
                self.SetHoldings(self.growth_symbol, -0.45)
        elif (self.ratio_df['ratio'].iloc[-1])<(self.ratio_df['ma'].iloc[-1]):
            if self.Portfolio.Invested:
                self.Liquidate()