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 Probabilistic 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.746 Tracking Error 0.228 Treynor Ratio 0 Total Fees $0.00 |
import numpy as np from clr import AddReference AddReference("System") AddReference("NodaTime") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Indicators") AddReference("QuantConnect.Common") from datetime import datetime, timedelta from System import * from NodaTime import DateTimeZone from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Brokerages import * from QuantConnect.Data.Market import * from datetime import timedelta class DataConsolidationAlgorithm(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.SetCash(30000) self.StopRisk = 1 if self.Portfolio.TotalUnrealizedProfit > 599.99: #take profit self.Liquidate() self.SetStartDate(2018,1,1) #Set Start Date self.SetEndDate(2021,1,1) #Set End Date # Find more symbols here: http://quantconnect.com/data self.AddEquity("BOXL", Resolution.Minute) self.ema = self.EMA("BOXL", 30, MovingAverageType.Simple, Resolution.Minute) self.vwap = self.VWAP("BOXL", 30, Resolution.Minute) # define our 5 minute trade bar consolidator. we can # access the 5 minute bar from the DataConsolidated events fiveMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=5)) # attach our event handler. The event handler is a function that will # be called each time we produce a new consolidated piece of data. # this call adds our 5-minute consolidator to # the manager to receive updates from the engine self.SubscriptionManager.AddConsolidator("BOXL", fiveMinuteConsolidator) def fiveMinuteBarHandler(self, sender, bar): '''This is our event handler for our 5-minute trade bar defined above in Initialize(). So each time the consolidator produces a new 5-minute bar, this function will be called automatically. The sender parameter will be the instance of the IDataConsolidator that invoked the event ''' self.Debug(str(self.Time) + " " + str(bar)) def OnData(self, data): if not self.ema.IsReady: return if not self.vawap.IsReady: return if self.ema > self.vwap: self.MarketOrder("BOXL",1) if self.ema < self.vwap: self.MarketOrder("BOXL",-1)