Skip to main content

Comparing Volumes of Exchanges and Assets

Though decentralized finance has garnered significant attention in recent years, centralized exchanges remain a crucial cornerstone of the crypto asset industry. These trading venues serve as some of the deepest pools of liquidity for the top crypto assets, and facilitate the onboarding and offboarding of millions of users by sitting at the intersection of digital assets and fiat currencies. Coin Metrics collects a wide variety of data from a universe of 39+ top crypto exchanges, allowing our users to easily assess exchange dominance, asset trading volumes, and even the composition of trading patterns in specific markets.

Resources​

This notebook demonstrates basic functionality offered by the Coin Metrics Python API Client and Market Data Feed.

Coin Metrics offers a vast assortment of data for hundreds of cryptoassets. The Python API Client allows for easy access to this data using Python without needing to create your own wrappers using requests and other such libraries.

To understand the data that Coin Metrics offers, feel free to peruse the resources below.

File Download​

Download the entire notebook as either a jupyter notebook to run yourself or as a pdf from the two links below

Download MDF_exchange_volume.ipynb

Download MDF_exchange_volume.pdf

Notebook Setup​

from os import environ
import sys
import pandas as pd
import numpy as np
import logging
from datetime import date, datetime, timedelta
from coinmetrics.api_client import CoinMetricsClient
import json
import logging
import matplotlib.pyplot as plt
# import plotly.express as px
# import seaborn as sns
# %matplotlib inline
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S'
)
# We recommend privately storing your API key in your local environment.
try:
api_key = environ["CM_API_KEY"]
logging.info("Using API key found in environment")
except KeyError:
api_key = ""
logging.info("API key not found. Using community client")
client = CoinMetricsClient(api_key)
2024-10-07 12:48:33 INFO Using API key found in environment

Daily Exchange Volumes​

Coin Metrics creates aggregated metrics to allow users to easily compare the total trading volume of dominant centralized exchanges. By leveraging the timeseries/exchange-metrics endpoint, we can retrieve the daily reported spot trading volume for a single trading venue or a list of exchanges.

end = pd.to_datetime(datetime.now())
start = end - timedelta(days=28)
exchange_list = [
e['exchange'] for e in client.get_snapshots_of_asset_metric_constituents(
'volume_trusted_spot_usd_1d', at_time=end
).to_list()
]
volumes = client.get_exchange_metrics(
exchanges=exchange_list,
metrics='volume_reported_spot_usd_1d',
frequency='1d',
start_time=start,
end_time=end
).to_dataframe()
top_volumes = volumes.groupby('exchange')['volume_reported_spot_usd_1d'].sum().sort_values(ascending=False)
volumes['exchange'] = np.where(volumes['exchange'].isin(top_volumes[:8].index), volumes['exchange'], 'other')
volumes = volumes.groupby(['exchange', 'time'])[['volume_reported_spot_usd_1d']].sum().reset_index()
exchange_list_truncated = list(volumes.exchange.unique())

pivot_volumes = volumes.pivot(
index="time",
columns="exchange",
values="volume_reported_spot_usd_1d"
)
pivot_volumes.head()
exchangebinancebullishbybitcoinbasecrypto.comgate.iohuobiokexother
time
2024-09-10 00:00:00+00:009714347717.472661264837837.16393667152874.201691323434212.378034694543620.14163845127903.4621621605960239.921271293157356.510021340992725.680607
2024-09-11 00:00:00+00:0012274439317.7852991102465276.624744522846470.922851706654989.730287265287964.563011116958520.426751758439622.214221589552806.981921766919607.712266
2024-09-12 00:00:00+00:0011296654011.8449991071014247.325794144560926.663791781063003.2814845335792.934721035902360.918031640974256.921281418484926.00311631462282.025268
2024-09-13 00:00:00+00:0011925481195.4529991073344439.249674164462938.089541832416834.758934559652705.029261060397918.392751602703737.97291544920512.397721847874572.934688
2024-09-14 00:00:00+00:006374474955.75626391985441.7229832230639306.761541137971743.14381992728998.68231587007576.0281091267693924.07889961073483.60885870317615.504417
pivot_volumes[exchange_list_truncated]
exchangebinancebullishbybitcoinbasecrypto.comgate.iohuobiokexother
time
2024-09-10 00:00:00+00:009714347717.472661264837837.16393667152874.201691323434212.378034694543620.14163845127903.4621621605960239.921271293157356.510021340992725.680607
2024-09-11 00:00:00+00:0012274439317.7852991102465276.624744522846470.922851706654989.730287265287964.563011116958520.426751758439622.214221589552806.981921766919607.712266
2024-09-12 00:00:00+00:0011296654011.8449991071014247.325794144560926.663791781063003.2814845335792.934721035902360.918031640974256.921281418484926.00311631462282.025268
2024-09-13 00:00:00+00:0011925481195.4529991073344439.249674164462938.089541832416834.758934559652705.029261060397918.392751602703737.97291544920512.397721847874572.934688
2024-09-14 00:00:00+00:006374474955.75626391985441.7229832230639306.761541137971743.14381992728998.68231587007576.0281091267693924.07889961073483.60885870317615.504417
2024-09-15 00:00:00+00:007361704730.28157562957320.7115112590884166.76392832798774.7668782931984212.55974760804668.5528381124162599.40243997351542.1483141032771425.499747
2024-09-16 00:00:00+00:0012134299152.84191060106347.585184165725283.3181361649870.775834722670462.419821191365703.761541583872653.479731593737943.296781535830455.197682
2024-09-17 00:00:00+00:0012784370854.81811370902890.667984599028084.11071783827256.96484323879290.277911164978755.285121572931912.754031735321786.522751939514486.618056
2024-09-18 00:00:00+00:0013949094048.2956011509743657.169335191983189.973711812085945.131326524939071.870541588197115.857481677643847.702912025256403.677542131259660.134958
2024-09-19 00:00:00+00:0015765392190.6924991319652147.969475525980769.225842541879532.524255235187763.937851887336656.88171975000649.308772390932500.796712569561724.497508
2024-09-20 00:00:00+00:0015637079381.66931265080412.997044627547221.999591976169614.447875064003012.659211629840500.883591700075845.885662139950015.811742114986008.292456
2024-09-21 00:00:00+00:007239200803.06984459895539.0583032482619303.48854742642406.8409012411519153.63723833998109.2451231087714374.93748952109526.988626991526560.843603
2024-09-22 00:00:00+00:009068630508.16427802099932.545483151837904.3863963747563.9895233502445418.964811052501821.183611171972957.837521286837506.194081177308035.41588
2024-09-23 00:00:00+00:0014119038812.0175991329762723.442724669434414.701671776058068.848265796920448.023941604826350.386271572446737.447421883576140.482512059560504.183348
2024-09-24 00:00:00+00:0013803897941.44591233617827.372244623955823.489511889015003.756084560270564.106111531245791.354881499667822.705572074103404.060312043368536.120572
2024-09-25 00:00:00+00:0011243478001.82341056276031.712224504151719.142961543860513.038473791679743.586981510723332.356411492906823.756841894745371.911621159844.139992
2024-09-26 00:00:00+00:0015599762219.37711610121770.78685623746968.562712281290095.104166042193867.254631884280762.684631716777384.932892384946966.645382319230690.451392
2024-09-27 00:00:00+00:0014116726844.8188991069480100.139795160096066.062452558606461.874925638677750.919471018072023.288321716844603.369352342997486.180922064558204.748724
2024-09-28 00:00:00+00:008159304277.82764502782942.6549922694065736.76692964628082.6254742081725893.72908677192203.1692881195274976.6031451311955.47487941584508.956109
2024-09-29 00:00:00+00:008921640553.12451539803911.6329832538588361.133291024493096.081312706231391.93362900547717.9148621067935423.380931460065096.94411018404267.377896
2024-09-30 00:00:00+00:0015202552937.9983011342394442.656254937717476.118332111602915.236056422163849.55781370536947.446361595747524.909842388331950.39122037584661.361227
2024-10-01 00:00:00+00:0023240548408.5847023184757131.551577759540621.791893415548316.380068959183206.5125692137805079.145371908358048.629523470705407.361972871101695.353822
2024-10-02 00:00:00+00:0017437229519.5136991603025104.857055526619243.093432352353661.750568743651625.5250891815221539.442251956203879.595612356068415.413752205618738.858672
2024-10-03 00:00:00+00:0014999111682.61521605418668.375045120501662.456911930904616.177418193532164.495631538014044.6731771828990.694222116511967.712811889111631.496463
2024-10-04 00:00:00+00:0012876175910.4162011332886726.351174279900711.687871918812943.461795759795028.967881280488009.449461437592080.676711697775201.175121770689490.345348
2024-10-05 00:00:00+00:006532364228.97254392462635.0066912126069409.03706608167606.664071872894569.02638594321770.03637965511857.476451815970303.962524705386770.661552
2024-10-06 00:00:00+00:006930843434.83285444045828.2104642046183278.08736679562882.1404942229413627.75299661460021.074824882202743.119424951842866.408241823568622.1757
def format_ticks_usd(y, pos):
if y >= 1_000_000_000_000:
return '${:.1f}T'.format(y/1000000000000)
elif y >= 1_000_000_000:
return '${:.1f}B'.format(y/1000000000)
elif y >= 1000000:
return '${:.1f}M'.format(y/1000000)
elif y >= 1000:
return '${:.1f}K'.format(y/1000)
else:
return '${:.1f}'.format(y)

fig, ax = plt.subplots(figsize=(8,6))

ax.stackplot(
pivot_volumes.index,
[pivot_volumes[exchange].astype(float) for exchange in exchange_list_truncated],
labels=exchange_list_truncated,
)
ax.set_title("Total Exchange Volume")
ax.yaxis.set_major_formatter(format_ticks_usd)
ax.yaxis.grid(visible=True, which='major', linestyle='--', alpha=0.5)
ax.legend(loc='lower right', bbox_to_anchor=(1.25, 0), title="Exchange")
ax.tick_params(axis='x', labelrotation=45)
ax.xaxis.set_major_locator(plt.MaxNLocator(4))
ax.set_xlim(volumes.time.min(), volumes.time.max())
pivot_volume_share = 100*pivot_volumes[exchange_list_truncated].div(pivot_volumes[exchange_list_truncated].sum(axis=1), axis=0)
import matplotlib.ticker as mtick


fig, ax = plt.subplots(figsize=(8,6))

ax.stackplot(
pivot_volume_share.index,
[pivot_volume_share[exchange].astype(float) for exchange in exchange_list_truncated],
labels=exchange_list_truncated,
)
ax.set_title("Exchange Volume Share")
ax.yaxis.set_major_formatter(mtick.PercentFormatter())
ax.yaxis.grid(visible=True, which='major', linestyle='--', alpha=0.5)
ax.legend(loc='lower right', bbox_to_anchor=(1.25, 0), title="Exchange")
ax.tick_params(axis='x', labelrotation=45)
ax.xaxis.set_major_locator(plt.MaxNLocator(4))
ax.set_xlim(volumes.time.min(), volumes.time.max())
ax.set_ylim(0, 100)

Asset Share​

In addition to retrieving aggregated trading volumes for all markets on an exchange, we can also utilize the timeseries/market-candles to obtain the USD trading volume of individual markets on a particular exchange.

