Overall Statistics |
Total Trades 13 Average Win 0.03% Average Loss -0.02% Compounding Annual Return 20.601% Drawdown 44.300% Expectancy 1.118 Net Profit 75.920% Sharpe Ratio 0.811 Loss Rate 14% Win Rate 86% Profit-Loss Ratio 1.47 Alpha 0.086 Beta 0.869 Annual Standard Deviation 0.279 Annual Variance 0.078 Information Ratio 0.268 Tracking Error 0.241 Treynor Ratio 0.261 Total Fees $33.81 |
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): def Initialize(self): self.SetStartDate(2010,10, 7) #Set Start Date self.SetEndDate(2013,10,11) #Set End Date self.SetCash(100000) #Set Strategy Cash self.AddEquity("SPY", Resolution.Minute) self.AddEquity("AAPL", Resolution.Minute) self._EMA = self.EMA("SPY", 30, Resolution.Minute) self.SetBenchmark("SPY") self.position = None def OnData(self, data): if not self._EMA.IsReady: return if self._EMA.Current.Value >= self.Portfolio["SPY"].Price and not self.Portfolio.Invested: self.SetHoldings("SPY", 1) self.position == "SPY" else: self.Liquidate("SPY") self.SetHoldings("AAPL", 1) self.position == "AAPL"