ib-client
v0.5.0
Published
Interactive Brokers API client library for Node.js
Downloads
28
Maintainers
Readme
This is a Node.js version of Interactive Brokers' TWS/IBGW API official client library. It's compatible with TWS API 974 and earlier versions too.
Extra features:
- built in retries on lost TWS API connection
- high priority
connect
commands when trying to reconnect to TWS/Gateway - commands held in a queue until processed
- V100+ connection mechanism allowed
- builder classes for contracts and orders
Library structure:
The library consists of 4 modules:
Inner Socket module makes connection to TWS/IBGW API using net and events modules
Message transformation module:
- Message Encoder: converts client requests to binary sequences using messaging protocols of TWS API
- Message Decoder: converts the incoming TWS API's binary sequences to javascript objects
Queue module:
- Outbound Queue: enques the commands comming from the Client module. When processing, it calls the Encoder with the commands, then it sends the encoded results to the Socket. In addition, it applies rate limiting, retries and message prioritization techniques
- Inbound Queue: receives messages from the Socket. When processing, it calls the Decoder with the messages, then sends the decoded results back to the Client module.
Client module:
- implements the IB Client interface
- validates the commands and pushes them into Qutbound Queue
- receives responses from Inbound Queue and emits events to pass the results back to user
- manages the other modules
The API Client uses the same API command method- and parameter names as the Java version (see the TWS/IBGW API documentation)
It uses EventEmmitter to pass back the responses from TWS/IBGW API. For better usage the response events are named after the event listener names used in the Java version.
Usage:
See the examples here