Overall Statistics Total Trades0Average Win0%Average Loss0%Compounding Annual Return0%Drawdown0%Expectancy0Net Profit0%Sharpe Ratio0Loss Rate0%Win Rate0%Profit-Loss Ratio0Alpha0Beta0Annual Standard Deviation0Annual Variance0Information Ratio0Tracking Error0Treynor Ratio0Total 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'

#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)) )```