hi. I want to see how to implement a simple Order Imbalance strategy
By Order_Imbalance I mean the ratio between bid volume and ask volume in 5 minute time windows.
And use this indicator to make decisions.
QUANTCONNECT COMMUNITY
hi. I want to see how to implement a simple Order Imbalance strategy
By Order_Imbalance I mean the ratio between bid volume and ask volume in 5 minute time windows.
And use this indicator to make decisions.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Derek Melchin
Hi LOB faridi,
We provide bid/ask data through the QuoteBars passed to the OnData method. To track the bid and ask volume over 5 minute windows, we can setup some SMA indicators of length 5 and update them with the bid/ask size each minute.
def Initialize(self): # ... self.bid_volume = SimpleMovingAverage(5) self.ask_volume = SimpleMovingAverage(5) def OnData(self, data): # ... bar = data.QuoteBars[self.symbol] self.bid_volume.Update(self.Time, bar.LastBidSize) self.ask_volume.Update(self.Time, bar.LastAskSize)
We can then create a Scheduled Event to calculate the desired ratio and place the trades.
def Initialize(self): # ... self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.Every(timedelta(minutes=5)), self.trade)
See the attached backtest for reference.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
R.mat faridi
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!