Interactive Brokers SDK
How It Works
npm install ib-sdk
- The SDK expects to connect to an authenticated user session.
- The IB software must be configured to accept API connections.
- The SDK connects over
- Use ib-controller to automate UI interaction if necessary.
The entry point is the
session returned by the
sdk.start promise. Each
session is associated with one or more accounts. The most common case is access to a single account.
For multiple managed accounts, the accounts summary must be used. Otherwise only one account can be subscribed to at a time.
let accounts = await session;accounts;console;accountsorders;console;accountstrades;session;
Use the SDK's symbol syntax to create
securities from which you can access market data.
let AAPL = await session0;console;let snapshot = await AAPL;console;if !AAPLcontractmarketsOpensessionfrozen = true;let instant = await AAPLquote;console;let chart = await AAPLchartsminutesfivehistory;chart;console;elselet quote = await AAPLquote;let depth = await AAPLdepth;let charts = await AAPLcharts;
Manage system events like changes in market data farm connectivity, IB bulletins, and FYI's. If you connect to the graphical TWS software, you can interact with display groups.
session;// Make sure stuff has loadedawait session;// IB news bulletins (margin calls, special labelling, etc)let bulletins = sessionbulletins;console;// Market data farm connectionslet connectivity = sessionconnectivity;console;// Access display groupssessiondisplayGroups;// Update display groupsessiondisplayGroups0;
Copyright 2017 Jonathan Hollinger
This is an open source project unrelated to Interactive Brokers.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.