Skip to content

Latest commit

 

History

History
347 lines (275 loc) · 9.66 KB

README.md

File metadata and controls

347 lines (275 loc) · 9.66 KB

Exante CI Status version Known Vulnerabilities Coverage Status code style: prettier semantic-release Conventional Commits GitHub top language node version npm downloads License

Node.js library for Exante's API.

Installation

npm install exante

Usage

The library currently supports the following API versions: 2.0 and 3.0 (see API versions). For more detailed documentation please see docs.

RestClient

import { RestClient } from "exante";
const client_id = "d0c5340b-6d6c-49d9-b567-48c4bfca13d2";
const app_id = "6cca6a14-a5e3-4219-9542-86123fc9d6c3";
const shared_key = "5eeac64cc46b34f5332e5326/CHo4bRWq6pqqynnWKQg";
const demo = false;
const client = new RestClient({ client_id, app_id, shared_key, demo });
const version = "3.0";
const accounts = await client.getAccounts({ version });
const version = "2.0";
const changes = await client.getDailyChanges({ version });
const version = "3.0";
const symbolId = ["AAPL.NASDAQ", "MSFT.NASDAQ"];
const changes = await client.getDailyChange({ version, symbolId });
const version = "2.0";
const currencies = await client.getCurrencies({ version });
const from = "USD";
const to = "EUR";
const crossrate = await client.getCrossrate({ from, to });
const version = "3.0";
const exchanges = await client.getExchanges({ version });
const version = "2.0";
const exchangeId = "NASDAQ";
const symbols = await client.getExchangeSymbols({ version, exchangeId });
const groups = await client.getGroups({});
const version = "3.0";
const groupId = "NG";
const symbols = await client.getGroupSymbols({ version, groupId });
const version = "2.0";
const groupId = "NG";
const symbol = await client.getGroupNearestSymbol({ version, groupId });
const symbols = await client.getSymbols();
const version = "3.0";
const symbolId = "AAPL.NASDAQ";
const symbol = await client.getSymbol({ version, symbolId });
const version = "2.0";
const symbolId = "AAPL.NASDAQ";
const types = true;
const schedule = await client.getSymbolSchedule({ version, symbolId, types });
const symbolId = "AAPL.NASDAQ";
const specification = await client.getSymbolSpecification({ symbolId });
const version = "3.0";
const types = await client.getTypes({ version });
const version = "2.0";
const symbolType = "OPTION";
const symbols = await client.getTypeSymbols({ version, symbolType });
const symbolIds = ["MSFT.NASDAQ", "AAPL.NASDAQ", "GAZP.MICEX"];
const stream = await client.getTradesStream({ symbolIds });
for await (const update of stream) {
  console.log(update);
}
const version = "3.0";
const symbolIds = ["MSFT.NASDAQ", "AAPL.NASDAQ", "GAZP.MICEX"];
const level = "market_depth";
const ac = new AbortController();

const stream = await client.getQuoteStream(
  { version, symbolIds, level },
  { signal: ac.signal }
);
for await (const update of stream) {
  console.log(update);
}
const symbolIds = ["MSFT.NASDAQ", "AAPL.NASDAQ"];
const level = "market_depth";
const quote = await client.getLastQuote({ symbolIds, level });
const version = "3.0";
const duration = "3600";
const symbolId = "AAPL.NASDAQ";
const from = 1481565600000;
const to = 1481572800000;
const size = 1;
const candles = await client.getCandles({
  version,
  duration,
  symbolId,
  from,
  to,
  size,
});
const version = "2.0";
const symbolId = "AAPL.NASDAQ";
const from = "1481565600000";
const to = 1481572800000;
const size = 1;
const type = "trades";
const ticks = await client.getTicks({
  version,
  symbolId,
  from,
  to,
  size,
  type,
});
const version = "3.0";
const id = "ABC1234.001";
const currency = "EUR";
const summary = await client.getAccountSummary({ version, id, currency });
const version = "3.0";
const id = "ABC1234.001";
const date = "2013-02-16";
const currency = "EUR";
const summary = await client.getAccountSummary({
  version,
  id,
  date,
  currency,
});
const symbolId = "AAPL.NASDAQ";
const operationType = ["TRADE"];
const limit = 1;
const transactions = await client.getTransactions({
  symbolId,
  operationType,
  limit,
});
const version = "3.0";
const symbolId = "AAPL.NASDAQ";
const side = "sell";
const quantity = "1";
const limitPrice = "10000";
const duration = "good_till_cancel";
const orderType = "limit";
const accountId = "ABC1234.001";
const order = await client.placeOrder({
  version,
  symbolId,
  side,
  quantity,
  limitPrice,
  duration,
  orderType,
  accountId,
});
const version = "2.0";
const limit = "10";
const from = "2017-05-18T10:00:00.000Z";
const to = "2017-05-21T17:59:59.999Z";
const account = "ABC1234.001";
const orders = await client.getOrders({ version, limit, from, to, account });
const instrument = "APL.NASDAQ";
const account = "ABC1234.001";
const orders = await client.getActiveOrders({ instrument, account });
const version = "3.0";
const orderId = "d642d2ca-fcb5-4910-9de4-7c91f275ca23";
const action = "replace";
const limitPrice = "101.0";
const quantity = "7";
const stopPrice = "102.0";
const priceDistance = "1.0";
const order = await client.modifyOrder({
  version,
  orderId,
  action,
  parameters: { limitPrice, quantity, stopPrice, priceDistance },
});
const version = "3.0";
const orderId = "ffecfac8-ccf9-4015-9a0f-b49a6b9673b8";
const order = await client.getOrder({ version, orderId });
const version = "2.0";
const stream = await client.orderUpdatesHttp({ version });
for await (const update of stream) {
  console.log(update);
}
const version = "3.0";
const stream = await client.tradesHttp({ version });
for await (const update of stream) {
  console.log(update);
}

Test

npm test