@stoqey/ib (Low-Level SDK)IBApiNext Reference
IBApiNext Method Reference
Comprehensive list of Promises and RxJS Observable methods in IBApiNext.
Connection & Control
connect(clientId?: number): void
Connects IBApiNext to TWS or IB Gateway.
disconnect(): void
Disconnects the socket session.
One-Shot Promise Methods
getCurrentTime(): Promise<number>
Returns the current server time from TWS in Unix seconds.
getContractDetails(contract: Contract): Promise<ContractDetails[]>
Resolves full contract definitions and exchange metadata.
const details = await api.getContractDetails({
symbol: "TSLA",
secType: SecType.STK,
currency: "USD",
exchange: "SMART",
});searchContracts(pattern: string): Promise<ContractDescription[]>
Searches TWS symbol database matching text queries.
Reactive Stream Methods (Observables)
getAccountSummary(group: string, tags: string): Observable<AccountSummary>
Streams live updates for portfolio balances and account values.
api.getAccountSummary("All", "NetLiquidation,TotalCashValue,BuyingPower").subscribe((summary) => {
console.log("Account Summary Update:", summary);
});getPositions(): Observable<Position[]>
Streams current open positions.
api.getPositions().subscribe((positions) => {
positions.forEach((pos) => {
console.log(`${pos.account} - ${pos.contract.symbol}: ${pos.pos} @ $${pos.avgCost}`);
});
});getPnL(account: string, modelCode?: string): Observable<PnL>
Streams total account daily and unrealized PnL.
getPnLSingle(account: string, modelCode: string, conId: number): Observable<PnLSingle>
Streams position-level PnL.
getMarketData(contract: Contract, genericTickList: string, snapshot: boolean, regulatorySnapshot: boolean): Observable<MarketData>
Streams live tick prices, sizes, and market metrics.
Order Management Methods
placeOrder(contract: Contract, order: Order): Promise<number>
Submits an order and returns the assigned orderId.
const orderId = await api.placeOrder(contract, order);
console.log(`Placed order ID: ${orderId}`);cancelOrder(orderId: number, manualOrderCancelTime?: string): Promise<void>
Cancels an active order.