Shile, you're a legend thank you now I understand...
The doc below is slightly different but both seems to work. The algorithm reference usees data.Bars. What's the difference there?
https://www.quantconnect.com/docs/algorithm-reference/charting
self.Plot('Close', 'SPY', data[self.spy].Close)
self.Plot('Trade Plot', 'Price', data.Bars["SPY"].Close)
My understanding is data.Bars gives the trade bar and data.QuoteBars gives the quote bar. Tried to use quote bar below but didn't work. Any hints please?
from MyRsiAlphaModel import MyRsiAlphaModel
class ParticleQuantumCompensator(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 3, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddAlpha(MyRsiAlphaModel())
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
self.ibm = self.AddEquity('IBM', Resolution.Daily).Symbol
def OnData(self, data):
if self.ibm in data:
self.Plot('Close', 'IBM', data.QuoteBars["IBM"].Close)
def OnOrderEvent(self, orderEvent):
if orderEvent.Direction == OrderDirection.Buy:
self.Plot('Price', 'Buy', orderEvent.FillPrice)
elif orderEvent.Direction == OrderDirection.Sell:
self.Plot('Price', 'Sell', orderEvent.FillPrice)