IB@stoqey/ib
@stoqey/ibkr (High-Level Wrapper)

@stoqey/ibkr Overview

Modern developer-friendly TypeScript wrapper library for Interactive Brokers Node.js applications.

@stoqey/ibkr is a modern, TypeScript-based Node.js wrapper library for Interactive Brokers (IBKR).

It is built directly on top of @stoqey/ib and abstracts away low-level socket, event listener, and request ID tracking into clean singleton managers (AccountSummary, Portfolios, MarketDataManager, Orders).


Feature Matrix

FeatureDescriptionStatus
Accounts SummaryAutomatic caching & event-driven balance updates✅ Available
Portfolio PositionsAutomatic position snapshot & update events✅ Available
Order ManagementEasy order placement, modification, cancellations & filled trade tracking✅ Available
Market DataHistorical bars, real-time bar updates, tick-by-tick streaming, & quotes✅ Available
Contract ResolutionSymbol search & contract lookup for STK, OPT, FUT, FOREX, CFD✅ Available
Market Data Only ModeLightweight mode (IBKR_MD_ONLY=true) for tickers & scanners✅ Available
Contract AllowlistScope-based symbol filtering (IBKR_CONTRACTS)✅ Available

Quick Example

import ibkr, { Orders, MarketDataManager, IBKREvents, IBKREVENTS } from "@stoqey/ibkr";
import { OrderAction, OrderType } from "@stoqey/ib";

async function main() {
  // 1. Initialize client and connect to TWS / Gateway
  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. Submit order
  await Orders.Instance.placeOrder(contract, {
    action: OrderAction.BUY,
    totalQuantity: 10,
    orderType: OrderType.MKT,
    transmit: true,
    tif: "DAY",
  });
}

main();

Next Steps

On this page