Data Encyclopedia
HomeCharts
  • Welcome & Product Overview
  • Getting Started
  • Tutorials and Examples
    • Tutorials
      • Python API Client Walkthrough
      • Getting Started With Market Data
      • Getting Started With Futures Data
      • Aggregating Options Data
      • Examining Orderbook Depth
      • Aggregating Orderbook Depth to Create Liquidity Metrics
      • Comparing Stablecoin Prices Using Different Pricing Methods
      • Comparing Volumes of Exchanges and Assets
      • Creating Custom Network Data Metrics Using ATLAS
      • Applying Different Types of Marketcap Metrics
      • Comparing the Dominance of Mining Pools Using ATLAS
      • Using Staking Metrics to Get Yield and Staked Supply
      • Granular Insights On Chain Using Hourly Network Data Metrics
      • Exploring Options, Open Interest, and Volatility Data
      • Calculating Total Value Locked in Liquidity Pools using DEX Data
      • Calculating DEX Liquidity Pool Fees and Volumes
      • Analyzing DeFi Protocol Balance Sheets
    • How To Guides
      • How To Export Data
      • How To Migrate From Catalog to Catalog V2 and Reference Data
      • How To Use the Coin Metrics API Efficiently
    • Dashboard Examples
  • Packages
    • CM Labs
    • Coin Metrics Community Data
  • Access Our Data
    • API Reference
    • API Conventions
      • Catalog V1 to Catalog V2 Migration
    • Python API Client
    • R API Client
    • Coverage
    • Status Page
  • Data Visualization
    • Charting Tool
      • Formula Builder
      • Correlation Tool
      • Embedded Charts
      • Troubleshooting
    • Dashboard
      • Troubleshooting
    • CMTV Charts (Labs)
      • Troubleshooting
    • Atlas Explorer
  • Network Data
    • Network Data Pro Overview
      • Availability
        • Asset Completion Time
      • Addresses
        • Active Addresses
        • Address Balances
        • New Addresses
      • Economics
        • Mining
        • Valuation
      • Exchange
        • Deposits
        • Exchange Supply
        • Net Flows
        • Transaction Count
        • Withdrawals
      • Fees and Revenue
        • Fees
        • Revenue
      • Market
        • Market Capitalization
        • Price
        • Profitability
        • Returns
        • Volatility
      • Key Risk Indicator (KRI) Feed
        • Blocks
        • Block Attributes
        • Block Size
        • Block Times
        • Empty Blocks
        • Fees
        • Outputs
        • Rewards
        • Feerates
        • Hashrate
        • Transaction Feerates
        • Transaction Fees
        • Transaction Sizes
        • Transactions
      • Mining
        • Balances
        • Difficulty
        • Exchange Flows
        • Flows
        • Hardware Hash Rate
        • Hash Rate
      • Network Usage
        • Blocks
        • Contracts
        • Profitability
        • UTXOs
        • Blobs
      • Staking
        • Consensus Health
        • Flows
        • Penalty Metrics
        • Slashing Metrics
        • Validator Supply
        • Stakers
        • Yield
      • Supply
        • Active Supply
        • Addresses with Balance
        • Burnt Supply
        • Current Supply
        • Free Float Supply
        • Future Expected Supply
        • Miner Revenue
        • Profitability
        • Revived Supply
        • Shielded Supply
        • Supply Issuance
        • Staking Supply
      • Transactions
        • Blobs
        • Contracts
        • Token Transactions
        • Transactions
        • Transfer Value
        • Transfers
        • Velocity
      • Wallets
        • Active Wallets
        • Wallet Balances
    • Atlas Overview
      • Accounts
      • Account Balance
      • Blocks
        • Full Block
      • Transactions
        • Full Transaction
          • Full Transaction Info for Block
      • Balance Updates
    • Methodologies
      • Normalizing Block Times
    • DeFi Overview
      • Decentralized Exchange Data
      • DeFi Balance Sheets
      • DeFi FAQs
    • Tagging Meta Data
    • Transaction Tracker
    • CM Labs
      • Mining Pool Monitor Overview
        • Mining Pool Monitor API Fields
      • Reorg & Fork Tracker Overview
        • Reorg & Fork Tracker Tracker API Fields
    • Deprecated
      • Mempool Monitor
      • WatchTower Alerts Overview - DEPRECATED
        • WatchTower Alerts - DEPRECATED
          • Ethereum Proof-of-Stake Alerts - DEPRECATED
            • Missed Slot Alert - DEPRECATED
            • Fast Increase in Transaction Count Alert - DEPRECATED
            • Fast Decrease in Transaction Count Alert - DEPRECATED
            • Fast Decrease in Base Fees - DEPRECATED
            • Fast Increase in Base Fees - DEPRECATED
            • Fast Decrease in Priority Fees (Tips) Alert - DEPRECATED
            • Fast Increase in Priority Fees (Tips) Alert - DEPRECATED
            • Decrease in Active Addresses Alert - DEPRECATED
            • Increase in Active Addresses Alert - DEPRECATED
            • Decrease in Total Block Fees Alert - DEPRECATED
            • Increase in Total Block Fees Alert - DEPRECATED
          • DeFi Alerts - DEPRECATED
            • Smart Contract Admin Change Alert - DEPRECATED
            • Admin Change with Issuance Event Alert - DEPRECATED
            • Admin Change with Large Issuance Event Alert - DEPRECATED
          • Mining Alerts - DEPRECATED
            • Unknown Miner Predominance Alert - DEPRECATED
            • Mining Pool Conflict Alert - DEPRECATED
            • Persistent Mining Pool Conflict Alert - DEPRECATED
            • Hashrate Decrease Alert - DEPRECATED
            • 1-Block Difficulty Decrease - DEPRECATED
          • Blockchain Alerts - DEPRECATED
            • 1 Block Reorg Alert - DEPRECATED
            • 2 Block Reorg Alert - DEPRECATED
            • 3 Block Reorg Alert - DEPRECATED
            • Satoshi Coins Spent - DEPRECATED
            • Vintage Coins Spent - DEPRECATED
            • Slow Block Alert - DEPRECATED
            • 1 Consecutive Empty Block Alert - DEPRECATED
            • 2 Consecutive Empty Blocks Alert - DEPRECATED
            • 3 Consecutive Empty Blocks Alert - DEPRECATED
            • 6 Consecutive Empty Blocks Alert - DEPRECATED
          • Mempool Alerts - DEPRECATED
            • Mempool Disruption Alert - DEPRECATED
            • Mempool Size 90% Alert - DEPRECATED
            • Mempool Size 95% Alert - DEPRECATED
            • Mempool Size 99% Alert - DEPRECATED
            • Mempool Size 100% Alert - DEPRECATED
            • Mempool Congestion Alert - DEPRECATED
        • WatchTower API Fields - DEPRECATED
    • Network Data Glossary
    • Network Data FAQs
  • Market Data
    • Market Data Overview
      • Basis
      • Candles
      • Contract Prices
      • Funding Rates
        • Funding Rates
        • Predicted Funding Rates
        • Aggregated Futures Funding Rate
        • Cumulative Futures Funding Rate
      • Greeks
      • Institution Metrics
        • Grayscale
          • Shares Outstanding
          • Market Price
          • Net Asset Value
          • Coin Per Share
          • Total Assets
      • Liquidations
        • Market Level Liquidations
        • Liquidation Metrics
      • Liquidity
        • Bid-Ask Spread Percent
        • Order Book Depth
        • Slippage
      • Market Metadata
      • Open Interest
        • Market Level Open Interest
        • Reported Open Interest
      • Orderbooks
      • Quotes
      • Trades
      • Volatility
        • Market Implied Volatility
        • Implied Volatility
        • Realized Volatility
      • Volume
        • Trusted Volume
        • Reported Volume
    • CM Prices
      • Reference Rate
      • Principal Market Price (USD)
      • Principal Market (USD)
    • Methodologies
      • Coin Metrics Prices Policies
      • Coin Metrics Prices Methodology
      • Trusted Exchange Framework
    • Market Data FAQs
      • CM Prices FAQs
      • Trusted Exchange Framework FAQs
  • Index Data
    • Index Overview
      • Index Timeseries
        • Index Levels
        • Index Candles
        • Index Constituents
    • Policies & Charters
      • CMBI Index Policies
      • Governance Committees
    • Methodologies
      • Fork Legitimacy Framework
      • Adjusted Free Float Supply Methodology
      • Candidate Market Guidelines
    • Fact Sheets
      • CMBI Single Asset Series Fact Sheet
      • CMBI Multi Asset Series Fact Sheet
      • CMBI Total Market Series Fact Sheet
      • CMBI Mining Series Fact Sheet
    • Indexes Glossary
    • Index FAQs
  • Reference Data
    • datonomy Overview
      • Taxonomy for Assets
      • Taxonomy Metadata for Assets
      • datonomy FAQs
    • Profiles Overview
      • Asset Profiles
      • Network Profiles
    • Security Master Overview
      • Assets
      • Markets
    • Methodologies
      • Guiding Principles and Methodology for datonomy
  • BITTENSOR
    • Precog Methodology
      • Point Forecast Ranking
      • Interval Forecast Ranking
      • Interval Score Examples
      • Miner Weight from Rank
Powered by GitBook
On this page

Was this helpful?

  1. Market Data
  2. Market Data Overview

Trades

/timeseries/market-trades

PreviousQuotesNextVolatility

Last updated 7 months ago

Was this helpful?

Definition

A trade is the exchange of a financial asset between a buyer and seller from a market on a trading venue. A financial asset can be a cryptoasset, a fiat currency, or a cryptoasset derivatives contract.

Details

Market participants can submit a buy order or sell order that indicate the amount and price level that a buyer or seller wishes to trade at. When the exchange receives an order, the order can be matched with another order or placed on the order book. An order book represents the list of unmatched buy orders and the list of unmatched sell orders for a given market organized by price level. When a market participant submits an order that matches with an existing order on the order book, the result is a trade.

Coin Metrics collects trades data from spot, future, and option markets from exchanges that are listed on our exchange coverage universe.

API Endpoints

Market trades can be accessed using the timeseries/market-trades endpoint.

curl --compressed "https://api.coinmetrics.io/v4/timeseries/market-trades?markets=coinbase-btc-usd-spot&limit_per_market=1&api_key=<your_key>"
import requests
response = requests.get('https://api.coinmetrics.io/v4/timeseries/market-trades?markets=coinbase-btc-usd-spot&limit_per_market=1&api_key=<your_key>').json()
print(response)
from coinmetrics.api_client import CoinMetricsClient

