getStats (finance)

Analytics Services: Get results of analytics

Analytics

For the Finance package, there are a number of named analytics available:

Trades:                 Quotes:
  avgPrice                avgAskPrice         maxBidPrice
  avgVolume               avgAskSize          maxBidSize
  closePrice              avgBidPrice         maxMidPrice
  firstExchangeTime       avgBidSize          maxSpread
  firstInsertTime         avgMidPrice         medAskPrice
  firstPrice              avgSpread           medAskSize
  firstVolume             firstAskPrice       medBidPrice
  lastExchangeTime        firstAskSize        medBidSize
  lastInsertTime          firstBidPrice       medMidPrice
  lastPrice               firstBidSize        medSpread
  lastVolume              firstExchangeTime   minAskPrice
  maxPrice                firstInsertTime     minAskSize
  maxVolume               firstMidPrice       minBidPrice
  medPrice                firstSpread         minBidSize
  medVolume               lastAskPrice        minMidPrice
  minPrice                lastAskSize         minSpread
  minVolume               lastBidPrice        quoteCount
  openPrice               lastBidSize         sumAskPrice
  return                  lastExchangeTime    sumAskSize
  sumPrice                lastInsertTime      sumBidPrice
  sumVolume               lastMidPrice        sumBidSize
  tradeCount              lastSpread          sumMidPrice
  turnover                maxAskPrice         sumSpread
  TWAP                    maxAskSize
  VWAP

