davdiding / cex-adaptors

2 stars 0 forks source link

[Public] Sync `funding_rate` and `klines` inputs outputs format. #77

Closed davidting0918 closed 4 months ago

davidting0918 commented 5 months ago

Issue purpose:

Sync okx, binance, bybit, kucoin, bitget, htx, gateio klines and funding rate 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_current_candlestick
    • input format
      {
      "instrument_id": "BTC/USDT:USDT-PERP", // required
      "interval": "1m", // required, vary from different exchanges
      }
{
  "timestamp": 1629350400000, // timestamp in millisecond
  "interval": "1m",
  "instrument_id": "BTC/USDT:USDT-PERP",
  "market_type": "perp", // "spot", "futures", "perp
  "open": 10000.0, // open price
  "high": 10100, // high price
  "low": 9900, // low price
  "close": 10050, // close price
  "base_volume": 1000, // volume in base currency
  "quote_volume": 10000000, // quote volume
  "contract_volume": 1000, // contract volume
  "raw_data": {} // raw data from exchange
}
  1. get_history_candlesticks
    • input format
      {
      "instrument_id": "BTC/USDT:USDT-PERP", // required
      "interval": "1m", // required, vary from different exchanges
      "start": 1629350400000, // optional, timestamp in millisecond
      "end": 1629350400000, // optional, timestamp in millisecond
      "num": 100, // optional, number of data to return
      }
  1. get_current_funding_rate

    • input format
      {
      "instrument_id": "BTC/USDT:USDT-PERP", // required, funding rate only support futures and perp
      }
    • output format
      {
      "BTC/USDT:USDT-PERP": {
      "timestamp": 1629350400000, // timestamp in millisecond
      "next_funding_time": 1629350400000, // timestamp in milliseconds
      "instrument_id": "BTC/USDT:USDT-PERP",
      "market_type": "perp",
      "funding_rate": 0.001, // funding rate in percentage, 0.01 means 1%
      "raw_data": {} // raw data from exchange
      }
      }
  2. get_history_funding_rate

    • input format
      {
      "instrument_id": "BTC/USDT:USDT-PERP", // required, funding rate only support futures and perp
      "start": 1629350400000, // optional, timestamp in millisecond
      "end": 1629350400000, // optional, timestamp in millisecond
      "num": 100, // optional, number of data to return
      }

      (start, end) or num must be provided, if both provided, use start and end.

Issue Progress

  1. get_current_candlestick

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

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

    • [x] okx
    • [x] binance
    • [x] bybit
    • [x] kucoin
    • [x] bitget
    • [x] htx
    • [x] gateio
  4. get_history_funding_rate

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