api_key = "<API_KEY>"
client = CoinMetricsClient(api_key)

print(
    client.get_market_trades(
        markets=["coinbase-btc-usd-spot"], limit_per_market=5
    ).to_dataframe()
)

Example

{
  "data": [
    {
      "market": "coinbase-btc-usd-spot",
      "time": "2015-01-08T20:55:00.028749000Z",
      "coin_metrics_id": "100",
      "amount": "1000.01",
      "price": "10.61",
      "database_time": "2016-06-08T20:55:00.256754000Z",
      "side": "buy"
    },
    {
      "market": "coinbase-btc-usd-spot",
      "time": "2021-06-08T20:55:00.758178000Z",
      "coin_metrics_id": "200000000",
      "amount": "1000.01",
      "price": "1000000.61",
      "database_time": "2021-06-08T20:55:01.053472000Z",
      "side": "sell"
    }
  ]
}
  • market: The id of the market. Market ids use the following naming convention: exchangeName-baseAsset-quoteAsset-spot for spot markets, exchangeName-futuresSymbol-future for futures markets, and exchangeName-optionsSymbol-option for options markets. \

  • time: The exchange-reported time in ISO 8601 date-time format. Always with nanoseconds precision.\

  • coin_metrics_id: Identifier of a trade that is unique per exchange. We use the exchange-reported value if exchange reports a numeric trade ID, otherwise we convert to numeric using bijective mapping from exchange-reported trade ID’s string.\

  • amount: The amount of the base asset traded for spot markets or the number of contracts of a financial derivative.\

  • price: The price of the base asset quoted in the quote asset that the trade was executed at for spot markets or the price of one contract for derivatives markets.\

  • side: The market order side. "buy" means that an ask was removed from the book by an incoming buy order, "sell" means that a bid was removed from the book by an incoming sell order.\

  • database_time: The time when we saved the data in the database. The time is in ISO 8601 date-time format. Always with nanoseconds precision.

Frequently Asked Questions

What is the latency of your trades data?

The exact latency varies depending on the exchange, but our median latency is approximately 150 milliseconds. The 95th percentile latency is 300 milliseconds, and the 99th percentile latency is 400 milliseconds.

What is the historical coverage of your trades data?

Our trades history for Bitcoin begins when it began trading on Mt.Gox in July 2010, so we have over 10 years of trades history. We also have full historical trades data from several other early exchanges such as Bitstamp, TheRockTrading, Bitfinex, and Kraken.

Some exchanges allow users to query all of their historical trades data while other exchanges only allow users to query a short amount of history such as the past 1,000 trades. Coin Metrics always attempts to collect the maximum backhistory possible. If an exchange allows us to query historical trades data, we will collect data from every market starting from the inception of the exchange.

Can you tell me more information on how to interpret the coin_metrics_id field?

Exchanges serve each trades data with a unique identifier, typically labeled as trade id or uid. If an exchange’s unique identifier is an integer, we store the integer as is. If an exchange’s unique identifier is a base 16-encoded string, we convert the string to an integer and store that value. In general, if an exchange’s unique identifier is a string, we convert it to an integer using a bijective mapping function.

The coin_metrics_id field ensures that all of our observations are unique. Even if two adjacent trades have identical time, price, amount and side fields, they are two distinct trades if they have unique coin_metrics_id and do not represent duplicate trades.

Some exchanges use an incremental trade id that is represented by an integer that increments by 1 for every trade. Most exchanges will start this id at 1, so you can see how many trades have occurred in its lifetime. Also, it is useful for sequencing trades and determining whether all trades have been collected. Coinbase and Binance are two examples of exchanges that report their trade ids in this format.

How do you ensure that the data contains no duplicate trades?

Our market data collection system is designed to use multiple instances of each scraper for redundancy purposes. Although we run multiple instances of each scraper, we deduplicate observations using a composite primary key. For trades and liquidations data, the primary key consists of exchange, market id, and trade id. This ensures that each observation that we insert into our database is unique.

Is there a way to pull data for multiple markets in one API call?

Yes! All of our endpoints that accept the markets parameter will accept wildcards like exchange-* or exchange-*-spot or *USDT-future. The wildcards will match any market which fits this pattern so users do not need to specify every individual market when querying data for multiple markets. The markets parameter will also accept a comma-separated string of individual markets.

What is the timestamp resolution of your trades data?

We always preserve the exchange-reported timestamp resolution, and the maximum resolution reported by some exchanges is at microsecond level. Our API serves time always using nanosecond precision.

What is the difference between time and database_time?

time represents the time logged by the given exchange, whereas database_time represents the time logged by Coin Metrics' database.

How is database_time useful?

database_time can be useful to show collection lag time, which can be important for users who are running backtests and simulations, and need to know exactly what data was available in a given point in time.

How come there is no trades data for a particular market?

When spot markets that involve a new asset are listed on an exchange, there is a short period of time before we can support it. It involves adding this new asset to our security master file so that our market data collection system recognizes it. Please contact us at info@coinmetrics.io if you do not see a particular market, and we will investigate it.

We collect data for spot markets in real-time that consist of existing assets that are already in our security master file without any delay. We also collect data for new futures and options markets in real-time without any delay.

How come there are multiple trades with the same timestamp for a particular market?

Sometimes there may be multiple trades that all occur with the same timestamp. The likely explanation is that an incoming taker order simultaneously matched with multiple existing orders on the order book, although from the available data it is not possible to determine how a particular order is matched with other orders. However, we are certain that each trade is unique even if one or more trades have identical timestamp, price, and amount with other trades.

Do you support any dexes/decentralized exchanges?

We are currently supporting all major liquidity pools on Uniswap v2, Uniswap v3, and Sushiswap v1, and are actively expanding our DeFi universe.

How does Coin Metrics ensure high levels of data quality and data integrity?

Please take a look at this question in the Market Data FAQs page linked below.

Market Data FAQs

