areed1192 / interactive-broker-python-api

A python packaged used to interact with the Interactive Brokers REST API.
MIT License
374 stars 122 forks source link

don't assume data_news() will return a valid dict #12

Closed Voyz closed 3 years ago

Voyz commented 3 years ago

When the gateway is already running, the data_news doesn't seem to return what was previously assumed. This PR fixes the issue by checking if data_news returned valid data.

fixes #8 fixes #10

5tomato commented 3 years ago

I may be reading this wrong, but this seems to be just going around the issue. It seems like the point is for data_news() to return not None before the code continues.

I cannot seem to get the data_news() function to return anything other than a 404 error "resource not found."

There is a separate issue that might causing the authentication issues. The iserver/account node returns a 500 error if the account is already set.

Voyz commented 3 years ago

I agree with @5tomato this is just a workaround. I also agree there are other places in code when this type of issue exists and IMO holistically this type of logic should be reworked in this library. I also couldn't get it to work properly so I stopped using it in the end.

5tomato commented 3 years ago

Did you use something else instead?

Voyz commented 3 years ago

@5tomato I built my own:

https://github.com/Voyz/ibeam

5tomato commented 3 years ago

Nice! Looks like you are mostly interested in keeping your session up and running, not necessarily collecting data and executing trades through it?

Voyz commented 3 years ago

@5tomato indeed - these two felt like they would be easier to manage if they were decoupled. The Gateway and its startup (eg. IBeam) could live in one place, while the API code could be running elsewhere. Also, using Swagger it is possible to convert IBKR's OpenAPI specification into autogenerated Python API code, so I concluded that it is the Gateway maintenance that requires a bespoke solution more promptly. Btw - if you're interested in collecting data, check out Databay