How to use on-chain realized volatility
calculate_volatility
set_checkpoint
function.
data_type
: enum of the data type you are requesting (See DataType structure). By providing the enum data type, you also provide the pair id (for spot entries), or the pair id and the expiration timestamp (for futures)start_tick
: timestamp at the beginning of the period over which you want to calculate realized volatilityend_tick
: timestamp at the end of the period over which you want to calculate realized volatility. If set to 0, it defaults to the timestamp of the last published blocknum_samples
: number of samples on which you want to calculate volatility. Starknet currently limits computation, so there is a max of 200 for this inputaggregation_mode
: aggregation mode to use for combining the many data sources available in Pragma. Use the structure AggregationMode defined in Pragma. Option must currently be set to MEDIAN
, MEAN
or CONVERSIONRATE
. Additional options VWAP
, EXPONENTIAL_DECAY
are coming soon.volatility
: annualized realized volatility percentage. Volatility is reported with 8 decimals of precision. To convert it to percentage, divide the output by 10^8 (e.g. 7076538586 means annualized volatility is around 70%)decimals
: number of decimals, i.e. , the number of places that value has been shifted to allow for greater accuracy.