Can't get portfolio
freekeys opened this issue · 1 comments
freekeys commented
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 commented
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)