Closed sirugh closed 3 years ago
Ah, saw on another issue that the problem might be related to subscriptions in the IB Account. I added
NASDAQ (Network C/UTP)
NYSE (Network A/CTA)
NYSE American, BATS, ARCA, IEX, and Regional Exchanges (Network B)
OPRA (US Options Exchanges)
and the error is a bit different now.
2021-02-11 17:18:33,811 ib_insync.wrapper ERROR Error 10197, reqId 4: No market data during competing live session, contract: Stock(symbol='SPY', exchange='SMART', currency='USD')
2021-02-11 17:19:03,810 eventkit.event ERROR Value () caused exception for event Event<connectedEvent, [[None, None, <function start.<locals>.onConnected at 0x7f536587bc80>]]>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/eventkit/event.py", line 181, in emit
func(*args)
File "/usr/local/lib/python3.7/dist-packages/thetagang/thetagang.py", line 113, in onConnected
portfolio_manager.manage()
File "/usr/local/lib/python3.7/dist-packages/thetagang/portfolio_manager.py", line 271, in manage
self.check_if_can_write_puts(account_summary, portfolio_positions)
File "/usr/local/lib/python3.7/dist-packages/thetagang/portfolio_manager.py", line 443, in check_if_can_write_puts
self.wait_for_market_price(ticker)
File "/usr/local/lib/python3.7/dist-packages/thetagang/portfolio_manager.py", line 60, in wait_for_market_price
10,
File "/usr/local/lib/python3.7/dist-packages/thetagang/util.py", line 60, in while_n_times
while_n_times(pred, body, remaining - 1)
File "/usr/local/lib/python3.7/dist-packages/thetagang/util.py", line 60, in while_n_times
while_n_times(pred, body, remaining - 1)
File "/usr/local/lib/python3.7/dist-packages/thetagang/util.py", line 60, in while_n_times
while_n_times(pred, body, remaining - 1)
[Previous line repeated 7 more times]
File "/usr/local/lib/python3.7/dist-packages/thetagang/util.py", line 57, in while_n_times
raise "Exhausted retries waiting on predicate. This shouldn't happen. "
TypeError: exceptions must derive from BaseException
Ok, red herring - the No market data during competing live session
error was from me being logged in to the online web portal. Guess they don't allow you to do that while trying to access the API. So back to the original "not subscribed" error, even after adding the subscriptions. Is there a specific subscription we need to enable? What about asset class/permissions to trade? I see this hardcoded:
So a couple things first:
ExistingSessionDetectedAction
setting here. I recommend using primaryoverride
which will kick out any other sessions. IBKR doesn't let you have more than one active session at a time.It sounds like you may have already somewhat figured it out. Let me know how it goes. It's easier to start by making sure you can get basic things working with TWS first before making about with the automated tools.
My subscriptions:
I checked and my config is set to primaryoverride
, but maybe it can't override if I'm authed to the web portal. It does show a popup if I'm on TWS and run the docker container, so that's good. At this point though, I feel like I might just be hitting some issue with IBKR/paper permissions. Maybe it's because I haven't actually funded my live account? I might need to call them.
Anyways, after mirroring your settings as closely as possible, I'm still getting the "Requested market data is not subscribed" error. Is there something I can try in the TWS app to replicate the contract: Stock(symbol='SPY', exchange='SMART', currency='USD')
command?
FWIW I am trying this on paper first. Based on this article and my current settings, I should be getting data as I'm in that fifth row of case 1, yet when I log in to paper-trading on TWS and hover over "SPY" I see this:
These are my current subscriptions:
And these are my trading permissions:
Hmm, I can only assume IB isn't giving you data because it's not actually funded yet. Maybe they want to see a balance that can cover the data fees before they enable it.
You could try setting market_data_type = 4
, which will use frozen data, and that's usually sufficient for testing a paper account.
@sirugh , I had to make a demo account. They said i didnt have the ability to access data because my account doesnt pay fees or something like that. Also @brndnmtthws, im trying to run the tool on chromebook virtual debian machine, it was working a few days ago, and now im getting this error.
2021-02-15 02:12:02,176 ib_insync.client INFO Connecting to 127.0.0.1:4002 with clientId 1... 2021-02-15 02:12:02,179 ib_insync.client INFO Disconnecting 2021-02-15 02:12:02,179 ib_insync.client ERROR API connection failed: ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 4002)") 2021-02-15 02:12:02,180 ib_insync.client ERROR Make sure API port on TWS/IBG is open 2021-02-15 02:12:02,180 ib_insync.IBC INFO Terminating 2021-02-15 02:12:05,450 ib_insync.IBC INFO Starting
@Ianfinn1994 there isn't enough context from that log message for me to help. You're going to have to do some debugging. Please open a new issue in the future.
They said i didnt have the ability to access data because my account doesnt pay fees or something like that.
Yea this is my assertion as well. I am in the process of funding the account and will update this when I see if that makes a difference.
To follow up here, I got past the initial errors by funding the account first which then allowed me to subscribe to market data. Might be worth dropping a line in a FAQ related to this? If you have one, I'd be happy to open a PR.
To follow up here, I got past the initial errors by funding the account first which then allowed me to subscribe to market data. Might be worth dropping a line in a FAQ related to this? If you have one, I'd be happy to open a PR.
That'd be great
First, thanks for making this tool!
I finally got docker/wsl running along with the mounted paths and config, but I'm hitting an issue and I'm a bit stuck. Unsure if I need to modify part of the config or if there is a bug. I've basically copied the sample config files - the only changes are the addition of my username/password to both, although it wasn't clear to me if I needed to add it to both or just thetagang.toml.
See the stack below: