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
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
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):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

        self.SetStartDate(2018,1, 1)  #Set Start Date
        #self.SetEndDate(2018,4,10)    #Set End Date
        self.SetCash(10000)           #Set Strategy Cash
        self.sym = 'SPY'
        self.SymData = self.AddEquity(self.sym, Resolution.Daily).Symbol

        #define PPO
        self.qcPPO = self.PPO(self.SymData, 12,26,9)
        # define my own EMAs for PPO verification
        self.ppoema12=0
        self.ppoema26=0
        self.ppoema9=float(0.0)
        self.ppo=0

        self.Debug("end init")
        self.Log("Fields-> date, Close, QC_PPO, QC_PPO_signal, my_EMA12, my_EMA26, my_PPO, my_PPO_signal")

    def OnData(self, slice):
        bar = slice[self.sym]        
        barClose = float(bar.Close)
        if self.ppoema12 == 0:
            # initialize on first bar
            self.ppoema12 = barClose
            self.ppoema26 = barClose
        else:
            self.ppoema12= (barClose - self.ppoema12) * float(0.15385) + self.ppoema12     # sf=.15385 = 1/(1+12)
            self.ppoema26= (barClose - self.ppoema26) * float(.07407) + self.ppoema26     # sf=.07407 = 1/(1+26)
        self.ppo = (self.ppoema12-self.ppoema26)/self.ppoema26*100
        self.ppoema9= (self.ppo - self.ppoema9) * float(.2) + self.ppoema9  # sf=0.2 = 1/(1+9)

        if str(self.Time) > '2018-04-01':
            self.Log(str(bar.Time) +'  '+str(round(bar.Close,2)) +'    '+ str(round(self.qcPPO.Current.Value,4)) +'  '+ str(round(self.qcPPO.Signal.Current.Value,4)) +'  '+ str(round(self.ppoema12,4)) +'  '+ str(round(self.ppoema26,4)) +'  '+ str(round(self.ppo,4)) +'  '+ str(round(self.ppoema9,4)) )