Release History

  • CM MDF v1.0 on April 2020: Added trades data for all spot markets on major exchanges. \

  • CM MDF v1.0 update on July 30, 2019: Minor changes to trades websocket messages. \

Availability

The previous 24 hours of trades data is available through our community API. Community data is available via HTTP API only and is limited to 10 API requests per 6 seconds per IP address. All of our trades data is available through our professional API with higher rate limits. The professional API supports trades data through both our HTTP API and websocket API.

Availability by Market Type

Type
Market Count

Spot

13440

Futures

6874

Option

18560

Availability by Exchange

Exchange
Spot Market Count
Future Market Count
Option Market Count
Start Date

Bibox

202

2019-04-24

Binance

1580

220

2017-07-14

Binance.US

119

2019-09-23

Bitbank

11

2017-02-14

Bitfinex

533

35

2013-01-14

bitFlyer

9

64

2019-05-28

Bithumb

91

2013-12-27

BitMEX

302

2014-11-22

Bitstamp

108

2011-08-18

Bittrex

1068

2019-03-21

Bybit

31

2019-10-01

Cex.IO

240

2013-12-27

CME

252

2017-12-17

Coinbase

304

2014-12-01

Deribit

121

11894

2017-01-06

FTX

440

1189

487

2019-03-05

Gate.io

1603

2017-09-29

Gatecoin

80

2014-11-11

Gemini

78

2018-10-16

HitBTC

1517

2013-12-27

Huobi

961

2630

2019-03-15

Kraken

394

79

2013-09-10

Kucoin

914

2020-04-02

LBank

527

2017-09-29

Liquid

481

2014-07-17

LMAX

21

2021-02-18

LocalBitcoins

119

2013-03-11

Mt.Gox

16

2010-07-17

OKEx

629

1951

6666

2018-12-25

Poloniex

448

2014-01-18

TheRockTrading

30

2011-11-09

Upbit

452

2019-03-14

ZB.com

456

2019-03-04

A sample of the trades data from the coinbase-btc-usd-spot market from our API endpoint is provided below.

: Added trades data for spot markets on Binance.US. Added trades data for futures markets on BitMEX and Huobi. \

: Added trades data for spot markets on Kucoin and FTX. Added trades data for futures markets on Deribit, OKEx, Binance, FTX, and Bitfinex. \

: Added trades data for futures markets on bitFlyer and Kraken. \

: Added trades data for spot markets on LMAX. Added trades data for futures markets on CME and Bybit. Added trades data for option markets on Deribit and OKEx. \

: Extended trades data for Ethereum futures markets on CME.

: Added DeFi coverage, and upgrades in areas like order book, candles, and API, etc

Our coverage can be found by querying our or API endpoints. Alternatively, you can query our or API endpoints which contain the same information but organized by exchange.

/timeseries/market-trades
CM MDF v2.0 on December 9, 2019
CM MDF v2.1 on May 5, 2020
CM MDF v2.2 on December 2, 2020
CM MDF v2.3 on April 25, 2021
CM MDF v2.4 on September 1, 2021
CM MDF v2.6 on July 13, 2022
/catalog/markets
/catalog-all/markets
/catalog/exchanges
/catalog-all/exchanges

Market trades

get

Returns trades for specified markets. Results are ordered by tuple (market, time, coin_metrics_id). To fetch the next page of results use next_page_url JSON response field.

Authorizations
Query parameters
marketsstring[]Required

Comma separated list of markets or market patterns like exchange-* or exchange-*-spot or *USDT-future. Use the /catalog-all/markets endpoint for the full list of supported markets.

start_timestringOptional

Start of the time interval. This field refers to the time field in the response. Multiple formats of ISO 8601 are supported: 2006-01-20T00:00:00Z, 2006-01-20T00:00:00.000Z, 2006-01-20T00:00:00.123456Z, 2006-01-20T00:00:00.123456789Z, 2006-01-20, 20060120. Inclusive by default. UTC timezone by default. Z suffix is optional and timezone parameter has a priority over it. If start_time is omitted, response will include time series from the earliest time available.

end_timestringOptional

End of the time interval. This field refers to the time field in the response. Multiple formats of ISO 8601 are supported: 2006-01-20T00:00:00Z, 2006-01-20T00:00:00.000Z, 2006-01-20T00:00:00.123456Z, 2006-01-20T00:00:00.123456789Z, 2006-01-20, 20060120. Inclusive by default. UTC timezone by default. Z suffix is optional and timezone parameter has a priority over it. If end_time is omitted, response will include time series up to the latest time available.

start_inclusivebooleanOptional

Inclusive or exclusive corresponding start_* parameters.

Default: true
end_inclusivebooleanOptional

Inclusive or exclusive corresponding end_* parameters.

Default: true
timezonestringOptional

Timezone name for start_time and end_time timestamps. This parameter does not modify the output times, which are always UTC. Format is defined by TZ database.

Default: UTCExample: America/New_York
page_sizeinteger · int32 · min: 1 · max: 10000Optional

Number of items per single page of results. The value of this parameter is ignored if the endpoint supports the format parameter and its value is set to json_stream.

Default: 100
paging_fromstring · enumOptional

Where does the first page start, at the start of the interval or at the end. The value of this parameter is ignored if the endpoint supports the format parameter and its value is set to json_stream.

Default: endPossible values:
limit_per_marketinteger · int32Optional

How many entries per market result should contain. It is useful when multiple markets are requested.

prettybooleanOptional

Human-readable formatting of JSON responses.

Default: false
formatstring · enumOptional

Format of the response.

Default: jsonPossible values:
next_page_tokenstringOptional

Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use next_page_url response field.

min_confirmationsinteger · int32 · max: 99Optional

Specifies how many blocks behind the chain tip trades are based on. Default is 2. For example, a min_confirmations of 0 means trades are being collected for all blocks up to the block at the tip of the chain (the latest block received by our node) whereas a min_confirmations of 6 means that trades are being collected for all blocks up to the block that is 6 blocks behind the chain tip (i.e., the 7th block if the chain tip is block 1). Currently available only for DeFi markets.

Default: 2
Responses
200
Time series of market trades.
400
Market not found.
application/json
401
Requested resource requires authorization.
application/json
403
Requested resource is not available with supplied credentials.
application/json
414
Provided URI is too long. It must not be greater than 10000 symbols.
get
GET /v4/timeseries/market-trades HTTP/1.1
Host: api.coinmetrics.io
Accept: */*
{
  "data": [
    {
      "time": "2015-01-08T20:55:00.028749000Z",
      "market": "coinbase-btc-usd-spot",
      "coin_metrics_id": "100",
      "amount": "1000.01",
      "price": "10.61",
      "database_time": "2016-06-08T20:55:00.256754000Z",
      "side": "buy"
    },
    {
      "time": "2021-06-08T20:55:00.758178000Z",
      "market": "coinbase-btc-usd-spot",
      "coin_metrics_id": "200000000",
      "amount": "1000.01",
      "price": "1000000.61",
      "database_time": "2021-06-08T20:55:01.053472000Z",
      "side": "sell"
    }
  ],
  "next_page_token": "0.MjAyMC0wNi0wOFQyMTowMzowNi40OTM1OTZafDk0MjMzMjAz",
  "next_page_url": "https://api.coinmetrics.io/v4/timeseries/market-trades?markets=coinbase-btc-usd-spot&api_key=<your_key>&pretty=true&page_size=2&next_page_token=0.MjAyMC0wNi0wOFQyMTowMzowNi40OTM1OTZafDk0MjMzMjAz"
}
  • Definition
  • Details
  • API Endpoints
  • GETMarket trades
  • Example
  • Frequently Asked Questions
  • What is the latency of your trades data?
  • What is the historical coverage of your trades data?
  • Can you tell me more information on how to interpret the coin_metrics_id field?
  • How do you ensure that the data contains no duplicate trades?
  • Is there a way to pull data for multiple markets in one API call?
  • What is the timestamp resolution of your trades data?
  • What is the difference between time and database_time?
  • How is database_time useful?
  • How come there is no trades data for a particular market?
  • How come there are multiple trades with the same timestamp for a particular market?
  • Do you support any dexes/decentralized exchanges?
  • How does Coin Metrics ensure high levels of data quality and data integrity?
  • Release History
  • Availability
  • Availability by Market Type
  • Availability by Exchange