stoqey / ib

Interactive Brokers TWS/IB Gateway API client library for Node.js (TS)
https://stoqey.github.io/ib-doc/
MIT License
205 stars 47 forks source link

IB test papertrading account for CI #48

Closed Tsopic closed 3 years ago

Tsopic commented 3 years ago

Interactive Brokers used to have demo accounts but now it's more difficult to obtain a PaperTrading account.

I'm looking into ways to make CI work with tests, and need an IB paper trading account to use in CircleCI.

Anyone, having good connections with IB staff?

mfrener commented 3 years ago

Don't think we will get any help from IB on that. Might be worth a try simply asking them if it possible to create persistent paper account for automated testing purpose. My introducing broke (CapTrader in Germany) usually is very coopreative open it comes to creating additional accounts or logins. Idk how it is with IB guys directly.

Next thing would to post on twsapi@groups.io (if you don't have an account I can do). Maybe there are others that have same issue and solved it already (be able to CI-test your stuff against real IB servers).

Tsopic commented 3 years ago

I don't have an account, please check with them.

I'll prepare CI config meanwhile

mfrener commented 3 years ago

https://groups.io/g/twsapi/topic/ci_testing_anyone/80766946?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,80766946

mfrener commented 3 years ago

So up to now there was no real usefull answer on the mailing group. Recommendation basically is to build a TWS simulator and test our stack against that. We coud do that in theory, as we don't need to test real trading scenarios (we don't need acutal exchange, market data ect. logic, just return mock data for testing). We have encoder / decoder code, so also doing the other side not that much anymore. But...... we will test our code against our code. If we have bug on encoder, we propably have same bug on TWS simulator as well and test succeeds while it fails with real TWS.- And ofc it is efforts to implement and maintain this.. no idk if it is a good idea to start implementing a TWS simulator.

bayareacoder commented 3 years ago

@Tsopic @mfrener Per the IBKR website: "Once your regular trading account has been approved and funded, you are eligible to open a Paper Trading Account.". Just trying to understand what the issue is for you with getting a paper trading account? I got one right away when I opened my live account. Why would simulation be a better route - besides the time spent on it, the IBKR API is very extensive and tricky with the TCP socket communication and actually making sure your client works reliably with their server downtimes is one of the key issues. Would be hard to simulate I think.

mfrener commented 3 years ago

@bayareacoder paper trading account is fine for local testing, but we want it on the CI (continuous integration) pipeline. Means, every time a dev pushes a change, a pool (ideally :D ) of servers starts to pull up docker containers and tests the new code against all kind of environments (i.e. you want to test against a set of different TWS versions at least, having different account types would be cool (Single, IRA, Advisor, .. they have different features enabled), or different configs on the accounts to i.e. test trade restricton errors, ....). You could do this with a single account, all serial, but a CI-cycle will than probably take 24h. Also you need a paper trading account that can be used for it - I need mine for myself =)

Edit: and no, simulation is no better router. Just saying that nobody on twsapi@groups.io (up to now) does CI testing against TWS - because you would need to have a simluator to overcome IB account restrictions.

bayareacoder commented 3 years ago

@mfrener Seems several have been successful at running IB Gateway in a Docker container and automating the login. e.g. https://github.com/th3sys/capsule, which uses https://github.com/ib-controller/ib-controller.

mfrener commented 3 years ago

@bayareacoder yeah, that's not the issue @Tsopic has setup this already and integrate in on CI. But you need to enter account credentials to ib-contoller. I need my paper account for local testing, Tspoic as well. Can we use your one? You need to re-create every month because it expires and update the CI script. Also pls ask some of your friends to sponsor their account, because we would like to run the dockers (there will one for each TWS versoin we support, hopefully) in parallel not in serial. You see the problem ;)

bayareacoder commented 3 years ago

@mfrener OK so the issue is that you just need more paper trading accounts. It seems to me getting a few of your family members to put minimum funds to open live accounts so you can get extra paper accounts will be a lot easier than building an accurate simulator. And no you can't use my account :) Best of luck. PS happy to have found your version of the ib library; it's quite good.

mfrener commented 3 years ago

Yes, a simulator is out of question. We build an API client here, a sim that would be a whole new project. Think I'm going to wait for next week until the some weekend party folks catches up on twsapi@groups.io and if there is nothing usefull, I will ask at my broker.. maybe can get some special deal like 5 free paper accounts for posting their logo on the readme or whatever.

mfrener commented 3 years ago

Closed as no broker seems to be willing to sponsor some accounts.