bancorprotocol / carbon-backend

MIT License
1 stars 7 forks source link

CoinGecko - /orderbook (Order book depth details) #3

Open ashachaf opened 1 year ago

ashachaf commented 1 year ago

Endpoint 3 - /orderbook (Order book depth details)

The /orderbook/ticker_id endpoint is to provide order book information with at least depth = 100 (50 each side) returned for a given market pair/ticker.

API para

ticker_id:

depth

Example query: .../api/orderbook?ticker_id=BTC_ETH&depth=200

Note that for more liquid or closely priced pairs, the lack of order depth may result in miscalculation of depth/spread.

data structure

{
"ticker_id": //baseToken_quoteToken, "ticker_symbols": //baseToken.symbol_quoteToken.symbol "timestamp": //Unix timestamp in milliseconds for when the last updated time occurred., "bids": //An array containing 2 elements. The offer price and quantity for each bid order "asks": //An array containing 2 elements. The ask price and quantity for each ask order }

example:
{  
   "ticker_id": "BTC_ETH",
   "timestamp":"1700050000",
   "bids":[  
      [  
         "49.8", //price in quoteToken
         "0.50000000" //amount in baseToken
      ],
      [  
         "49.9", //price in quoteToken
         "6.40000000" //amount in baseToken
      ]
   ],
   "asks":[  
      [  
         "50.1", //price in quoteToken
         "9.20000000" //amount in baseToken
      ],
      [  
         "50.2", //price in quoteToken
         "7.9000000" //amount in baseToken
      ]
   ]
}

calculated values

"bids"

  1. price in quote token -> calculating the price in quoteToken. (for reference, use the process from the frontend as reference
  2. amount in baseToken -> showing the available liquidity in baseToken (for reference, use the process from the frontend as reference

    "asks"

    same as bids