Skip to content
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

Can't get portfolio #9

Closed
freekeys opened this issue Dec 17, 2022 · 1 comment
Closed

Can't get portfolio #9

freekeys opened this issue Dec 17, 2022 · 1 comment

Comments

@freekeys
Copy link

Hi, I keep getting the error below when I try to get my portfolio. This is a new paper account with no portfolio in place yet, so I'd expect it to return an empty portfolio instead of an error? I've tried restarting ibeam and my server but the error persists. Other service calls work. Any ideas much appreciated! Thanks

Traceback (most recent call last):
  File "/home/xxx/test.py", line 72, in <module>
    print(api.get_portfolio())
  File "/home/xxx/.local/lib/python3.9/site-packages/easyib/easyib.py", line 98, in get_portfolio
    for item in response.json():
  File "/usr/lib/python3/dist-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@utilmon
Copy link
Owner

utilmon commented Dec 19, 2022

Hi! This is weird. My paper account is also empty and it returns an empty array just fine.
It seems you are not getting any response from the server.
Can you run the following code and see what happens?

import requests as rq
import easyib

ib = easyib.REST() # put URL argument if port is not 5000

response = rq.get(f"{ib.url}portfolio/{ib.id}/positions/0", verify=ib.ssl)
print(response.json())

cash = ib.get_cash()
print(cash)

@utilmon utilmon closed this as completed Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants