Skip to content

Customize getStats

_This page provides information on how to customize the getStats API.

Customizing getStats

Some complex named analytics are also available:

select from .tbls.cfg.analytics where tableName=`Trade, analytic in `VWAP`TWAP`turnover
tableName analytic clause
-------------------------------------------------------------------------------------------------------
Trade     VWAP     (wavg;`volume;`price)
Trade     turnover (sum;(*;`price;`volume))
Trade     TWAP     (%;(sum;(enlist;(*:;`price);(max;(max;`price));(min;(min;`price));(last;`price)));4)

Additional custom named aggregations can be added by including them with any custom configuration you are applying.

Including analytics with custom configuration

Custom named aggregations can be added to getStats with configuration in q table format. The API is looking for a table named .fsi.custom.analytics on initialization. If present, it validates and adds to configured aggregations. Validation prints any errors at initialization time and errors out before adding the configuration. The format is as follows:

Column Type Description
tableName symbol Name of the table that the analytic operates on
analytic symbol Name of the aggregation
clause mixed q functional clause

For example:

    .fsi.custom.analytics:flip `tableName`analytic`clause! flip (
        (`Trade;`custom;(wavg;`accVol;`tickCount));
        (`Quote;`custom;(sum;(*;`askSize;`bidSize)))
        );

This table can be included with any custom configuration.

Steps to add custom configuration can be found under Adding Custom Configuration or Code.