# The wildcard parameter (*) enables users to retrieve all markets matching the designated format
exchange = 'coinbase'
markets=f"{exchange}-*-spot"
df = client.get_market_candles(
markets=markets,
start_time=start,
end_time=end,
frequency='1d',
page_size=10000
).parallel(time_increment=timedelta(days=1)).to_dataframe()
Exporting to dataframe type: 79%|███████████████████████████████████████▎ | 22/28 [00:02<00:00, 10.38it/s]2024-10-07 12:48:38 INFO no data to export
Exporting to dataframe type: 100%|██████████████████████████████████████████████████| 28/28 [00:02<00:00, 9.86it/s]
df
markettimeprice_openprice_closeprice_highprice_lowvwapvolumecandle_usd_volumecandle_trades_count
0coinbase-00-usd-spot2024-09-10 00:00:00+00:000.03690.03610.03930.0360.0373494538849.98169520.0737091586
1coinbase-1inch-btc-spot2024-09-10 00:00:00+00:000.0000050.0000050.0000050.0000050.00000514287.413720.28015921
2coinbase-1inch-eur-spot2024-09-10 00:00:00+00:000.2380.2370.2390.2320.236182616552.97160541.151569271
3coinbase-1inch-gbp-spot2024-09-10 00:00:00+00:000.2010.1990.2010.1960.199207358978.9493500.859211194
4coinbase-1inch-usd-spot2024-09-10 00:00:00+00:000.2630.260.2640.2560.2597553483735.74904916.714912772
.................................
11027coinbase-zen-usd-spot2024-10-06 00:00:00+00:007.498.018.047.497.7266373059.79223641.90321243
11028coinbase-zeta-usd-spot2024-10-06 00:00:00+00:000.59640.60840.61210.58150.59916666852.1399550.776253258
11029coinbase-zk-usd-spot2024-10-06 00:00:00+00:000.124320.129040.130470.124090.126848562305.171327.114648462
11030coinbase-zro-usd-spot2024-10-06 00:00:00+00:004.1094.2364.2534.0674.162722119387.31496976.156161341
11031coinbase-zrx-usd-spot2024-10-06 00:00:00+00:000.3094970.3239020.3239020.3072550.317242599437.77086190166.8855331235

11032 rows × 10 columns

df["candle_usd_volume"] = df.candle_usd_volume.astype(float)
df["time"] = pd.to_datetime(df.time)
df.sort_values(["market","time"],inplace=True)

# Create Addt. Cols
df['exchange'] = df.market.apply(lambda x: x.split("-")[0])
df['exchange-base'] = df.market.apply(lambda x: x.split("-")[0]+"-"+x.split("-")[1])
df['market_type'] = df.market.apply(lambda x: x.split("-")[-1])
df['base'] = df.market.apply(lambda x: x.split("-")[1])
df['quote'] = df.market.apply(lambda x: x.split("-")[2])

# Get volume by base asset by day

# Get top 10 assets by volume
total_vol_by_base = df.groupby('base',as_index=False).candle_usd_volume.sum()
total_vol_by_base.sort_values(by="candle_usd_volume",inplace=True)
base_top_list = total_vol_by_base.tail(10).base.tolist()
df["base2"] = np.where(df.base.isin(base_top_list),df.base,f"{len(total_vol_by_base)-10} others")

# Get sum by base asset by day
df_vol_by_base = df.groupby(["time","base2"],as_index=False).candle_usd_volume.sum()
df_vol_by_base['total_vol'] = df_vol_by_base.groupby("time").candle_usd_volume.transform(sum)
df_vol_by_base.columns=["time","base_asset","vol","total_vol"]
df_vol_by_base["vol_pct"]=(df_vol_by_base.vol/df_vol_by_base.total_vol)*100
df_vol_by_base.sort_values(["base_asset","time"],inplace=True)
df_vol_by_base
timebase_assetvoltotal_volvol_pct
02024-09-10 00:00:00+00:00248 others2.285934e+081.325089e+0917.251175
112024-09-11 00:00:00+00:00248 others2.546721e+081.708684e+0914.904575
222024-09-12 00:00:00+00:00248 others2.478359e+081.783317e+0913.897469
332024-09-13 00:00:00+00:00248 others2.823741e+081.834706e+0915.390699
442024-09-14 00:00:00+00:00248 others1.710470e+081.139076e+0915.016301
..................
2522024-10-02 00:00:00+00:00xrp1.025636e+082.355545e+094.354134
2632024-10-03 00:00:00+00:00xrp8.681132e+071.934456e+094.487634
2742024-10-04 00:00:00+00:00xrp4.813218e+071.924832e+092.500591
2852024-10-05 00:00:00+00:00xrp1.525881e+076.100742e+082.501140
2962024-10-06 00:00:00+00:00xrp1.258580e+076.807883e+081.848710

