Overall Statistics |
Total Trades 23 Average Win 0% Average Loss 0% Compounding Annual Return 8.882% Drawdown 0.100% Expectancy 0 Net Profit 0.062% Sharpe Ratio 12.971 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.03 Beta 2.363 Annual Standard Deviation 0.004 Annual Variance 0 Information Ratio 11.01 Tracking Error 0.004 Treynor Ratio 0.022 Total Fees $23.00 |
import datetime class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2014, 10, 15) #Set Start Date self.SetEndDate(2014, 10, 18) #Set End Date self.SetCash(100000) #Set Strategy Cash self.AddEquity("SPY", Resolution.Minute) self.openLimitOrders = [] def OnData(self, data): open_orders = self.Transactions.GetOpenOrders("SPY") if len(open_orders) == 0: limitOrderTicket = self.LimitOrder("SPY", 1, float(self.Securities["SPY"].Price)*0.982) self.limitOrderSubmitTime = self.Time self.openLimitOrders.append(limitOrderTicket) if len(self.openLimitOrders) == 1 and self.openLimitOrders[0].Status == OrderStatus.Submitted: # if over 15 minutes since the limit order was submitted if self.Time > self.limitOrderSubmitTime + datetime.timedelta(minutes=15): self.Transactions.CancelOpenOrders("SPY") # cancle the limit order self.MarketOrder("SPY", 1) # sumbit the market order self.openLimitOrders = []