交易日誌
整個賬戶統一錢包裡的交易日誌, 支持最多查詢過去2年的數據
HTTP 請求
GET /v5/account/transaction-log
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
accountType | false | string | 錢包類型. 僅支持UNIFIED |
category | false | string | 交易產品類型 spot ,linear ,option ,inverse spot ,linear ,option |
currency | false | string | 貨幣 |
baseCoin | false | string | 交易幣種. 例如: BTCUSDT 的 baseCoin 是 BTC |
type | false | string | 交易日誌的類型 |
startTime | false | integer | 開始時間戳 (毫秒)
|
endTime | false | integer | 結束時間戳 (毫秒) |
limit | false | integer | 每頁數量, 最大50. 默認每頁20條 |
cursor | false | string | 游標,用於翻頁 |
響應參數
參數 | 類型 | 說明 |
---|---|---|
list | array | Object |
> id | string | 唯一id |
> symbol | string | 合約名稱 |
> category | string | 產品類型 |
> side | string | 方向. Buy ,Sell ,None |
> transactionTime | string | 交易時間戳(毫秒) |
> type | string | 類型 |
> qty | string | 數量. |
> size | string | 倉位. 特別地, 對於成交的流水來說, 這裡的size表示成交後的倉位大小, 帶有方向, 比如空倉, 則有"-" |
> currency | string | USDC、USDT、BTC、ETH |
> tradePrice | string | 交易價格 |
> funding | string | 資金費用. 正數表示用戶收取xx資金費, 負數表示用戶支出xx資金費 funding 來確定資金費用, 以及cashFlow 來確定8小時平倉盈虧 |
> fee | string | 手續費, 正數表示用戶付出xx手續費, 負數表示返佣 |
> cashFlow | string | 現金流, 比如平倉時的未平盈虧結算, USDC永續和交割合約的8小時結算, 以及劃入劃出等. 該值不包含任何手續費或者資金費 |
> change | string | 變更 = cashFlow + funding - fee |
> cashBalance | string | 餘額(當前幣種), 資金流發生後的該幣種的錢包餘額 |
> feeRate | string |
|
> bonusChange | string | 體驗金的變化 |
> tradeId | string | 交易id |
> orderId | string | 訂單id |
> orderLinkId | string | 用戶自定義訂單id |
nextPageCursor | string | 游標,用於翻頁 |
請求示例
- HTTP
- Python
- Node.js
GET /v5/account/transaction-log?accountType=UNIFIED&category=linear¤cy=USDT HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672132480085
X-BAPI-RECV-WINDOW: 5000
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.get_transaction_log(
accountType="UNIFIED",
category="linear",
currency="USDT",
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getTransactionLog({
accountType: 'UNIFIED',
category: 'linear',
currency: 'USDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {
"nextPageCursor": "21963%3A1%2C14954%3A1",
"list": [
{
"id": "592324_XRPUSDT_161440249321",
"symbol": "XRPUSDT",
"side": "Buy",
"funding": "-0.003676",
"orderLinkId": "",
"orderId": "1672128000-8-592324-1-2",
"fee": "0.00000000",
"change": "-0.003676",
"cashFlow": "0",
"transactionTime": "1672128000000",
"type": "SETTLEMENT",
"feeRate": "0.0001",
"bonusChange": "",
"size": "100",
"qty": "100",
"cashBalance": "5086.55825002",
"currency": "USDT",
"category": "linear",
"tradePrice": "0.3676",
"tradeId": "534c0003-4bf7-486f-aa02-78cee36825e4"
},
{
"id": "592324_XRPUSDT_161440249321",
"symbol": "XRPUSDT",
"side": "Buy",
"funding": "",
"orderLinkId": "linear-order",
"orderId": "592b7e41-78fd-42e2-9aa3-91e1835ef3e1",
"fee": "0.01908720",
"change": "-0.0190872",
"cashFlow": "0",
"transactionTime": "1672121182224",
"type": "TRADE",
"feeRate": "0.0006",
"bonusChange": "-0.1430544",
"size": "100",
"qty": "88",
"cashBalance": "5086.56192602",
"currency": "USDT",
"category": "linear",
"tradePrice": "0.3615",
"tradeId": "5184f079-88ec-54c7-8774-5173cafd2b4e"
},
{
"id": "592324_XRPUSDT_161407743011",
"symbol": "XRPUSDT",
"side": "Buy",
"funding": "",
"orderLinkId": "linear-order",
"orderId": "592b7e41-78fd-42e2-9aa3-91e1835ef3e1",
"fee": "0.00260280",
"change": "-0.0026028",
"cashFlow": "0",
"transactionTime": "1672121182224",
"type": "TRADE",
"feeRate": "0.0006",
"bonusChange": "",
"size": "12",
"qty": "12",
"cashBalance": "5086.58101322",
"currency": "USDT",
"category": "linear",
"tradePrice": "0.3615",
"tradeId": "8569c10f-5061-5891-81c4-a54929847eb3"
}
]
},
"retExtInfo": {},
"time": 1672132481405
}