Skip to content

Instantly share code, notes, and snippets.

@ljw-612
Created November 25, 2021 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljw-612/1935b66272d9e3331258cec5ca9f7cb1 to your computer and use it in GitHub Desktop.
Save ljw-612/1935b66272d9e3331258cec5ca9f7cb1 to your computer and use it in GitHub Desktop.
# Install the API package
!pip install coinmetrics-api-client
# Import necessary packages
import pandas as pd
from coinmetrics.api_client import CoinMetricsClient
from os import environ
# Create a client use the community API key
client = CoinMetricsClient()
# Get the data we want.
# 1. Specify the market to be 'coinbase-btc-usd-spot'
# 2. Specify the start time and the end time
trades = client.get_market_trades(
markets='coinbase-btc-usd-spot',
start_time='2021-11-24T22:50:00Z',
end_time='2021-11-24T23:00:00Z'
# limit_per_market=50
)
trades_df = trades.to_dataframe()
trades_df = trades_df.reindex(index=trades_df.index[::-1])
trades_df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment