-
Notifications
You must be signed in to change notification settings - Fork 148
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
JSONDecodeError: Expecting property name enclosed in double quotes #47
Comments
Can't tell from the code you posted whether you have an v1 or v20 API account. The code also referred to a ForexSystem class which seemed to be a custom class created by the author. It's a bit challenging to tell what the problem is. You might like to refer to some sample codes that I posted on my github to get up and running quickly. It's open sourced. |
Oanda quotes v1 API: I ran this a moment ago. import oandapy
access_token=".."
oanda = oandapy.API(environment="practice", access_token=access_token)
account = "XXXXXXX"
class MyStreamer(oandapy.Streamer):
def __init__(self, count=10, *args, **kwargs):
super(MyStreamer, self).__init__(*args, **kwargs)
self.count = count
self.reccnt = 0
def on_success(self, data):
print(data)
self.reccnt += 1
if self.reccnt == self.count:
self.disconnect()
def on_error(self, data):
self.disconnect()
stream = MyStreamer(environment="practice", access_token=access_token)
stream.rates(account, instruments="EUR_USD") Gives JSON decoded output: {u'tick': {u'ask': 1.09708, u'instrument': u'EUR_USD', u'bid': 1.09697, u'time': u'2017-05-15T11:04:11.936976Z'}}
{u'tick': {u'ask': 1.09708, u'instrument': u'EUR_USD', u'bid': 1.09697, u'time': u'2017-05-15T11:04:11.936976Z'}}
{u'heartbeat': {u'time': u'2017-05-15T11:04:14.275570Z'}}
{u'heartbeat': {u'time': u'2017-05-15T11:04:16.603674Z'}}
{u'heartbeat': {u'time': u'2017-05-15T11:04:19.275622Z'}} So these are Python dicts. The streamer does JSON decoding of the incoming data. The error you report comes for instance from trying to decode a stringyfied dict: >>> d = {"a": 10} # dict
>>> s = str(d)
>>> print(s)
"{'a': 10}"
>>> json.loads(s) you get the error you reported |
These's are the exact codes from which I copy from a popular oanda sample code in some "Mastering Python for Finance" book. But no matter what I do, I keep getting JSON errors!
The Errors responses are the following. Can someone tell me how to fix this? I hear its OANDA's problem
The text was updated successfully, but these errors were encountered: