Replies: 2 comments
-
I'm not sure if you are talking about testing ib_async itself, if so have you tried with Mock,MagicMock and AsyncMock? if you are talking about testing your trading algo, the same answer will work to some extend. What i usually do is to leverage eventkit. i create an event, connect my tradign algo to this "fake" event and i start emiting and see whats comes out at the other end. I would still try on paper account, mostly using futures and currencies to avoid the market hours problem. I usually do this to test execution. |
Beta Was this translation helpful? Give feedback.
-
This could work for some cases, but it would be a medium-sized project on its own. I assume you're saying create a mock "IBKR API" you'd connect to instead of to the gateway or TWS Itself. Some parts could be easy:
But, one big part of actually testing your client is testing the actual IBKR API replies given your account values. Things like margin offset calculations, commission estimates, valid algo parameter combinations, account balance / initial margin / maint margin calculations given your account and instrument classifications (RegT, SPAN, Portfolio Margin all change per instrument). and, all this goes without mentioning things like subscribing to simulated market data updates. I think sadly the answer is use the gateway in paper trading mode as the safest alternative. and when using paper trading mode, it helps to only use market orders (limit or algo order types rarely work correctly in paper trading accounts) because then at least you still get all the real time pub/sub account and position updates, etc. short version:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Since tests often can only be done during market opening hours, I would love to have a mock that can be used to simulate various scenarios. Does anyone know if there is already something out there? (I was not able to find anything yet)
I also tried a few approaches to create such a mock server instance, but I already fail on the connection handshake. Would be cool if there are some other people who would like to have such a (scriptable) mock, especially if they understand the requirements of the library
Beta Was this translation helpful? Give feedback.
All reactions