davdiding / cex-adaptors

2 stars 0 forks source link

[Public] Sync `index`, `mark` and `last` price in all exchanges #82

Closed davidting0918 closed 4 months ago

davidting0918 commented 4 months ago

Issue purpose:

Sync okx, binance, bybit, kucoin, bitget, htx, gateio exchanges' index, mark and last price related functions output format

Sync function

This issue will ensure the above exchange will have the following function and input and output format will consistent with the following format.

  1. get_last_price
    This function will return the last traded price of the instrument.
    • input format
      {
      "instrument_id": "BTC/USDT:USDT-PERP", // required
      }
{
  "timestamp": 1629350400000, // timestamp in millisecond
  "instrument_id": "BTC/USDT:USDT-PERP",
  "market_type": "perp", // "spot", "futures", "perp
  "last_price": 10000.0, // last price
  "raw_data": {} // raw data from exchange
}
  1. get_index_price
    This function will return the index price of the instrument. index price is the price of the underlying asset in the perp or futures market.
    • input format
      {
      "instrument_id": "BTC/USDT:USDT-PERP", // required
      }

3. `get_mark_price`  
This function will return the `mark price` of the instrument. `mark price` is the price of the underlying asset normally used to calculate the `unrealized PNL` of the position.
- input format
```json5
{
  "instrument_id": "BTC/USDT:USDT-PERP", // required, funding rate only support futures and perp
}

Issue Progress

  1. get_index_price

    • [x] okx
    • [x] binance
    • [x] bybit
    • [x] kucoin
    • [x] bitget
    • [x] htx
    • [x] gateio
  2. get_mark_price

    • [x] okx
    • [x] binance
    • [x] bybit
    • [x] kucoin
    • [x] bitget
    • [x] htx
    • [ ] gateio
  3. get_last_price

    • [x] okx
    • [x] binance
    • [x] bybit
    • [x] kucoin
    • [x] bitget
    • [x] htx
    • [ ] gateio