Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
custom-ibkr
Advanced tools
This is an event-based ibkr client for node
Feature | |
---|---|
✅ | Accounts |
✅ | Portfolios |
✅ | Orders (stocks/forex/options/index .e.t.c) |
✅ | Historical Data |
✅ | Realtime price updates |
✅ | Contracts (stocks/forex/options/index .e.t.c) |
✅ | Mosaic Market scanner |
⬜️ | News |
npm i custom-ibkr
import ibkr, { AccountSummary, IBKREVENTS, IbkrEvents, PortFolioUpdate, getContractDetails } from 'custom-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
})
const accountId = AccountSummary.Instance.accountSummary.AccountId;
const totalCashValue = AccountSummary.Instance.accountSummary.TotalCashValue;
// 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
})
import { HistoricalData } from 'custom-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
})
import { PriceUpdates } from 'custom-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);
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');
import { Orders, Order, Contract } from 'custom-ibkr';
const orderTrade = Orders.Instance;
const myStockOrder: Order = { ... }
const myStockContract: Contract = { ... }
const placedOrder = await orderTrade.placeOrder(myStockContract, myStockOrder);
Order
const stockOrderBuyOut: Order = {
action: OrderAction.BUY,
orderType: OrderType.LMT,
lmtPrice: 200
totalQuantity: 5
}
const stockContractBuyOut: Contract = {
symbol: symbol,
secType: SecType.STK,
exchange: exchange, // 'SMART'
currency: currency // 'USD'
}
type
(action, quantity, lmtPrice)
like in example above(action, quantity, transmitOrder, goodAfterTime, goodTillDate)
(action, quantity, price, transmitOrder)
(action, quantity, price, transmitOrder, parentId, tif)
(action, quantity, limitPrice, stopPrice, transmitOrder, parentId, tif)
(action, quantity, auxPrice, tif, transmitOrder, parentId)
Order events
ibkrEvents.on(IBKREVENTS.ORDER_FILLED, (data) => {
});
ibkrEvents.on(IBKREVENTS.ORDER_STATUS, (data) => {
});
ibkrEvents.on(IBKREVENTS.OPEN_ORDERS, (data) => {
});
Mosaic Scanner
import { MosaicScanner } from 'custom-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
We use debug library for logging.
Run with DEBUG=ibkr:*
to see all logs, or DEBUG=ibkr:info
for less verbose logs.
FAQs
NodeJS Interactive Brokers wrapper & utilities - Custom Version
The npm package custom-ibkr receives a total of 7 weekly downloads. As such, custom-ibkr popularity was classified as not popular.
We found that custom-ibkr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.