InteractiveBrokersPythonBot icon indicating copy to clipboard operation
InteractiveBrokersPythonBot copied to clipboard

Close price is not updating

Open blph opened this issue 4 years ago • 1 comments

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):

blph avatar Apr 23 '21 17:04 blph

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

jeejee19 avatar Aug 25 '23 14:08 jeejee19