qsforex
qsforex copied to clipboard
V20 Friendly
Thank you
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 ;)
@maxss280 Saved the day, thanks mate.