The analytics above are named after the aggregate keyword and the column to which it is applied. For example, maxVolume is equivalent to (max;`Volume). The above list is indicative, not exhaustive. Additional analytics will continue to be added.

Opening and closing prices

Both opening and closing prices are dynamically extracted from the real-time market data feed and inserted into the openClose table. getStats retrieves the open and close prices from these tables rather than extracting them from the tick data.

Trade analytics

Analytic Result Datatype
avgPrice average price for the specified time interval float
avgVolume average volume for the specified time interval float
closePrice day close price float
firstExchangeTime first exchange time for the specified time interval. Exchange Time is the time value of a record as given by the relevant exchange timestamp
firstInsertTime first insert time for the specified time interval. Insert Time is the time at which a record is ingested by Refinery timestamp
firstPrice first available price for the specified time interval float
firstVolume first available volume for the specified time interval long
lastExchangeTime last exchange time for the specified time interval. Exchange Time is the time value of a record as given by the relevant exchange timestamp
lastInsertTime last insert time for the specified time interval. Insert Time is the time at which a record is ingested by Refinery timestamp
lastPrice last available price for the specified time interval float
lastVolume last available volume for the specified time interval long
maxPrice maximum available price for the specified time interval float
maxVolume maximum volume for the specified time interval long
medPrice median price for the specified time interval float
medVolume median volume for the specified time interval float
minPrice minimum price for the specified time interval float
minVolume minimum volume for the specified time interval long
openPrice day open price float
return return of the last price compared to the close price, where
return = (lastPrice - closePrice)/closePrice
float
sumPrice sum of the prices for the specified time interval float
sumVolume sum of the volumes for the specified time interval long
tradeCount number of trades for the specified interval long
turnover turnover of specified time interval: the sum of all the prices times the volumes for the given interval float
TWAP Time-Weighted Average Price for the specified time interval float
VWAP Volume-Weighted Average Price for the specified time interval float

Quote analytics

Analytic Result Datatype
avgAskPrice average ask price for the specified time interval float
avgAskSize average ask size for the specified time interval float
avgBidPrice average bid price for the specified time interval float
avgBidSize average bid size for the specified time interval float
avgMidPrice average mid-price for the specified time interval float
avgSpread average spread for the specified time interval float
firstAskPrice first available ask price for the specified time interval float
firstAskSize first available ask size for the specified time interval long
firstBidPrice first available bid price for the specified time interval float
firstBidSize first available bid size for the specified time interval long
firstExchangeTime first exchange time for the specified time interval timestamp
firstInsertTime first insert time for the specified time interval timestamp
firstMidPrice first mid-price for the specified time interval float
firstSpread first spread for the specified time interval float
lastAskPrice last available ask price for the specified time interval float
lastAskSize last available ask size for the specified time interval long
lastBidPrice last available bid price for the specified time interval float
lastBidSize last available bid size for the specified time interval long
lastExchangeTime last exchange time for the specified time interval timestamp
lastInsertTime last insert time for the specified time interval timestamp
lastMidPrice last mid-price for the specified time interval float
lastSpread last spread for the specified time interval float
maxAskPrice maximum ask price for the specified time interval float
maxAskSize maximum ask size for the specified time interval long
maxBidPrice maximum bid price for the specified time interval float
maxBidSize maximum bid size for the specified time interval long
maxMidPrice maximum mid-price for the specified time interval float
maxSpread max spread for the specified time interval float
medAskPrice median ask price for the specified time interval float
medAskSize median ask size for the specified time interval float
medBidPrice median bid price for the specified time interval float
medBidSize median bid size for the specified time interval float
medMidPrice median mid-price for the specified time interval float
medSpread median spread for the specified time interval float
minAskPrice minimum ask price for the specified time interval float
minAskSize minimum ask size for the specified time interval long
minBidPrice minimum bid price for the specified time interval float
minBidSize minimum bid size for the specified time interval long
minMidPrice minimum mid-price for the specified time interval float
minSpread min spread for the specified time interval float
quoteCount total number of quotes in the specified time interval long
sumAskPrice sum total of the ask prices for the specified time interval float
sumAskSize sum total of the ask sizes for the specified time interval long
sumBidPrice sum total of the bid prices for the specified time interval float
sumBidSize sum total of the ask sizes for the specified time interval long
sumMidPrice sum total of the mid-prices for the specified time interval float
sumSpread sumtotal of the spreads for the specified time interval float

Do not validate

Key doNotValidate optional Value parameter symbol vector

Example `analytics

Default none

Disables pre-processing parameter validation checks for the specified parameters. For supported parameters, see Parameter Validation

Examples

getStats .[!]flip(
    (`symList    ;`VOD.L`BARC.L`AZN.L);
    (`dataType   ;`quote);
    (`startDate  ;2016.05.24);
    (`endDate    ;2016.05.24);
    (`startTime  ;12:00:00.000);
    (`endTime    ;13:00:00.000);
    (`timeZone   ;`$"Europe/London");
    (`assetclass ;`equity);
    (`temporality;`slice);
    (`filterRule ;`default);
    (`analytics  ;`avgBidPrice`avgAskPrice`quoteCount)
  )

Returns average bid prices, average ask price, number of quotes for VOD.L, BARC.L, AZN.L between 12:00 and 13:00 on the 24th of May.

getStats .[!]flip(
    (`symList        ;`1BON6);
    (`dataType       ;`quote);
    (`startDate      ;2020.03.31);
    (`endDate        ;2020.03.31);
    (`startTime      ;09:00:00.000);
    (`endTime        ;12:00:00.000);
    (`timeZone       ;`$"Europe/London");
    (`assetClass     ;`future);
    (`temporality    ;`slice);
    (`filterRule     ;`default);
    (`granularity    ;1);
    (`granularityUnit;`hour);
    (`analytics      ;`avgBidPrice`avgAskPrice)
  )

Returns average bid and ask prices for 1BON6 between 09:00 and 12:00 on today's date. The returned data is at a 1-hour granularity interval – showing average prices for each hour between 09:00 and 12:00.

getStats .[!]flip(
    (`symList    ;`1EDZ6`1EDM6`1EDU6);
    (`dataType   ;`quote);
    (`startDate  ;2020.03.31);
    (`endDate    ;2020.03.31);
    (`startTime  ;09:00:00.000);
    (`endTime    ;12:00:00.000);
    (`timeZone   ;`$"Europe/London");
    (`assetClass ;`future);
    (`temporality;`slice);
    (`filterRule ;`default);
    (`analytics  ;`avgBidPrice`avgAskPrice)
  )

Returns average bid and ask prices for 1EDZ6, 1EDM6 and 1EDU6 between 09:00 and 12:00

getStats .[!]flip(
    (`symList        ;`);
    (`dataType       ;`trade);
    (`startDate      ;2020.03.31);
    (`endDate        ;2020.03.31);
    (`startTime      ;09:00:00.000);
    (`endTime        ;09:01:00.000);
    (`timeZone       ;`$"Europe/London");
    (`assetClass     ;`future);
    (`granularity    ;1);
    (`granularityUnit;`second);
    (`temporality    ;`slice);
    (`filterRule     ;`default);
    (`analytics      ;`avgPrice`avgVolume)
  )

Returns average price and average volume of each futures instrument traded between 09:00 and 09:01 London time, calculated at a one-second granularity.

getStats .[!]flip(
    (`symList        ;`);
    (`dataType       ;`trade);
    (`startDate      ;2020.03.30);
    (`endDate        ;2020.03.30);
    (`startTime      ;09:00:00.000);
    (`endTime        ;10:00:00.000);
    (`timeZone       ;`$"Europe/London");
    (`assetClass     ;`equity);
    (`granularity    ;1);
    (`granularityUnit;`hour);
    (`temporality    ;`slice);
    (`filterRule     ;`default);
    (`analytics      ;`VWAP)
  )

Returns Volume-Weighted Average Price (VWAP) for all equity products traded yesterday (.z.d-1) between 09:00 and 10:00.

getStats .[!]flip(
    (`symList        ;`.FTSE);
    (`dataType       ;`trade);
    (`startDate      ;2020.03.30);
    (`endDate        ;2020.03.30);
    (`startTime      ;09:00:00.000);
    (`endTime        ;16:00:00.000);
    (`timeZone       ;`$"Europe/London");
    (`assetClass     ;`index);
    (`granularity    ;1);
    (`granularityUnit;`hour);
    (`temporality    ;`slice);
    (`filterRule     ;`default);
    (`analytics      ;`VWAP);
    (`fill           ;`zero)
  )

Returns VWAP for .FTSE between 09:00 and 16:00 yesterday in London time at a one-hour granularity. The fill parameter means any hour that does not have the required data will be filled with zeros.

getStats .[!]flip(
    (`symList        ;`VOD.L`BARC.L`AZN.L);
    (`dataType       ;`trade);
    (`startDate      ;2020.03.30);
    (`endDate        ;2020.03.30);
    (`startTime      ;09:00:00.000);
    (`endTime        ;16:00:00.000);
    (`timeZone       ;`$"Europe/London");
    (`assetClass     ;`equity);
    (`granularity    ;1);
    (`granularityUnit;`hour);
    (`temporality    ;`slice);
    (`filterRule     ;`default);
    (`analytics      ;`VWAP);
    (`fill           ;`forward)
  )

Returns VWAP for .FTSE between 09:00 and 16:00 yesterday in London time at a one-hour granularity. The fill argument means any hour that does not have the required data will be forward-filled by the most recent non-null value.