297 rows × 5 columns

num_assets = len(total_vol_by_base)
top_assets = df_vol_by_base[~df_vol_by_base.base_asset.isin(["btc","eth",f"{num_assets-10} others"])].groupby("base_asset").vol.sum().sort_values(ascending=False).index.tolist()
top_assets = ["btc","eth",f"{num_assets-10} others"] + top_assets

# Pivot back to assets in columns
df_vol_pivot = df_vol_by_base.pivot(index='time',
columns="base_asset",
values="vol_pct")

df_vol_pivot = df_vol_pivot[top_assets]
df_vol_pivot
base_assetbtceth248 othersusdtsolsuixrpbonkdogeshibfet
time
2024-09-10 00:00:00+00:0030.97214913.06744617.25117524.9459506.1467311.2924791.1178071.0954191.1763070.5052092.429329
2024-09-11 00:00:00+00:0042.53309814.60127914.90457516.5080545.4093470.9866930.8595030.9182631.0868480.5104671.681872
2024-09-12 00:00:00+00:0036.05590311.24640513.89746924.4721155.4321462.3235822.7687700.6865770.8970560.3172871.902690
2024-09-13 00:00:00+00:0041.60048212.46963215.39069917.6870485.3966641.2831561.7446600.6395772.0294110.4382101.320460
2024-09-14 00:00:00+00:0018.1045497.16994815.01630146.8559374.1187001.8426873.2107860.8530401.3478430.4695071.010702
2024-09-15 00:00:00+00:0031.12505116.34849122.99683710.3917167.6481903.7476062.4546361.2444481.5277480.5435001.971777
2024-09-16 00:00:00+00:0037.19387417.20618614.86656017.1641955.4162182.0697752.0748280.7354511.2924250.4824451.498044
2024-09-17 00:00:00+00:0043.46280513.12219314.03960816.8770174.8062212.6393381.3386550.6170461.5270540.3047941.265270
2024-09-18 00:00:00+00:0042.57894514.38916016.36353410.7590896.3677824.1614221.5419830.6895651.0256030.5041581.618760
2024-09-19 00:00:00+00:0040.55435511.91376016.69787313.9905237.9228743.0514381.4191951.0716191.0163500.6195021.742510
2024-09-20 00:00:00+00:0037.44964713.96616317.36161313.2701938.2675773.2947781.6935001.1564771.1831910.5080401.848821
2024-09-21 00:00:00+00:0018.08312617.64752128.82294911.7179057.5030454.0025903.3991641.9883372.7628441.6467012.425818
2024-09-22 00:00:00+00:0021.30780412.65831826.45163617.4947547.3989477.1189062.2688501.1222231.4431691.1734591.561934
2024-09-23 00:00:00+00:0028.06201317.66716523.86844013.8617106.5949814.0930831.5687480.6549691.2795640.5473871.801941
2024-09-24 00:00:00+00:0033.09402916.22986021.21801210.3616138.6808764.2900911.5151160.9332011.2907900.5891671.797243
2024-09-25 00:00:00+00:0027.40490614.14450524.53090514.9852926.6725374.8672931.4588991.8156781.2181821.5963751.305427
2024-09-26 00:00:00+00:0039.1771609.94060919.49671411.1094526.3684703.4486741.4424501.6902032.3789294.1528330.794507
2024-09-27 00:00:00+00:0026.76693511.66084217.98337423.7779465.3857912.3431621.3944742.9648852.6095854.0885191.024488
2024-09-28 00:00:00+00:0020.2307638.00378228.1345259.9492525.9243452.5262985.7949795.2327255.8588646.7833511.561114
2024-09-29 00:00:00+00:0018.9386148.16961025.58688912.1725588.4806276.5019597.4996834.0495263.3237464.0290561.247732
2024-09-30 00:00:00+00:0035.24346310.55516717.24321715.9491955.0599583.8537982.8015143.9267002.0077232.2838441.075420
2024-10-01 00:00:00+00:0031.63266612.95697615.57816519.1524256.9073274.0172892.2041733.2740451.5614031.6027771.112754
2024-10-02 00:00:00+00:0025.28150811.47400016.97884020.7363727.4661115.5706984.3541343.8185781.5357131.6644151.119630
2024-10-03 00:00:00+00:0027.77923410.98239419.68153913.2323347.5750488.6865704.4876343.9145501.5091321.2662150.885351
2024-10-04 00:00:00+00:0027.7442489.43538818.42615422.7156536.2937915.6230552.5005912.8826261.6191081.7612270.998159
2024-10-05 00:00:00+00:0019.6591088.42740929.77095514.6149176.7185456.9555542.5011403.3044752.2286123.5361272.283157
2024-10-06 00:00:00+00:0020.9934497.61776428.48686714.2679446.8445858.2556161.8487103.9456312.1454864.2234521.370494
fig, ax = plt.subplots(figsize=(8,6))

ax.stackplot(
df_vol_pivot.index,
[df_vol_pivot[asset].astype(float) for asset in df_vol_by_base.base_asset.unique()],
labels=df_vol_by_base.base_asset.unique(),
)
ax.set_title("Asset Volume Share")
ax.yaxis.set_major_formatter(mtick.PercentFormatter())
ax.yaxis.grid(visible=True, which='major', linestyle='--', alpha=0.5)
ax.legend(loc='lower right', bbox_to_anchor=(1.25, 0), title="Asset")
ax.tick_params(axis='x', labelrotation=45)
ax.xaxis.set_major_locator(plt.MaxNLocator(4))
ax.set_xlim(volumes.time.min(), volumes.time.max())
ax.set_ylim(0, 100)

Retrieve Trade Sizes​

Trade size is a useful metric for understanding the composition of an exchange's trading patterns. Is the platform more popular for retail traders, or large institutions? Which assets are driven by whale trades vs. small buys? These patterns are especially relevant for venues like Coinbase, where fee revenue is determined by trade size.

def get_trade_size_stats(start,end,market):
"""
For a given date and market, get stats on number of trades and dist of trade sizes
Returns a df with:
Number of trades
Volume (USD/Native)
Number of trades by size groupings
Volume derived from trades of various size groupings
"""

#Call api
df_trades = client.get_market_trades(
markets=market,
start_time=start,
end_time=end,
page_size=10000
).parallel(time_increment=timedelta(hours=1)).to_dataframe()
#Prep data
df_trades["amount_usd"] = df_trades.amount*df_trades.price
df_trades["amount_usd_groups"] = pd.cut(df_trades["amount_usd"],bins=[0,1e3,1e4,1e5,1e6,1e7,1e100])
print(df_trades.time.min())
print(df_trades.time.max())

#Get stats by group
sum_count_by_size = df_trades.groupby("amount_usd_groups").agg({"amount_usd":['count',sum]})

#Collect into a df
df_day = pd.DataFrame()

df_day.loc[start,"NumTrades"] = len(df_trades)
df_day.loc[start,"VolUSD"] = df_trades.amount_usd.sum()
df_day.loc[start,"VolNTV"] = df_trades.amount.sum()

df_day.loc[start,"AvgSizeUSD"] = df_trades.amount_usd.mean()
df_day.loc[start,"MedSizeUSD"] = df_trades.amount_usd.median()
df_day.loc[start,"MaxSizeUSD"] = df_trades.amount_usd.max()

df_day.loc[start,"NumTrades_0-1K"] = sum_count_by_size.iloc[0,0]
df_day.loc[start,"NumTrades_1K-10K"] = sum_count_by_size.iloc[1,0]
df_day.loc[start,"NumTrades_10K-100K"] = sum_count_by_size.iloc[2,0]
df_day.loc[start,"NumTrades_100K-1M"] = sum_count_by_size.iloc[3,0]
df_day.loc[start,"NumTrades_1M-10M"] = sum_count_by_size.iloc[4,0]
df_day.loc[start,"NumTrades_10M-Over"] = sum_count_by_size.iloc[5,0]

df_day.loc[start,"VolUSD_Trades_0-1K"] = sum_count_by_size.iloc[0,1]
df_day.loc[start,"VolUSD_Trades_1K-10K"] = sum_count_by_size.iloc[1,1]
df_day.loc[start,"VolUSD_Trades_10K-100K"] = sum_count_by_size.iloc[2,1]
df_day.loc[start,"VolUSD_Trades_100K-1M"] = sum_count_by_size.iloc[3,1]
df_day.loc[start,"VolUSD_Trades_1M-10M"] = sum_count_by_size.iloc[4,1]
df_day.loc[start,"VolUSD_Trades_10M-Over"] = sum_count_by_size.iloc[5,1]

return df_day
start = datetime.today() - timedelta(hours=24)
end = datetime.today()
df = get_trade_size_stats(start, end,'coinbase-btc-usd-spot')
Exporting to dataframe type: 44%|██████████████████████ | 11/25 [00:02<00:02, 6.99it/s]2024-10-07 12:48:43 INFO no data to export
Exporting to dataframe type: 100%|██████████████████████████████████████████████████| 25/25 [00:04<00:00, 5.16it/s]

2024-10-06 12:48:39.766637+00:00
2024-10-07 12:48:31.860605+00:00


df.head()
NumTradesVolUSDVolNTVAvgSizeUSDMedSizeUSDMaxSizeUSDNumTrades_0-1KNumTrades_1K-10KNumTrades_10K-100KNumTrades_100K-1MNumTrades_1M-10MNumTrades_10M-OverVolUSD_Trades_0-1KVolUSD_Trades_1K-10KVolUSD_Trades_10K-100KVolUSD_Trades_100K-1MVolUSD_Trades_1M-10MVolUSD_Trades_10M-Over
2024-10-06 12:48:39.638626233725.02.681840e+084249.993841147.43405248.436912475567.911314187168.041234.05278.045.00.00.01.983836e+071.350884e+081.056560e+087.601298e+060.00.0
df.transpose()#.rename_axis('value')
2024-10-06 12:48:39.638626
NumTrades2.337250e+05
VolUSD2.681840e+08
VolNTV4.249994e+03
AvgSizeUSD1.147434e+03
MedSizeUSD4.843691e+01
MaxSizeUSD4.755679e+05
NumTrades_0-1K1.871680e+05
NumTrades_1K-10K4.123400e+04
NumTrades_10K-100K5.278000e+03
NumTrades_100K-1M4.500000e+01
NumTrades_1M-10M0.000000e+00
NumTrades_10M-Over0.000000e+00
VolUSD_Trades_0-1K1.983836e+07
VolUSD_Trades_1K-10K1.350884e+08
VolUSD_Trades_10K-100K1.056560e+08
VolUSD_Trades_100K-1M7.601298e+06
VolUSD_Trades_1M-10M0.000000e+00
VolUSD_Trades_10M-Over0.000000e+00
trade_sizes = df[['VolUSD_Trades_0-1K',
'VolUSD_Trades_1K-10K',
'VolUSD_Trades_10K-100K',
'VolUSD_Trades_100K-1M',
'VolUSD_Trades_1M-10M',
'VolUSD_Trades_10M-Over']]

trade_sizes = trade_sizes.rename(columns=lambda x: x.split('_')[2])
trade_sizes
0-1K1K-10K10K-100K100K-1M1M-10M10M-Over
2024-10-06 12:48:39.6386261.983836e+071.350884e+081.056560e+087.601298e+060.00.0
fig, ax = plt.subplots()
ax.bar(
x=trade_sizes.columns,
height=np.hstack([trade_sizes[c].astype(float) for c in trade_sizes.columns])
)

ax.set_title(f"Coinbase Volume by Trade Size \n{start.isoformat()[:16]} to {end.isoformat()[:16]}")
ax.yaxis.set_major_formatter(format_ticks_usd)
ax.yaxis.grid(visible=True, which='major', linestyle='--', alpha=0.5)