Closed houmie closed 7 years ago
Hello Houman, did you check my post? http://jon.io/placing-your-first-forex-trade-with-python.html I think I say something there.
Cheers
Hello Jon,
Yes I'm following your blog. It's amazing by the way. Very excited about the series and what else is to come. I just found it. After login --> Manage Funds --> View. The dashboard of them isn't very clear at first. :) Thanks
One last comment: Even after the right account id I get an internal server error. Vert strange:
------ System online ------- 2016-11-23 02:41:51.830574
Buy at 1.06296
Traceback (most recent call last):
File "/Users/houmie/projects/forex_algotrading/post3/runner.py", line 30, in <module>
main()
File "/Users/houmie/projects/forex_algotrading/post3/runner.py", line 24, in main
type='market')
File "/Users/houmie/projects/forex_algotrading/post3/oandapy.py", line 73, in create_order
return self.request(endpoint, "POST", params=params)
File "/Users/houmie/projects/forex_algotrading/post3/oandapy.py", line 262, in request
raise OandaError(content)
oandapy.OandaError: OANDA API returned error code 0 (INTERNAL_SERVER_ERROR)
Thank you for your kind words! What happened is that Oanda upgraded their API, released a new version and all new accounts go to that version. I need to update my post 💃
Ah that makes sense. Well I have now removed your oandapy and installed it via pip install git+https://github.com/oanda/oandapy.git
Unfortunately, it is still crashing. I was hoping they would have fixed the wrapper by now. This means effectively either we bypass the wrapper and do our own requests, or we make pull requests to the wrapper project. :)
Ha I see! I plan to release something in the next couple of days. Please keep bugging me!
Hey Jon,
No worries, I keep bugging you. ;) I have some good news though.
There is a version 2 of that library: https://github.com/hootnot/oanda-api-v20 and there is also version 2.0 from Oanda directly: https://github.com/oanda/v20-python
I tested the former and it works, but the classes are very different than the old version. Hence it requires rewriting most of your sample code.
import oandapyV20
import oandapyV20.endpoints.orders as orders
from oandapyV20.contrib.requests import MarketOrderRequest
api = oandapyV20.API(environment="practice", access_token=OANDA_ACCESS_TOKEN)
r = orders.OrderCreate(
OANDA_ACCOUNT_ID,
data=MarketOrderRequest(instrument="EUR_USD", units=1000).data)
rv = api.request(r)
print json.dumps(rv, indent=2)
Is there anyway I could help you?
Oh nice! You can make a pull request and update the code :D
Hey @jonromero,
Sure, I really would like to help out. But it's not easy for me as I'm still learning.
api = oandapyV20.API(environment="practice", access_token=OANDA_ACCESS_TOKEN)
params = {'count': 2, 'price': 'B', 'granularity': 'M5'}
r = instruments.InstrumentsCandles(instrument="EUR_USD", params=params)
response = api.request(r)
prices = response.get("candles")
As you can see V2 of the wrapper has changed dramatically. Hence your instructions and teachings in your blog series are now outdated and unusable. :(
{u'volume': 113, u'bid': {u'h': u'1.06162', u'c': u'1.06149', u'l': u'1.06123', u'o': u'1.06135'}, u'complete': False, u'time': u'2016-12-01T09:20:00.000000000Z'}
As you can see the bid price is now including 4 different prices, which isn't clear at all.
That makes it very difficult following your blog. What a shame...
No worries! A new updated version (and post) is coming up!
Jon,
I have some great news. In my desperation, I contacted OANDA tech support. They can create a Sub-account with V10. Just remember folks, you have to revoke your token and recreate it again. Otherwise, it won't work. I have now both V10 and V20 accounts. :)
I have done your first few posts and it all works. Just one thing, PANDAS has changed a bit, hence the csv import and handling datetime won't work with your code anymore. I have fixed it though with some adjustments. Would you like me to send you some PR's this regarding?
Yes, please make a pull request! I just updated the code (post coming soon) for v20 accounts.
It is not clear where I can fetch this information. The Token was easy, but this wasn't.
Thank you, Houman