{"id":47312478,"url":"https://github.com/deepentropy/ibx","last_synced_at":"2026-04-03T09:02:11.249Z","repository":{"id":344906935,"uuid":"1172892577","full_name":"deepentropy/ibx","owner":"deepentropy","description":"Direct connection engine for Interactive Brokers in Rust. No Java Gateway required. Ultra-low-latency orders and market data. Rust + Python (PyO3).","archived":false,"fork":false,"pushed_at":"2026-04-02T17:08:17.000Z","size":2906,"stargazers_count":95,"open_issues_count":7,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-04-02T23:44:17.244Z","etag":null,"topics":["interactive-brokers","low-latency","market-data","pyo3","rust","trading"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepentropy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-04T19:53:35.000Z","updated_at":"2026-04-02T17:08:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/deepentropy/ibx","commit_stats":null,"previous_names":["deepentropy/ibx"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/deepentropy/ibx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepentropy%2Fibx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepentropy%2Fibx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepentropy%2Fibx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepentropy%2Fibx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepentropy","download_url":"https://codeload.github.com/deepentropy/ibx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepentropy%2Fibx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31344440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T08:03:20.796Z","status":"ssl_error","status_checked_at":"2026-04-03T08:00:37.834Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interactive-brokers","low-latency","market-data","pyo3","rust","trading"],"created_at":"2026-03-17T12:18:04.695Z","updated_at":"2026-04-03T09:02:11.244Z","avatar_url":"https://github.com/deepentropy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/banner.png\" alt=\"IBX\" width=\"100%\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eDirect IB connection engine. No Java Gateway. No middleman.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#benchmarks\"\u003eBenchmarks\u003c/a\u003e \u0026bull;\n  \u003ca href=\"#rust-usage\"\u003eRust\u003c/a\u003e \u0026bull;\n  \u003ca href=\"#python-usage\"\u003ePython\u003c/a\u003e \u0026bull;\n  \u003ca href=\"#notebooks\"\u003eNotebooks\u003c/a\u003e \u0026bull;\n  \u003ca href=\"#architecture\"\u003eArchitecture\u003c/a\u003e \u0026bull;\n  \u003ca href=\"docs/RUST_API.md\"\u003eRust API\u003c/a\u003e \u0026bull;\n  \u003ca href=\"docs/PYTHON_API.md\"\u003ePython API\u003c/a\u003e \u0026bull;\n  \u003ca href=\"docs/COVERAGE.md\"\u003eCoverage\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nIBX connects directly to Interactive Brokers servers — without requiring the official Java Gateway. Built in Rust for ultra-low-latency, available as both a Rust library and a Python library via PyO3. Both expose an ibapi-compatible `EClient`/`Wrapper` API.\n\n## Benchmarks\n\n### Processing Latency (no network)\n\nInternal engine processing measured in isolation (1M iterations, no network I/O). Compared to the Java Gateway's internal processing, measured via bytecode instrumentation.\n\n#### Tick Reading (wire → strategy)\n\n| Metric | Java Gateway | IBX (Rust) | Ratio |\n|---|---|---|---|\n| Latency | 2 ms | 340 ns | **5,900x** |\n\n#### Order Sending (strategy → wire)\n\n| Order Type | Java Gateway | IBX (Rust) | Ratio |\n|---|---|---|---|\n| Limit | 83 µs | 459 ns | **180x** |\n| Market | 76 µs | 460 ns | **165x** |\n| Cancel | 125 µs | 386 ns | **323x** |\n| Modify | 86 µs | 470 ns | **183x** |\n\nIBX eliminates the Java Gateway entirely — no JVM, no localhost hop, no garbage collection pauses. The strategy receives ticks and sends orders in-process.\n\n## Rust Usage\n\nAdd to `Cargo.toml`:\n\n```toml\n[dependencies]\nibx = { git = \"https://github.com/deepentropy/ibx\" }\n```\n\nibapi-compatible `EClient`/`Wrapper` API — same callback pattern as C++ `EClientSocket`:\n\n```rust\nuse ibx::api::{EClient, EClientConfig, Wrapper, Contract, Order};\nuse ibx::api::types::TickAttrib;\n\nstruct MyWrapper;\nimpl Wrapper for MyWrapper {\n    fn tick_price(\u0026mut self, req_id: i64, tick_type: i32, price: f64, attrib: \u0026TickAttrib) {\n        println!(\"tick_price: req_id={req_id} type={tick_type} price={price}\");\n    }\n}\n\nfn main() {\n    let mut client = EClient::connect(\u0026EClientConfig {\n        username: \"your_username\".into(),\n        password: \"your_password\".into(),\n        host: \"your_ib_host\".into(),\n        paper: true,\n        core_id: None,\n    }).unwrap();\n\n    // Market data\n    let spy = Contract { con_id: 756733, symbol: \"SPY\".into(), ..Default::default() };\n    client.req_mkt_data(1, \u0026spy, \"\", false, false);\n\n    // SeqLock quote read (lock-free, any thread)\n    if let Some(q) = client.quote(1) {\n        // q.bid, q.ask, q.last are i64 fixed-point (PRICE_SCALE = 10^8)\n    }\n\n    // Process events via Wrapper callbacks\n    let mut wrapper = MyWrapper;\n    loop {\n        client.process_msgs(\u0026mut wrapper);\n    }\n}\n```\n\n### Place and manage orders\n\n```rust\n// Limit order\nlet id = client.next_order_id();\nlet order = Order { order_type: \"LMT\".into(), action: \"BUY\".into(),\n    total_quantity: 1.0, lmt_price: 550.00, ..Default::default() };\nclient.place_order(id, \u0026spy, \u0026order).unwrap();\n\n// Cancel\nclient.cancel_order(id, \"\");\n```\n\n## Python Usage\n\nIBX exposes an [ibapi](https://github.com/InteractiveBrokers/tws-api)-compatible `EClient`/`EWrapper` API. Same callback pattern, same method names — but connecting directly through the Rust engine instead of through TWS or IB Gateway. Drop-in compatible with existing ibapi and [ib_async](https://github.com/ib-api-reloaded/ib_async) code.\n\n### Install\n\n```bash\n# Create venv and build\nuv venv .venv --python 3.13\nsource .venv/bin/activate  # or .venv\\Scripts\\activate on Windows\npip install maturin\nmaturin develop --features python\n```\n\n### Connect and trade\n\n```python\nimport threading\nfrom ibx import EWrapper, EClient, Contract, Order\n\nclass App(EWrapper):\n    def __init__(self):\n        super().__init__()\n        self.next_id = None\n        self.connected = threading.Event()\n\n    def next_valid_id(self, order_id):\n        self.next_id = order_id\n        self.connected.set()\n\n    def managed_accounts(self, accounts_list):\n        print(f\"Account: {accounts_list}\")\n\n    def order_status(self, order_id, status, filled, remaining,\n                     avg_fill_price, perm_id, parent_id,\n                     last_fill_price, client_id, why_held, mkt_cap_price):\n        print(f\"Order {order_id}: {status} filled={filled}\")\n\n    def tick_price(self, req_id, tick_type, price, attrib):\n        print(f\"Tick {tick_type}: {price}\")\n\n    def error(self, req_id, error_code, error_string, advanced_order_reject_json=\"\"):\n        if error_code not in (2104, 2106, 2158):\n            print(f\"Error {error_code}: {error_string}\")\n\napp = App()\nclient = EClient(app)\nclient.connect(username=\"your_user\", password=\"your_pass\", paper=True)\n\nthread = threading.Thread(target=client.run, daemon=True)\nthread.start()\napp.connected.wait(timeout=10)\n\n# Market data\naapl = Contract(con_id=265598, symbol=\"AAPL\")\nclient.req_mkt_data(1, aapl)\n\n# Orders\norder = Order(order_id=app.next_id, action=\"BUY\", total_quantity=1,\n              order_type=\"LMT\", lmt_price=150.00)\nclient.place_order(app.next_id, aapl, order)\n\n# Account\nclient.req_positions()\nclient.req_account_summary(1, \"All\", \"NetLiquidation,BuyingPower\")\n\nclient.disconnect()\n```\n\n### Supported EClient Methods\n\n| Category | Methods |\n|---|---|\n| **Connection** | `connect`, `disconnect`, `is_connected`, `run`, `get_account_id` |\n| **Market Data** | `req_mkt_data`, `cancel_mkt_data`, `req_tick_by_tick_data`, `cancel_tick_by_tick_data`, `req_mkt_depth`, `cancel_mkt_depth`, `req_market_data_type` |\n| **Orders** | `place_order`, `cancel_order`, `req_global_cancel`, `req_ids`, `req_open_orders`, `req_all_open_orders`, `req_auto_open_orders`, `req_completed_orders`, `req_executions` |\n| **Account** | `req_positions`, `cancel_positions`, `req_positions_multi`, `cancel_positions_multi`, `req_account_summary`, `cancel_account_summary`, `req_account_updates`, `req_account_updates_multi`, `cancel_account_updates_multi`, `req_pnl`, `cancel_pnl`, `req_pnl_single`, `cancel_pnl_single`, `req_managed_accts` |\n| **Historical** | `req_historical_data`, `cancel_historical_data`, `req_head_time_stamp`, `cancel_head_time_stamp`, `req_historical_ticks`, `req_real_time_bars`, `cancel_real_time_bars`, `req_histogram_data`, `cancel_histogram_data` |\n| **Reference** | `req_contract_details`, `req_matching_symbols`, `req_sec_def_opt_params`, `req_mkt_depth_exchanges`, `req_market_rule`, `req_smart_components` |\n| **Scanner** | `req_scanner_parameters`, `req_scanner_subscription`, `cancel_scanner_subscription` |\n| **News** | `req_news_providers`, `req_news_article`, `req_historical_news`, `req_news_bulletins`, `cancel_news_bulletins` |\n| **Fundamental** | `req_fundamental_data`, `cancel_fundamental_data` |\n| **Options** | `calculate_implied_volatility`, `cancel_calculate_implied_volatility`, `calculate_option_price`, `cancel_calculate_option_price`, `exercise_options` |\n| **Other** | `req_current_time`, `req_user_info`, `req_family_codes`, `req_soft_dollar_tiers`, `set_server_log_level`, `req_wsh_meta_data`, `req_wsh_event_data` |\n\n### Supported Order Types\n\nMKT, LMT, STP, STP LMT, TRAIL, TRAIL LIMIT, MOC, LOC, MTL, MIT, LIT, MKT PRT, STP PRT, REL, PEG MKT, PEG MID, MIDPRICE, SNAP MKT, SNAP MID, SNAP PRI, BOX TOP. Algo orders: VWAP, TWAP, Arrival Price, Close Price, Dark Ice, PctVol.\n\n## Notebooks\n\nJupyter notebooks adapted from [ib_async's examples](https://ib-api-reloaded.github.io/ib_async/notebooks.html), using the ibapi-compatible `EClient`/`EWrapper` pattern. All connect through the Rust engine — no TWS or IB Gateway needed.\n\n| Notebook | Description |\n|---|---|\n| [basics](notebooks/basics.ipynb) | Connect, positions, account summary |\n| [contract_details](notebooks/contract_details.ipynb) | Request contract metadata (AAPL, TSLA) |\n| [bar_data](notebooks/bar_data.ipynb) | Head timestamp, historical bars, pandas/matplotlib plot |\n| [tick_data](notebooks/tick_data.ipynb) | L1 streaming, live quote table, tick-by-tick last \u0026 bid/ask |\n| [ordering](notebooks/ordering.ipynb) | Limit orders, cancel, market orders, sell to flatten |\n| [market_depth](notebooks/market_depth.ipynb) | L2 order book, depth exchanges, SmartDepth |\n| [scanners](notebooks/scanners.ipynb) | Scanner parameters, market scanner subscriptions, resolve results |\n\n\u003e **Note:** `option_chain` notebook is planned — blocked on multi-asset options (#38).\n\n## Architecture\n\n```\n    ┌─────────────────────────────────────────────┐\n    │           Your Code (Rust / Python)          │\n    │  process_msgs() → Wrapper callbacks          │\n    │  client.quote(id) → SeqLock read             │\n    │  client.place_order(id,c,o) → control chan   │\n    └─────────┬──────────────────────┬─────────────┘\n              │ events (crossbeam)   │ commands\n    ┌─────────▼──────────────────────▼─────────────┐\n    │              IBX Engine (pinned thread)       │\n    │  ┌────────────────────────────────────────┐  │\n    │  │   Protocol Stack                       │  │\n    │  │   Encryption → Auth → Compression → Decode │  │\n    │  └────────────┬───────────────┬───────────┘  │\n    └───────────────┼───────────────┼──────────────┘\n               ┌────▼───┐     ┌────▼───┐\n               │ market │     │  auth  │\n               │  data  │     │ orders │\n               │  feed  │     │ control│\n               └────┬───┘     └────┬───┘\n                    │              │\n              ──────▼──────────────▼──────\n                     IB Servers\n```\n\n**Hot path**: Poll socket (non-blocking) → verify → decompress → decode ticks → update SeqLock quotes → push `Event::Tick` to channel → drain orders → encode → send. All on a single pinned core, zero allocations.\n\n**Rust client**: Events dispatched via `process_msgs()` → `Wrapper` callbacks. Quotes readable anytime via lock-free SeqLock (`client.quote()`). Orders sent via control channel. No shared mutable state.\n\n**Python bridge**: Same engine, ibapi-compatible `EClient`/`EWrapper` API. SeqLock quote reads, crossbeam order channel. No GIL contention on the hot path.\n\n## Requirements\n\n- Rust 2024 edition (1.85+)\n- Python 3.11+ (for PyO3 bindings)\n- Interactive Brokers account (paper or live)\n\n## License\n\n[AGPL-3.0](LICENSE)\n\n## Disclaimer\n\nInteractive Brokers®, IBKR®, Trader Workstation®, and IB Gateway® are registered trademarks of Interactive Brokers Group, Inc. This project is **not affiliated with, endorsed by, or supported by Interactive Brokers**.\n\nIBX is an independent, open-source project provided \"as is\", without warranty of any kind.\n\n### How IBX Was Built\n\nIBX was developed through **independent analysis of network traffic** between the official IB Gateway client and IB servers. No IB software was decompiled, disassembled, or modified. The protocol implementation was built from scratch in Rust based solely on observed wire-level behavior.\n\nThis approach is consistent with the principle of **interoperability through protocol analysis** — the same method used by projects like Samba (SMB/CIFS), open-source Exchange clients, and countless other third-party implementations of proprietary network protocols.\n\n### Legal Considerations\n\n- **No warranty.** IBX is provided \"as is\", without warranty of any kind. See [LICENSE](LICENSE) for full terms.\n- **Use at your own risk.** Users are solely responsible for ensuring their use of IBX complies with Interactive Brokers' Terms of Service, Customer Agreement, and any applicable laws or regulations. Using IBX may carry risks including but not limited to account restriction or termination by IB.\n- **Not financial software.** IBX is an experimental research project. It is not intended as a replacement for officially supported IB software in production trading environments. The authors accept no liability for financial losses, missed trades, account issues, or any other damages arising from the use of this software.\n- **Protocol stability.** IBX relies on an undocumented protocol that IB may change at any time without notice. There is no guarantee of continued functionality.\n\n### EU Interoperability\n\nFor users and contributors in the European Union: Article 6 of the EU Software Directive (2009/24/EC) permits reverse engineering for the purpose of achieving interoperability with independently created software, provided that specific conditions are met. IBX was developed with this legal framework in mind, enabling interoperability with IB's trading infrastructure on platforms where the official Java-based Gateway cannot run (headless Linux, containers, embedded systems).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepentropy%2Fibx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepentropy%2Fibx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepentropy%2Fibx/lists"}