Open techguysimon opened 7 years ago
so i'm paritially there. modified streaming.py
with
try:
s = requests.Session()
url = "https://" + domain + "/v3/accounts/" + account_id + "/pricing/stream"
streaming.py runs but now bowhead:oanda_stream fails fatally with the following error:
[ErrorException] Undefined index: tick
So I guess I'm still missing something with the different APIs. From what I can see tick should be part of the output from the api call.
As you are using the v3 api of oanda and the console was made for the v1, youneed to do some tweaks on the command in order to handle the new output.
In order to fix the OandaStreamCommand I have made the following changes:
Line 26 $last_price = $ticker['bids'][0]['price'];
Line 27 $instrument = $ticker['instrument'];
Line 68: $ins = $thisline['instrument'];
Line 69: $curr[$ins] = (($thisline['bids'][0]['price'] + $thisline['asks'][0]['price'])/2);
Note that this is more a quickfix than a real long term solution because in some case $ticker['bids']
may be an empty array which would lead to an error.
Refer to http://developer.oanda.com/rest-live-v20/pricing-ep/ and http://developer.oanda.com/rest-live-v20/pricing-df/#Price for more information about the api call result
Don't forget that Joel said the project is under active development, before trying to do a real fix I would wait the part 2.
@joeldg are you planning to jump to the oanda api v3 version?
Yes, I was not aware of this, I will incorporate this into the project.. My account on Oanda is about 15 years old or so.. I started when they did. let me look into it
+1
Streaming.py still errors out because any new accounts on Oanda will be a V20 account and uses the V20 api. the code you are using calls the v1 api. Maybe another variable can be added to adjust the api endpoints based on whether the user has a V20 account or not.
Caught exception when connecting to stream HTTPSConnectionPool(host='stream-fxpractice.oanda.com', port=443): Max retries exceeded with url: /v1/prices?instruments=USD_JPY%2CEUR_USD%2CAUD_USD%2CEUR_GBP%2CUSD_CAD%2CUSD_CHF%2CUSD_MXN%2CUSD_TRY%2CUSD_CNH%2CNZD_USD&accountId=101-001-6251772-001 (Caused by <class 'httplib.BadStatusLine'>: '') Traceback (most recent call last): File "streaming.py", line 90, in
main()
File "streaming.py", line 86, in main
demo(displayHeartbeat)
File "streaming.py", line 57, in demo
if response.status_code != 200:
AttributeError: 'NoneType' object has no attribute 'status_code'
root@eaaed65955a0:/var/www/bowhead# python streaming.py
{
"code" : 1,
"message" : "Invalid or malformed argument: accountId",
"moreInfo" : "http:\/\/developer.oanda.com\/docs\/v1\/troubleshooting\/#errors"
}