Skip to content

Commit

Permalink
updated l2 aggregation info to make exchange-specific params clear
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Jan 26, 2018
1 parent cd08c57 commit 835dd36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions wiki/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ Note, that most of methods of the unified API accept an optional `params` parame
- [OHLCV Candlestick Charts](https://github.com/ccxt/ccxt/wiki/Manual#ohlcv-candlestick-charts)
- [Public Trades And Closed Orders](https://github.com/ccxt/ccxt/wiki/Manual#trades-orders-executions-transactions)

## Order Book / Market Depth
## Order Book

Exchanges expose information on open orders with bid (buy) and ask (sell) prices, volumes and other data. Usually there is a separate endpoint for querying current state (stack frame) of the *order book* for a particular market. An order book is also often called *market depth*. The order book information is used in the trading decision making process.

Expand Down Expand Up @@ -885,7 +885,9 @@ Prices and amounts are floats. The bids array is sorted by price in descending o

Exchanges may return the stack of orders in various levels of details for analysis. It is either in full detail containing each and every order, or it is aggregated having slightly less detail where orders are grouped and merged by price and volume. Having greater detail requires more traffic and bandwidth and is slower in general but gives a benefit of higher precision. Having less detail is usually faster, but may not be enough in some very specific cases.

Some exchanges accept a second dictionary of extra parameters to the `fetchOrderBook () / fetch_order_book ()` function allowing you to get the level of aggregation you need, like so:
### Market Depth

Some exchanges accept a second dictionary of extra parameters to the `fetchOrderBook () / fetch_order_book ()` function. **All extra `params` are exchange-specific (non-unified)**. You will need to consult exchanges docs if you want to override a particular param, like the depth of the order book (or the count of returned orders on both sides). You can get a limited count of returned orders or a desired level of aggregation (aka *market depth*) by specifying an exchange-specific extra `param` like so:

```JavaScript
// JavaScript
Expand All @@ -894,7 +896,7 @@ Some exchanges accept a second dictionary of extra parameters to the `fetchOrder
const ccxt = require ('ccxt')
const exchange = new ccxt.bitfinex ()
const orders = await exchange.fetchOrderBook ('BTC/USD', {
'limit_bids': 5, // max = 50
'limit_bids': 5, // max = 50, bitfinex-specific!
'limit_asks': 5, // may be 0 in which case the array is empty
'group': 1, // 1 = orders are grouped by price, 0 = orders are separate
})
Expand All @@ -906,7 +908,7 @@ Some exchanges accept a second dictionary of extra parameters to the `fetchOrder

import ccxt
# return up to ten bidasks on each side of the order book stack
ccxt.cex().fetch_order_book('BTC/USD', {'depth': 10})
ccxt.cex().fetch_order_book('BTC/USD', {'depth': 10}) # cex-specific!
```

```PHP
Expand All @@ -916,7 +918,7 @@ ccxt.cex().fetch_order_book('BTC/USD', {'depth': 10})
$exchange = '\\ccxt\\kraken';
$exchange = new $exchange ();
var_dump ($exchange->fetch_order_book ('BTC/USD', array (
'count' => 10, // up to ten orders on each side for example
'count' => 10, // up to ten orders on each side for example, kraken-specific
)));
```

Expand Down
3 changes: 2 additions & 1 deletion wiki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Welcome to the ccxt wiki!
- [Synchronous vs Asynchronous Calls](https://github.com/ccxt/ccxt/wiki/Manual#synchronous-vs-asynchronous-calls)
- [Unified API](https://github.com/ccxt/ccxt/wiki/Manual#unified-api)
- [Market Data](https://github.com/ccxt/ccxt/wiki/Manual#market-data)
- [Order Book / Market Depth](https://github.com/ccxt/ccxt/wiki/Manual#order-book--market-depth)
- [Order Book](https://github.com/ccxt/ccxt/wiki/Manual#order-book)
- [Market Depth](https://github.com/ccxt/ccxt/wiki/Manual#market-depth)
- [Price Tickers](https://github.com/ccxt/ccxt/wiki/Manual#price-tickers)
- [OHLCV Candlestick Charts](https://github.com/ccxt/ccxt/wiki/Manual#ohlcv-candlestick-charts)
- [Public Trades And Closed Orders](https://github.com/ccxt/ccxt/wiki/Manual#trades-orders-executions-transactions)
Expand Down

0 comments on commit 835dd36

Please sign in to comment.