Close price is not updating
Issue
The close price does not change each time a new bar is generated.
Cause
for bar in self.bars:
closes.append(bar.close)
In the for loop above "bar" should be changed to something else so that it's not overwritting "bar" from:
def on_bar_update(self, reqId, bar, realtime):
this solution helped me with the close price to update. I only suspect that this is updating the last close price, and the last close price of in close_array, but not the preceding close prices from where the SMA is calculated? See below example:
Last 5 closes: 454 17.64 455 17.67 456 17.52 457 17.48 458 16.95 dtype: float64 SMA : 17.452 Last 5 closes: 454 17.64 455 17.67 456 17.52 457 17.48 458 16.98 dtype: float64 SMA : 17.458