Order books are one of the fundamental aspects of cryptocurrency exchanges. They are the active set of orders which are live on the exchange and represent user intent to buy or sell an asset at the specified price.

Order book snapshots are important because they provide the state of the market on a given exchange at the exact moment in time.

Access to order book snapshots provides a way for developers, institutions, and traders to backtest strategies, analyze the market, and find ways to improve their trading algorithms.

Let’s take a specific example. Imagine you want to study how using a Simple Moving Average Crossover strategy with the BTC-USD trading pair would have performed on Kraken for the last 4 years.

Without knowing the exact state of the order book at each crossover event, we would need to guess what prices we could have bought or sold each asset. This injects a level of uncertainty into mathematical models which attempt to accurately simulate trading on historical data.

Instead, we can now collect a complete history of order book snapshots for the BTC-USD trading pair on Kraken. Evaluating the actual order books, we can simulate the exact trades which would have been available at the crossover events.

How We Collect Order Book Snapshots

Unlike many other data services available in the cryptocurrency market, Shrimpy has strict requirements when it comes to the way we manage exchange order books.

Since Shrimpy originated as a trading engine which powers tens of thousands of traders, developers, and institutions, our infrastructure needs to be ready to execute trades in real-time.

That means instead of pulling for data from the exchange every time we make a trade, we need to have a local copy of the exchanges order books ready on our servers.

This is done through exchange order book WebSockets. As the order book for each asset changes, exchanges will send updates through the WebSockets to inform subscribers what has changed. Therefore allowing Shrimpy to update our local copy of the complete order book in real-time.

Once the infrastructure for real-time order book updates was in place, the ability to take snapshots of the order books on a regular interval came with ease.

On a 1 minute interval, Shrimpy takes a snapshot of every order book for every asset across each exchange we support. This snapshot is then stored in our database for later retrieval through the historical data APIs.

How You Can Access Historical Order Book Snapshots

After storing the order book snapshot, Shrimpy is now ready to serve the snapshot as a historical set of data. To access this data, you can call our REST API endpoints to quickly reconstruct the history of any order book.

The following example provides a demonstration of how you can call the endpoint and the results which are returned.

Request

GET https://dev-api.shrimpy.io/v1/historical/orderbooks

Response

[ { "time": "2019-05-19T00:03:02.000Z", "asks": [ { "price": 564.002, "size": 2354346 }, ... ], "bids": [ { "price": 564.002, "size": 2354346 }, ... ] }, ... ]

Tick-by-tick Trade Data

Tick-by-tick trade data is the detailed trades which were executed on the exchange. They provide the complete set of all trades which are being made on an exchange at any given time.

The trade data includes information about what time the order was executed, the size of the order, the price, and which side took the order.

Similar to the order books, our team required a robust strategy for maintaining the complete history of orders on any particular exchange.

In order to ensure we received trades in real-time, we implemented a websocket solution where we subscribe to every trading pair on each exchange to receive the complete updates from each trading pair.

Once we receive the trade, it is immediately placed into our database. In addition to storing each individual trade, we also construct candlestick (OHLCV) charting data based on these individual trades.

The Shrimpy developer APIs provide a normalized experience when handling historical data, so constructing each candlestick from scratch allows us to have a fine control over how each data point is processed.

How To Collect Tick-by-Tick Trade Data

Once a trade has been stored, it becomes ready to serve. Developers can then access this data through REST API calls to analyze, evaluate, or study how trades have been executed across exchanges.

These examples highlight how you can access trade data conveniently through our historical data endpoints.

Request

GET https://dev-api.shrimpy.io/v1/historical/trades

Response

[ { "time": "2016-09-06T13:01:34.000Z", "size": "1891.1316431", "price": "0.00002585", "takerSide": "buyer" }, ... ]

Available Instruments

The Shrimpy developer APIs provide access to 16 different exchanges and thousands of markets. Having access to all this data can feel overwhelming if you don’t know where to start or what data periods are available.

Fortunately, we provide a simple endpoint where you can access all the data which is available across each exchange. That way you never again need to question what data you can access.

How to Get Historical Instruments Available

Simple API calls provide a complete list of data availability. This includes both historical order book snapshots and trade data points.

Use the following call to find what data we have available.

Request

GET https://dev-api.shrimpy.io/v1/historical/instruments?exchange=Bittrex

Response

[ { "exchange":"bittrex", "baseTradingSymbol":"LTC", "quoteTradingSymbol":"BTC", "orderBookStartTime":"2016-09-14T13:00:00.000Z", "orderBookEndTime":"2019-09-07T23:00:00.000Z", "tradeStartTime":"2016-09-12T23:00:00.000Z", "tradeEndTime":"2019-09-09T16:00:00.000Z" } ... ]

Data Plan Pricing

Flexible pricing plans allows you to access the exact amount of data you require, without burning a hole in your back account. This makes Shrimpy ideal for anyone from individuals, to startups, to global institutions.

Access the data which matters most to you.