Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close price is not updating #2

Open
blph opened this issue Apr 23, 2021 · 1 comment
Open

Close price is not updating #2

blph opened this issue Apr 23, 2021 · 1 comment

Comments

@blph
Copy link

blph commented Apr 23, 2021

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

@jeejee19
Copy link

jeejee19 commented Aug 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants