Ticker

A Ticker object represents a stock in the market and there are functions for you to easily access the financial data about it. For example, real-time quoting and historical prices.

Real Time Quoting

Get the real-time market price related information on that stock

import { Ticker } from 'traders';

const ticker = new Ticker('AAPL');

const result = await ticker.liveQuote();
# Example of liveQuote result
{
  open: '120.40',
  price: '121.03',
  high: '121.17',
  low: '119.16',
  volume: '88.11M',
  change: '-0.93',
  changePercent: '-0.76%'
}

Historical Prices

Get the historical prices for particular stock

import { Ticker } from 'traders';

const ticker = new Ticker('V');

// Certain combination of date range and interval are forbidden
// Example like '1m', '2021-03-01', '2021-03-15'
// Since Yahoo Finance only provide 1-min data for 7 days range
const result = await ticker.historical('1d', '2021-03-01', '2021-03-03');
# Example of historical result
[
  {
    open: 214.97000122070312,
    high: 217.8000030517578,
    low: 214.7899932861328,
    volume: 6982000,
    close: 216.6300048828125,
    date: '2021-03-01 22:30:00'
  },
  {
    open: 216.9600067138672,
    high: 217.92999267578125,
    low: 214.82000732421875,
    volume: 6153500,
    close: 215.77000427246094,
    date: '2021-03-02 22:30:00'
  }
]

Last updated