Overall Statistics |
Total Trades 291 Average Win 0.28% Average Loss -0.14% Compounding Annual Return 9.590% Drawdown 2.900% Expectancy 0.270 Net Profit 5.462% Sharpe Ratio 1.068 Loss Rate 58% Win Rate 42% Profit-Loss Ratio 2.02 Alpha 0.067 Beta 0.041 Annual Standard Deviation 0.073 Annual Variance 0.005 Information Ratio -1.608 Tracking Error 0.127 Treynor Ratio 1.929 Total Fees $291.00 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Securities import * from QuantConnect.Data.Market import * from QuantConnect.Orders import * from datetime import datetime ### <summary> ### Demonstration of the Market On Close order for US Equities. ### </summary> ### <meta name="tag" content="trading and orders" /> ### <meta name="tag" content="placing orders" /> class MarketOnOpenOnCloseAlgorithm(QCAlgorithm): 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(2019,1,1) #Set Start Date self.SetEndDate(2019,7,31) #Set End Date self.SetCash(100000) #Set Strategy Cash # Find more symbols here: http://quantconnect.com/data self.equity = self.AddEquity("ILMN", Resolution.Second, fillDataForward = True, extendedMarketHours = True) self.__submittedMarketOnCloseToday = False self.__last = datetime.min def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.''' if self.Time.date() != self.__last.date(): # each morning submit a market on open order self.__submittedMarketOnCloseToday = False self.MarketOnOpenOrder("ILMN", 100) self.__last = self.Time if not self.__submittedMarketOnCloseToday and self.equity.Exchange.ExchangeOpen: # once the exchange opens submit a market on close order self.__submittedMarketOnCloseToday = True self.MarketOnCloseOrder("ILMN", -100) def OnOrderEvent(self, fill): order = self.Transactions.GetOrderById(fill.OrderId) self.Log("{0} - {1}:: {2}".format(self.Time, order.Type, fill))