All Projects β†’ stoqey β†’ ibkr

stoqey / ibkr

Licence: MIT license
Interactive Brokers wrapper 🚩

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to ibkr

ib
Interactive Brokers TWS/IB Gateway API client library for Node.js (TS)
Stars: ✭ 94 (+176.47%)
Mutual labels:  market-data, interactive-brokers, twsapi, stocks-api, forex-api
ibeam
IBeam is an authentication and maintenance tool used for the Interactive Brokers Client Portal Web API Gateway.
Stars: ✭ 244 (+617.65%)
Mutual labels:  interactive-brokers, ibkr-api, ibkr
TradeBot
Crypto trading bot using Binance API (Java)
Stars: ✭ 292 (+758.82%)
Mutual labels:  market, market-data
PT.MarketDataService
Market Data collector for Interactive Brokers
Stars: ✭ 16 (-52.94%)
Mutual labels:  market-data, interactive-brokers
ib dl
Historical market data downloader using Interactive Brokers TWS
Stars: ✭ 43 (+26.47%)
Mutual labels:  market-data, interactive-brokers
InterReact
Interactive Brokers reactive C# API.
Stars: ✭ 28 (-17.65%)
Mutual labels:  interactive-brokers, ibkr
IB.CSharpApiClient
Interactive Brokers - TWS API simplified client
Stars: ✭ 41 (+20.59%)
Mutual labels:  trading-api, interactive-brokers
Shioaji
Shioaji all new cross platform api for trading ( θ·¨εΉ³ε°θ­‰εˆΈδΊ€ζ˜“API )
Stars: ✭ 203 (+497.06%)
Mutual labels:  trading-api, market-data
Sumzerotrading
A Java API for Developing Automated Trading Applications for the Equity, Futures, and Currency Markets
Stars: ✭ 128 (+276.47%)
Mutual labels:  trading-api, market-data
xapi-node
xStation5 Trading API for NodeJS/JS
Stars: ✭ 36 (+5.88%)
Mutual labels:  trading-api, forex-api
rRofex
R library to connect to Matba Rofex's Trading API. Functionality includes accessing account data and current holdings, retrieving investment quotes, placing and canceling orders, and getting reference data for instruments.
Stars: ✭ 21 (-38.24%)
Mutual labels:  trading-api, market-data
Coinapi Sdk
SDKs for CoinAPI
Stars: ✭ 238 (+600%)
Mutual labels:  trading-api, market-data
EA31337-classes
πŸ“¦πŸ“ˆ EA31337 framework (MQL library for writing trading Expert Advisors, indicators and scripts)
Stars: ✭ 103 (+202.94%)
Mutual labels:  market, trading-api
Polkadex
An Orderbook-based Decentralized Exchange using the Substrate Blockchain Framework.
Stars: ✭ 223 (+555.88%)
Mutual labels:  market
FAIG
Fully Automated IG Trading
Stars: ✭ 134 (+294.12%)
Mutual labels:  trading-api
NEUP-FleaMarket
δΈœεŒ—ε€§ε­¦ε…ˆι”‹εΈ‚εœΊ
Stars: ✭ 18 (-47.06%)
Mutual labels:  market
market-pricing
Wrapper for the unofficial Steam Market Pricing API
Stars: ✭ 21 (-38.24%)
Mutual labels:  market
intrinio-realtime-java-sdk
Intrinio Java SDK for Real-Time Stock Prices
Stars: ✭ 22 (-35.29%)
Mutual labels:  market-data
marketplace-feedback
This repository is for feedback regarding NativeScript Marketplace. Use the issues system here to submit feature requests, vote for existing ones or report bugs.
Stars: ✭ 16 (-52.94%)
Mutual labels:  market
market
πŸ§œβ€β™€οΈ THE Data Market
Stars: ✭ 149 (+338.24%)
Mutual labels:  market

IBKR: Interactive Brokers

NPM

Run IBKR in style

This is an event-based ibkr client for node

Feature
βœ… Accounts
βœ… Portfolios
βœ… Orders
βœ… Historical Data
βœ… Realtime price updates
βœ… Contracts (stocks/forex/options/index .e.t.c)
βœ… Mosaic Market scanner
⬜️ News

1. Install

npm i @stoqey/ibkr

2. Usage

Initialize

import ibkr, { AccountSummary, IBKREVENTS, IbkrEvents, PortFolioUpdate, getContractDetails } from '@stoqey/ibkr';

const ibkrEvents = IbkrEvents.Instance;


// 0. Using env process.env.IB_PORT and process.env.IB_HOST
await ibkr();

// 1. Async 
await ibkr({ port: IB_PORT, host: IB_HOST });

