查詢未平倉合約持倉數量
查詢各個合約市場內所有未平倉的數量
覆蓋範圍: USDT永續 / USDC永續 / USDC交割 / 反向合約
信息
- 最久可以查詢到自合約上線開始的數據
HTTP請求
GET /v5/market/open-interest
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型. linear ,inverse |
symbol | true | string | 合約名稱 |
intervalTime | true | string | 時間粒度. 5min 15min 30min 1h 4h 1d |
startTime | false | integer | 開始時間戳 (毫秒) |
endTime | false | integer | 結束時間戳 (毫秒) |
limit | false | integer | 每頁數量限制. [1 , 200 ]. 默認: 50 |
cursor | false | string | 游標,用於翻頁 |
響應參數
參數 | 類型 | 說明 |
---|---|---|
category | string | 產品類型 |
symbol | string | 合約名稱 |
list | array | Object |
> openInterest | string | 未平倉合約數量, 數值為雙邊的和 |
> timestamp | string | 數據產生的時間戳(毫秒) |
nextPageCursor | string | 游標,用於翻頁 |
請求示例
- HTTP
- Python
- GO
- Java
- Node.js
GET /v5/market/open-interest?category=inverse&symbol=BTCUSD&intervalTime=5min&startTime=1669571100000&endTime=1669571400000 HTTP/1.1
Host: api-testnet.bybit.com
from pybit.unified_trading import HTTP
session = HTTP(testnet=True)
print(session.get_open_interest(
category="inverse",
symbol="BTCUSD",
intervalTime="5min",
startTime=1669571100000,
endTime=1669571400000,
))
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
client := bybit.NewBybitHttpClient("", "", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "linear", "symbol": "BTCUSDT"}
client.NewUtaBybitServiceWithParams(params).GetOpenInterests(context.Background())
import com.bybit.api.client.domain.CategoryType;
import com.bybit.api.client.domain.market.*;
import com.bybit.api.client.domain.market.request.MarketDataRequest;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance().newAsyncMarketDataRestClient();
var openInterest = MarketDataRequest.builder().category(CategoryType.LINEAR).symbol("BTCUSDT").marketInterval(MarketInterval.FIVE_MINUTES).build();
client.getOpenInterest(openInterest, System.out::println);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
});
client
.getOpenInterest({
category: 'inverse',
symbol: 'BTCUSD',
intervalTime: '5min',
startTime: 1669571100000,
endTime: 1669571400000,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {
"symbol": "BTCUSD",
"category": "inverse",
"list": [
{
"openInterest": "461134384.00000000",
"timestamp": "1669571400000"
},
{
"openInterest": "461134292.00000000",
"timestamp": "1669571100000"
}
],
"nextPageCursor": ""
},
"retExtInfo": {},
"time": 1672053548579
}