| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 8.602% Drawdown 18.800% Expectancy 0 Net Profit 25.027% Sharpe Ratio 0.561 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.206 Beta -5.431 Annual Standard Deviation 0.174 Annual Variance 0.03 Information Ratio 0.446 Tracking Error 0.174 Treynor Ratio -0.018 Total Fees $17.30 |
from QuantConnect.Indicators import *
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(2015,9,1) #Set Start Date
self.SetEndDate(2018,5,15) #Set End Date
self.SetCash(100000) #Set Strategy Cash
# Find more symbols here: http://quantconnect.com/data
self.AddEquity("PFE", Resolution.Daily)
self.Strength = self.RSI("PFE",14,MovingAverageType.Simple,Resolution.Daily)
self.SetWarmUp(20)
self.SetBenchmark("SPY")
def OnData(self, data):
rsi = self.Strength.Current.Value
current = data["PFE"].Close
#need to check when to go long
if not self.Portfolio.Invested:
if rsi < 40:
self.SetHoldings("PFE", 1)
self.current = self.Time
if self.Portfolio.Invested:
if (self.Time - self.current).days == 5:
self.Liquidate("PFE")