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 math import numpy as np import pandas as pd import statistics from datetime import datetime, timedelta class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetCash(100000) self.SetStartDate(2015, 8, 1) self.SetEndDate(2015, 9, 30) # Add securities and get the data self.equities = ["SPY","IWM"] self.roc = [] self.stdev = [] for s in self.equities: self.AddEquity(s, Resolution.Minute) self.roc.append(self.ROCP(s, 1, Resolution.Daily)) self.stdev.append(self.STD(s, 20, Resolution.Daily)) # Schedule trades at 10am self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 5), Action(self.Rebalance)) # Days to warm up the indicators self.SetWarmup(timedelta(20)) def OnData(self, slice): pass def Rebalance(self): prices = self.History(self.equities, 21, Resolution.Daily)['close'] roc = [(prices[i]-prices[i-1])/prices[i] for i in range(0,len(prices))] self.Log(str(roc)) #self.Log("{0} {1} stdev: {2} ".format(str(self.Time), self.equities[i], str(roc)))