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

V20 Friendly #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

V20 Friendly #59

wants to merge 1 commit into from

Conversation

maxss280
Copy link

No description provided.

@maxss280 maxss280 mentioned this pull request Mar 15, 2017
@Simangaliso
Copy link

Thank you

@edesmars
Copy link

edesmars commented Dec 8, 2017

Thanks a lot for this PR. :)
I just tested it on my local and found out that in file 'data/streaming.py' you select 'msg["bids"][1]["price"]". While testing on a practice account, I had to change that to msg["bids"][0]["price"] to make it work.

From Oanda doc, it seems like it only send 1 price for bid and ask at most (end price for the current window of 250ms) and that the array might be empty if there is no liquidity for the bid or ask. So I would suggest to check the length of the array before trying to access it. What about changing it to something around these lines:

                   bid = -100
                    ask = -100
                    if len(msg["bids"]) > 0:
                        bid = Decimal(str(msg["bids"][0]["price"])).quantize(
                            Decimal("0.00001")
                        )
                    if len(msg["asks"]) > 0:
                        ask = Decimal(str(msg["asks"][0]["price"])).quantize(
                            Decimal("0.00001")
                        )
                    # if no liquidity on ask or bid we don't proceed that event
                    if ask == -100 or bid == -100:
                        return

PS: I'm not a python expert so the code might not be best practice ;)

@geriski
Copy link

geriski commented Dec 3, 2019

@maxss280 Saved the day, thanks mate.

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

Successfully merging this pull request may close these issues.

4 participants