qsforex icon indicating copy to clipboard operation
qsforex copied to clipboard

V20 Friendly

Open maxss280 opened this issue 7 years ago • 3 comments

maxss280 avatar Mar 15 '17 23:03 maxss280

Thank you

Simangaliso avatar Apr 04 '17 10:04 Simangaliso

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

edesmars avatar Dec 08 '17 08:12 edesmars

@maxss280 Saved the day, thanks mate.

geriski avatar Dec 03 '19 14:12 geriski