brndnmtthws / thetagang

ThetaGang is an IBKR bot for collecting money
GNU Affero General Public License v3.0
1.94k stars 255 forks source link

support paratition account #470

Open noamagiv opened 1 month ago

noamagiv commented 1 month ago

I have multiple Interactive Brokers (IB) accounts connected to one, making it possible to view all account orders from a single account. Let's consider my main account as A and the sub-accounts as B and C.

Up until today, I only worked with Trading Gateway (TG) directly with Account C, and everything worked as expected. Today, I connected Account B and triggered it with the same Toml configuration, with the only change being the account number.

When TG started on Account B, it immediately canceled all open orders for Account C. I assume this happened because TG retrieved open orders without considering the specific account.

I can try to fix it, please assign it to me if you want .

brndnmtthws commented 1 month ago

Hmm, I'm not sure if the API has a decent way to support this, but it makes sense. IBKR's API is just trash, but there aren't any better options, sadly. There is an orderRef field, but the documentation doesn't provide enough detail on how to use it: https://interactivebrokers.github.io/tws-api/classIBApi_1_1Order.html#a9aa003d6c9f80b79d822a426e0fd5f5b

In any case, feel free to take a stab at this :)