Fetch Orderbook Data
The depth function returns orderbook depth data in snapshots with the specified resolution over the specified time period.
from velodata import lib as velo
day_in_ms = 1000 * 60 * 60 * 24
# new velo client
client = velo.client('api_key')
# pick a supported future
futures = client.get_futures()
futures_with_orderbook_data = [f for f in futures if f['depth']]
future = futures_with_orderbook_data[0]
# last 24 hours in 5 minute resolution
params = {
'exchange': future['exchange'],
'product': future['product'],
'begin': client.timestamp() - day_in_ms,
'end': client.timestamp(),
'resolution': '5m'
}
# prints orderbook at each timestamp as it finishes
for df in client.depth(params):
print(df)