Skip to content
Velo

Fetch Spot-Vol Correlation

from velodata import lib as velo
 
day_in_ms = 1000 * 60 * 60 * 24
 
# new velo client
client = velo.client('api_key')
 
# from 5 days ago in 1 hour resolution
params = {
    'type': 'options',
    'columns': ['dvol_close', 'index_price'],
    'exchanges': ['deribit'],
    'products': ['BTC'],
    'begin': client.timestamp() - day_in_ms * 5,
    'end': client.timestamp(),
    'resolution': '1h'
}
 
# returns dataframe
df = client.get_rows(params)
 
# simple rolling 24 hour correlation
print(
    df['dvol_close'].pct_change().rolling(24).corr(
        df['index_price'].pct_change()
    )
)