Trades

/timeseries/market-trades

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>"

Example

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

{
  "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 [email protected] 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. \

  • CM MDF v2.0 on December 9, 2019: Added trades data for spot markets on Binance.US. Added trades data for futures markets on BitMEX and Huobi. \

  • CM MDF v2.1 on May 5, 2020: Added trades data for spot markets on Kucoin and FTX. Added trades data for futures markets on Deribit, OKEx, Binance, FTX, and Bitfinex. \

  • CM MDF v2.2 on December 2, 2020: Added trades data for futures markets on bitFlyer and Kraken. \

  • CM MDF v2.3 on April 25, 2021: 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. \

  • CM MDF v2.4 on September 1, 2021: Extended trades data for Ethereum futures markets on CME.

  • CM MDF v2.6 on July 13, 2022: Added DeFi coverage, and upgrades in areas like order book, candles, and API, etc

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.

Our coverage can be found by querying our /catalog/markets or /catalog-all/markets API endpoints. Alternatively, you can query our /catalog/exchangesor /catalog-all/exchanges API endpoints which contain the same information but organized by exchange.

Availability by Market Type

Availability by Exchange

Last updated