Skip to main content

Stats

An interface to store and track time-series statistics. There are several system level statistics already tracked, which can be viewed over at Stats module (Grafana). However, this interface allows users to measure and track their own statistics throughout the life-cycle of the algo server. Stats methods do not take 'symbol' as a parameter because they are meant to apply to system as a whole. If want to track stats per individual symbol, you can just name the measurements appropriately, i.e. Stats.push('AMC-interval', 19.8);

Stats.push#

Stats.push(measurement, value)

Stores a specified measurement as time-series measurement with the current timestamp. The storage database of choice is InfluxDB and visualization is done with Grafana dashboard which can be accessed on the main screen (Stats)

Parameters#

ParameterTypeDescription
measurementStringthe name of the measurement (be careful about spelling errors)
valueNumbera numeric value for the measurement

Return values#

None

var time1 = (new Date()).getTime();
//
// ... do something time intensive
//
var time2 = (new Date()).getTime();
Stats.push("timeToComplete", time2 - time1);

Stats.tag#

Works just like Stats.push above but allows for tagging measurements with additional metadata.

Stats.tag(measurement, value, tagName, tagValue)

Parameters#

ParameterTypeDescription
measurementStringthe name of the measurement (be careful about spelling errors)
valueNumbera numeric value for the measurement
tagNameStringAn additional tag for the measurement (may come handy for queries)
tagValueStringA value associated with the tag

Return values#

None

var time1 = (new Date()).getTime();
//
// ... do something time intensive
//
var time2 = (new Date()).getTime();
Stats.push("timeToComplete", time2 - time1, "symbol", "AMC");