Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asyncio #17

Open
zdytch opened this issue Jul 11, 2024 · 1 comment
Open

Asyncio #17

zdytch opened this issue Jul 11, 2024 · 1 comment

Comments

@zdytch
Copy link

zdytch commented Jul 11, 2024

First, thank you Voy and other contributors, for the huge work you do on this project. I've been fighting against working with IB API for the last 4 years and find it... hmmm... (let's use a kind word here) "unfriendly". Actually, an IB's developer team is supposed to write such a wrapper for their customers, but they'd rather not.

My question is, why don't you start it as an asyncio project? From my experience, trading strategies are always doing so much stuff at the same time, reading inputs from different sources, placing orders, checking consistency, etc. So having non-blocking requests is important in this domain. Again, running a websocket client in the same thread with asyncio, looks better for me.

Maybe I don't understand something? Or maybe you already have asyncio in the roadmap?

@Voyz
Copy link
Owner

Voyz commented Jul 17, 2024

Hey @zdytch many thanks for checking out IBind and for your kind words.

My question is, why don't you start it as an asyncio project? From my experience, trading strategies are always doing so much stuff at the same time, reading inputs from different sources, placing orders, checking consistency, etc.

Good question! IBind could totally be written with asyncio. And the short answer is: I personally dislike it, I use multithreading.

I ran a few projects with it and ended up reverting back to threading due to complexity. This was a few years back, but from what I remember I had issues with exactly what you describe - needing for things to happen in parallel, bit by bit. Asyncio brought in an unnecessary amount of complexity when it came to different modules depending on each other - I recall code getting stuck a lot. Possibly there was an elegant solution to my issues at the time, but failing to find one after a good while trying, I decided to stick to threading which was clear to me. I've been running trading projects using threading since then without such issues, and threading speed was never a bottleneck I needed to look into. If it was I'm sure I'd have revisited asyncio.

When it comes to a project like IBind, I can see how asyncio would not cause the issues that I encountered. Not being fluent in using it though, I decided to stick to the tech I knew.

Both REST and WebSocket can be elegantly run with multithreading. I published a separate Python library called SuperLoops that I use for managing WebSockets using threading.

So yeah, not currently on the roadmap sadly - although if you think it could be integrated into IBind easily, then let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants