TypeScript SDKs for Interactive Brokers
Choose between @stoqey/ibkr (developer-friendly wrapper with automatic caching) or @stoqey/ib (low-level socket & TWS Java SDK port).
@stoqey/ibkr
Simplified manager singletons for account balances, portfolios, open orders, and market data. Zero manual state management.
@stoqey/ib
Direct TypeScript port of TWS Java SDK v10.32.01. Includes traditional EventEmitter (`IBApi`) and RxJS 7 (`IBApiNext`).
Compare Code Architectures
See how `@stoqey/ibkr` high-level managers compare to `@stoqey/ib` low-level socket observables.
import ibkr, { Orders, MarketDataManager, IBKREvents, IBKREVENTS } from "@stoqey/ibkr";
import { OrderAction, OrderType } from "@stoqey/ib";
// 1. Connect & initialize managers
await ibkr();
// 2. Resolve contract details
const contract = await MarketDataManager.Instance.getContract({
symbol: "AAPL",
secType: "STK",
exchange: "SMART",
currency: "USD",
});
// 3. Listen for filled trade executions
IBKREvents.Instance.on(IBKREVENTS.IBKR_SAVE_TRADE, (trade) => {
console.log("Trade filled:", trade.action, trade.quantity, trade.price);
});
// 4. Place order with automatic position & trade tracking
await Orders.Instance.placeOrder(contract, {
action: OrderAction.BUY,
totalQuantity: 10,
orderType: OrderType.MKT,
transmit: true,
tif: "DAY",
});Why Developers Choose Stoqey SDKs
Built for high reliability, algorithmic trading, and quantitative finance.
Automatic State Caching
`@stoqey/ibkr` maintains real-time cached snapshots of Net Liquidation, Portfolio Positions, and Filled Trades.
RxJS & Event Bus
Stream real-time price bars, Level II depth, and order execution events with simple subscriptions.
Pure TCP Socket Transport
Pure Node.js `net` socket connection to TWS / IB Gateway with zero C++ native compile dependencies.