Empiric has designed compute engines that use the same raw market data underlying our price feeds, but calculate different metrics to produce feeds of processed data. We call these new feeds computational feeds. Since computational feeds operate entirely on-chain, they don't introduce any new security assumptions.
The current Empiric Network proxy addresses are:
For any price feed, Empiric offers a realized volatility feed. The realized volatility feed uses checkpoints to calculate the annualized volatility of an asset over a period of time.
How Realized Volatility is Calculated
$\sigma^2 = \frac{1}{N} \sum_{i=1}^N \frac{log(S_i / S_{i-1})^2}{(T_i - T_{i-1})}$
Where $\sigma$ is in units of $1/\sqrt{(T)}$. We then multiply $\sigma$ by $\sqrt{\Delta T_{year}}$ to get the annualized volatility of the underlying asset.
calculate_volatility
This function allows you to query realized volatility for any price feed calculated over a requested period of time. The function accesses checkpoints within the requested timeframe, and uses the above equation to calculate realized volatility.
Currently, Empiric sets a checkpoint every 5 minutes. If you need more granular data, you can set more checkpoint via the set_checkpoint
function.
pair_id
: uppercased utf8-encoded string
start_key
: timestamp at the beginning of the period over which you want to calculate realized volatility
end_key
: 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 block
num_samples
: number of samples on which you want to calculate volatility. StarkNet currently limits computation, so there is a max of 200 for this input