// 2. Callback
ibkr({ port: IB_PORT, host: IB_HOST }).then(started => {
  
    if(!started){
          // Error IBKR has not started
          console.log('error cannot start ibkr');
        //   Not to proceed if not connected with interactive brokers
          return process.exit(1);
    }

    // Your code here

})

Accounts, Summary e.t.c

const accountId = AccountSummary.Instance.accountSummary.AccountId;
const totalCashValue = AccountSummary.Instance.accountSummary.TotalCashValue;

Portfolios

// Get current portfolios
const portfolios = Portfolios.Instance;
const accountPortfolios = await portfolios.getPortfolios();

// Subscribe to portfolio updates
ibkrEvents.on(IBKREVENTS.PORTFOLIOS, (porfolios: PortFolioUpdate[]) => {
      // use porfolios  updates here
})

Historical Data + Realtime price updates

  • Market data
import { HistoricalData } from '@stoqey/ibkr';

// 1. Init
const historyApi = HistoricalData.Instance;

const args = {
  symbol,
  // contract: ib.contract.stock("AAPL"),
  endDateTime = '',
  durationStr = '1 D',
  barSizeSetting = '1 min',
  whatToShow = 'ASK'
};

// 2. Get market data async promise
const data = await historyApi.reqHistoricalData(args);

// OR 

// 3.1 Request for market data using events
historyApi.getHistoricalData(args);
ibkrEvents.emit(IBKREVENTS.GET_MARKET_DATA, args); // the same

// 3.2. Subscribe to market data results
ibkrEvents.on(IBKREVENTS.ON_MARKET_DATA, ({ symbol, marketData }) => {
    //  Use the data here
})
  • Real-time price updates
import { PriceUpdates } from '@stoqey/ibkr';

PriceUpdates.Instance; // init

// subscribe for price updates
ibkrEvents.on(IBKREVENTS.ON_PRICE_UPDATES, (priceUpdates) => {
     // use the price updates here
 });

//  Request price updates
ibkrEvents.emit(IBKREVENTS.SUBSCRIBE_PRICE_UPDATES, { symbol: 'AAPL' });
// Unsubscribe from price updates
ibkrEvents.emit(IBKREVENTS.UNSUBSCRIBE_PRICE_UPDATES, symbol);

Contracts

 
const contractDetails = await getContractDetails(ib.contract.stock("AAPL"));

//  or e.g options
const contractDetails = await getContractDetails({
    currency: 'USD',
    exchange: 'SMART',
    multiplier: 100,
    right: 'C',
    secType: 'OPT',
    strike: 300,
    symbol: 'AAPL'
});

// e.g forex
const contractDetails = await getContractDetails({
    "symbol":"GBP",
    "secType":"CASH",
    "currency":"USD",
     // "localSymbol":"GBP.USD",
});


// or with just a symbol, defaults to stocks
 const contractDetails = await getContractDetails('AAPL');

Orders

import { Orders, OrderStock } from '@stoqey/ibkr';

const orderTrade = Orders.Instance;

const myStockOrder: OrderStock = { ... }

const placedOrder = await orderTrade.placeOrder(myStockOrder);
          

OrderStock

const stockOrderBuyOut: OrderStock = {
    symbol: symbol,
    action: "SELL",
    type: "limit",
    parameters: ["1", "9999"], // 'SELL', 1, 9999,
}

type

  • limit ('SELL', 1, 9999) like in example above
  • market (action, quantity, transmitOrder, goodAfterTime, goodTillDate)
  • marketClose (action, quantity, price, transmitOrder)
  • stop (action, quantity, price, transmitOrder, parentId, tif)
  • stopLimit (action, quantity, limitPrice, stopPrice, transmitOrder, parentId, tif)
  • trailingStop (action, quantity, auxPrice, tif, transmitOrder, parentId)

Order events

  • Order filled
ibkrEvents.on(IBKREVENTS.ORDER_FILLED, (data) => {

});
  • Order status
ibkrEvents.on(IBKREVENTS.ORDER_STATUS, (data) => {

});
  • Open Orders updates
ibkrEvents.on(IBKREVENTS.OPEN_ORDERS, (data) => {

});

Mosaic Scanner

import { MosaicScanner } from '@stoqey/ibkr';
const mosaicScanner = new MosaicScanner();

const scannerData = await mosaicScanner.scanMarket({
      instrument: 'STK',
      locationCode: 'STK.US.MAJOR',
      numberOfRows: 10,
      scanCode: 'TOP_PERC_GAIN',
      stockTypeFilter: 'ALL'
})

see any .test.ts file for examples

3. Debug

We use debug library for logging. Run with DEBUG=ibkr:* to see all logs, or DEBUG=ibkr:info for less verbose logs.

See change log for updates

Stoqey Inc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].