Time Series Requests

Time series data is collected by a Time Series Server (TSS), which is essentially a historical series of the changes taking place to the records in the market data tables. In addition to basic tick-by-tick and daily closing price series, the TSS also maintains intraday bar series of various periods.

The TSS can maintain a configurable amount of tick-by-tick and intraday bar history (subject to available storage space). 10 years or more of closing price history are available, depending on which stock is requested.

API access

The following interactive requests return time series data:

There are various options for filtering (e.g. removing irregular trades) and specifying the field list required in the response.

The API has flexible support for specifying time periods. Absolute time (exchange-local or UTC), trading day counts and data point counts can be used in any combination.

Time series data is adjusted for Corporate Actions (for example, splits, symbol changes), except dividends.

Common request parameters

Parameters that apply to all time series requests are defined by IRequestParameters.

Please note that relationship navigation is not used in the time series request model: the returned data always relates to the canonical key specified in the request.

Specifying periods

The range of data points in a time series request can be specified very flexibly using the periods property of the request parameters. Each IPeriod in the list has a PeriodType, and possibly a time or a count property as appropriate for the type.

The idea is that the list of periods is interpreted in chronological order, from the first entry being the oldest point in the data range to the last being the youngest.

The simple way to become familiar with the capabilities of the period list is to make some trial requests using the Explorer.

Please note an oddity of the API is that dates provided for PeriodType.exchangeLocalDateTime should be in the API's local timezone, even though they will represent times in the exchange's timezone. I.e. providing new Date(2019, 6, 17, 4, 0, 0) with PeriodType.exchangeDateLocalDateTime will specify 4am on 17th July 2019 in the exchange's timezone, not the API's local timezone. PeriodType.utcDateTime uses the Date's UTC time, so to specify 4am 17th July 2019 UTC, use new Date(Date.UTC(2019, 6, 17, 4, 0, 0)).

Note that the same is true of the returned dateTime in a IFieldSet: read it as a local time in the exchange's time zone. As such, the UTC values of that date will generally not be correct. Exchange timezone information can be queried using getExchangeInfo.

History requests

Request parameters for getHistory are defined by IHistoryRequestParameters. The additional properties are:

Here's a runnable example:

// You may have to update the userId and password fields below.
const userId = "__ACTIV_FEED_USERNAME__";
const password = "__ACTIV_FEED_PASSWORD__";
const url = "ams://cg-ny4-replay.activfinancial.com/ContentGateway:Service";

(async function() {
    try {
        console.log("Connecting...");

        const client = await activCgApi.connect({
            url,
            userId,
            password
        });

        console.log("Connected. Initiating data request...");

        // Initiate a getHistory request to the ContentGateway for daily bars.
        const requestHandle = client.timeSeries.getHistory({
            key: "MSFT.",

            // Daily bars.
            seriesType: activCgApi.TimeSeries.HistorySeriesType.dailyBars,

            // Mini bar only includes open, high, low, close and volume.
            fieldFilterType: activCgApi.TimeSeries.HistoryFieldFilterType.miniBar,

            // Get the last 5 trading days.
            periods: [
                {
                    type: activCgApi.TimeSeries.PeriodType.tradingDayCount,
                    count: 5
                },
                {
                    type: activCgApi.TimeSeries.PeriodType.now
                }
            ]
        });

        // Asynchronously iterate records.
        for await (const record of requestHandle) {
            console.log(record);
        }
    } catch (e) {
        console.error(`Error: ${e}`);
    }
})();
Try it out in the playground

Intraday requests

Request parameters for getIntraday are defined by IIntradayRequestParameters. The additional properties are:

  • seriesType: to specify 1-minute, 5-minute, or specified minute bars. See IntradaySeriesType.
  • minuteInterval: if using IntradaySeriesType.specifiedMinuteBars, then this property must be provided.
  • fieldFilterType: to filter the fields set in the returned data. See IntradayFieldFilterType.
  • recordFilterType: to filter what data is included in the calculation of each bar. See IntradayRecordFilterType.

Here's an example:

// Initiate a getIntraday request to the ContentGateway for 10 minute bars.
const requestHandle = client.timeSeries.getIntraday({
    key: "MSFT.",

    // 10 minute bars.
    seriesType: activCgApi.TimeSeries.IntradaySeriesType.specifiedMinuteBars,
    minuteInterval: 10,

    // All fields.
    fieldFilterType: activCgApi.TimeSeries.IntradayFieldFilterType.fullBar,

    // Exclude bars with only trades that do not update the last price.
    recordFilterType: activCgApi.TimeSeries.IntradayRecordFilterType.ohlcBars,

    // Get the last trading day.
    periods: [
        {
            type: activCgApi.TimeSeries.PeriodType.tradingDayCount,
            count: 1
        },
        {
            type: activCgApi.TimeSeries.PeriodType.now
        }
    ]
});

Tick requests

Request parameters for getTicks are defined by ITickRequestParameters. The additional property is:

  • recordFilterType: to filter what data is included in the calculation of returned field sets. See TickRecordFilterType.

Here's an example:

// Initiate a getTicks request to the ContentGateway for non-regular trades.
const requestHandle = client.timeSeries.getTicks({
    key: "MSFT.",

    // Non-regular trades only.
    recordFilterType: activCgApi.TimeSeries.TickRecordFilterType.nonRegularTrades,

    // Get the last hour's ticks.
    periods: [
        {
            type: activCgApi.TimeSeries.PeriodType.utcDateTime,
            date: (() => {
                let date = new Date();
                date.setHours(date.getHours() - 1);
                return date;
            })()
        },
        {
            type: activCgApi.TimeSeries.PeriodType.now
        }
    ]
});

Also in this Section