I am personally implementing a rust-written trading bots for the stocks/options for personal interests. Here I published a package to support the IBKR (Interactive Brokers) unofficial API client in Rust. I'm still working on that (but the main APIs are tested with UT) and any contributions/stars are welcomed.
Also, I implemented a dockerfile (could be found in the GitHub source code) to run the IBKR client portal with only one command (docker-compose).
Would it be possible to comment about how reliable the connection is with the web api, and if you have a mechanism to handle disconnects. In the past the client api would drop the connections more frequently than the TWS api. Thanks!
The endpoints have a ton of repetitive, uninteresting code. Every function in the modules under endpoints/ is essentially the following, repeated dozens of times with very slight variations:
The API is stringly-typed. E.g. URLs are not arbitrary strings; use a real URL type.
The new constructor has too many parameters. You should probably use a configuration struct with named fields and a sensible Default impl, and/or the builder pattern instead.
The name of the main entry type, IBClientPortal, is non-idiomatic. Rust has real namespaces, there's no need for prefixes.
Having a separate test module insidesrc is unconventional. You can have inline unit tests in each module, or larger-scale integration test in tests/ under the crate root. Similarly, having mock data (assets/get_market_data.json) under src feels dirty as well.
Good point, I haven't noticed that given my trading frequency is low (maybe just 1-2 times per day).
To handle disconnects, I just doing the exponential retry and looks working normal now. Do we have any existing mechanisms to monitor the connection dropping rates? I'll deep dive this issue then