Skip to content

Instantly share code, notes, and snippets.

@cbergz
Created February 19, 2024 18:05
Show Gist options
  • Save cbergz/aef7258a7ec601d7ac2405f554cadae9 to your computer and use it in GitHub Desktop.
Save cbergz/aef7258a7ec601d7ac2405f554cadae9 to your computer and use it in GitHub Desktop.
DEP TWAP Calculator
from pycoingecko import CoinGeckoAPI
import pandas as pd
cg = CoinGeckoAPI()
dydx_trades = cg.get_coin_ohlc_by_id("dydx", "usd", 7)
dydx_df = pd.DataFrame(dydx_trades, columns=['time', 'open', 'high', 'low', 'close'])
twap_price = dydx_df[['open', 'high', 'low', 'close']].mean(axis=None)
print(twap_price)
## Ran on Feb 19th at 18:00 UTC
## Returns 3.112674418604651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment