bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 42쪽 중 34쪽
l": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "23.72469206", // available balance
"maxWithdrawAmount": "23.72469206", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
},
{
"asset": "BUSD", // asset name
"walletBalance": "103.12345678", // wallet balance
"unrealizedProfit": "0.00000000", // unrealized profit
"marginBalance": "103.12345678", // margin balance
"maintMargin": "0.00000000", // maintenance margin required
"initialMargin": "0.00000000", // total initial margin required with current mark price
"positionInitialMargin": "0.00000000", //initial margin required for positions with current mark price
"openOrderInitialMargin": "0.00000000", // initial margin required for open orders with current mark price
"crossWalletBalance": "103.12345678", // crossed wallet balance
"crossUnPnl": "0.00000000" // unrealized profit of crossed positions
"availableBalance": "103.12345678", // available balance
"maxWithdrawAmount": "103.12345678", // maximum amount for transfer out
"marginAvailable": true, // whether the asset can be used as margin in Multi-Assets mode
"updateTime": 1625474304765 // last update time
}
],
"positions": [ // positions of all symbols in the market are returned
// only "BOTH" positions will be returned with One-way mode
// only "LONG" and "SHORT" positions will be returned with Hedge mode
{
"symbol": "BTCUSDT", // symbol name
"initialMargin": "0", // initial margin required with current mark price
"maintMargin": "0", // maintenance margin required
"unrealizedProfit": "0.00000000", // unrealized profit
"positionInitialMargin": "0", // initial margin required for positions with current mark price
"openOrderInitialMargin": "0", // initial margin required for open orders with current mark price
"leverage": "100", // current initial leverage
"isolated": true, // if the position is isolated
"entryPrice": "0.00000", // average entry price
"maxNotional": "250000", // maximum available notional with current leverage
"positionSide": "BOTH", // position side
"positionAmt": "0", // position amount
"updateTime": 0 // last update time
}
]
}
```
`GET /fapi/v4/account (HMAC SHA256)`
Get current account information.
**Weight:** 5
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ---- | --------- | ----------- |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
### Change Initial Leverage (TRADE)
> **Response:**
```
{
"leverage": 21,
"maxNotionalValue": "1000000",
"symbol": "BTCUSDT"
}
```
`POST /fapi/v1/leverage (HMAC SHA256)`
Change user's initial leverage of specific symbol market.
**Weight:** 1
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ------------------------------------------ |
| symbol | STRING | YES | |
| leverage | INT | YES | target initial leverage: int from 1 to 125 |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
### Change Margin Type (TRADE)
> **Response:**
```
{
"code": 200,
"msg": "success"
}
```
`POST /fapi/v1/marginType (HMAC SHA256)`
**Weight:** 1
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ----------------- |
| symbol | STRING | YES | |
| marginType | ENUM | YES | ISOLATED, CROSSED |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
### Modify Isolated Position Margin (TRADE)
> **Response:**
```
{
"amount": 100.0,
"code": 200,
"msg": "Successfully modify position margin.",
"type": 1
}
```
`POST /fapi/v1/positionMargin (HMAC SHA256)`
**Weight:** 1
**Parameters:**
| Name | Type | Mandatory | Description |
| ------------ | ------- | --------- | ---------------------------------------------------------------------------------------------------- |
| symbol | STRING | YES | |
| positionSide | ENUM | NO | Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. It must be sent with Hedge Mode. |
| amount | DECIMAL | YES | |
| type | INT | YES | 1: Add position margin,2: Reduce position margin |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
* Only for isolated symbol
### Get Position Margin Change History (TRADE)
> **Response:**
```
[
{
"amount": "23.36332311",
"asset": "USDT",
"symbol": "BTCUSDT",
"time": 1578047897183,
"type": 1,
"positionSide": "BOTH"
},
{
"amount": "100",
"asset": "USDT",
"symbol": "BTCUSDT",
"time": 1578047900425,
"type": 1,
"positionSide": "LONG"
}
]
```
`GET /fapi/v1/positionMargin/history (HMAC SHA256)`
**Weight:** 1
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ------------------------------------------------ |
| symbol | STRING | YES | |
| type | INT | NO | 1: Add position margin,2: Reduce position margin |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| limit | INT | NO | Default: 500 |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
### Position Information V2 (USER\_DATA)
> **Response:**
> For One-way position mode:
```
[
{
"entryPrice": "0.00000",
"marginType": "isolated",
"isAutoAddMargin": "false",
"isolatedMargin": "0.00000000",
"leverage": "10",
"liquidationPrice": "0",
"markPrice": "6679.50671178",
"maxNotionalValue": "20000000",
"positionAmt": "0.000",
"symbol": "BTCUSDT",
"unRealizedProfit": "0.00000000",
"positionSide": "BOTH",
"updateTime": 0
}
]
```
> For Hedge position mode:
```
[
{
"entryPrice": "6563.66500",
"marginType": "isolated",
"isAutoAddMargin": "false",
"isolatedMargin": "15517.54150468",
"leverage": "10",
"liquidationPrice": "5930.78",
"markPrice": "6679.50671178",
"maxNotionalValue": "20000000",
"positionAmt": "20.000",
"symbol": "BTCUSDT",
"unRealizedProfit": "2316.83423560"
"positionSide": "LONG",
"updateTime": 1625474304765
},
{
"entryPrice": "0.00000",
"marginType": "isolated",
"isAutoAddMargin": "false",
"isolatedMargin": "5413.95799991",
"leverage": "10",
"liquidationPrice": "7189.95",
"markPrice": "6679.50671178",
"maxNotionalValue": "20000000",
"positionAmt": "-10.000",
"symbol": "BTCUSDT",
"unRealizedProfit": "-1156.46711780"
"positionSide": "SHORT",
"updateTime": 0
}
]
```
`GET /fapi/v2/positionRisk (HMAC SHA256)`
Get current position information.
**Weight:** 5
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ----------- |
| symbol | STRING | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
**Note**\
Please use with user data stream `ACCOUNT_UPDATE` to meet your timeliness and accuracy needs.
### Account Trade List (USER\_DATA)
> **Response:**
```
[
{
"buyer": false,
"commission": "-0.07819010",
"commissionAsset": "USDT",
"id": 698759,
"maker": false,
"orderId": 25851813,
"price": "7819.01",
"qty": "0.002",
"quoteQty": "15.63802",
"realizedPnl": "-0.91539999",
"side": "SELL",
"positionSide": "SHORT",
"symbol": "BTCUSDT",
"time": 1569514978020
}
]
```
`GET /fapi/v1/userTrades (HMAC SHA256)`
Get trades for a specific account and symbol.
**Weight:** 5
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | -------------------------------------------------------- |
| symbol | STRING | YES | |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| fromId | LONG | NO | Trade id to fetch from. Default gets most recent trades. |
| limit | INT | NO | Default 500; max 1000. |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
* If `startTime` and `endTime` are both not sent, then the last 7 days' data will be returned.
* The time between `startTime` and `endTime` cannot be longer than 7 days.
* The parameter `fromId` cannot be sent with `startTime` or `endTime`.
### Get Income History(USER\_DATA)
> **Response:**
```
[
{
"symbol": "", // trade symbol, if existing
"incomeType": "TRANSFER", // income type
"income": "-0.37500000", // income amount
"asset": "USDT", // income asset
"info":"TRANSFER", // extra information
"time": 1570608000000,
"tranId":"9689322392", // transaction id
"tradeId":"" // trade id, if existing
},
{
"symbol": "BTCUSDT",
"incomeType": "COMMISSION",
"income": "-0.01000000",
"asset": "USDT",
"info":"COMMISSION",
"time": 1570636800000,
"tranId":"9689322392",
"tradeId":"2059192"
}
]
```
`GET /fapi/v1/income (HMAC SHA256)`
**Weight:** 30
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| symbol | STRING | NO | |
| incomeType | STRING | NO | "TRANSFER","WELCOME\_BONUS", "REALIZED\_PNL","FUNDING\_FEE", "COMMISSION", "INSURANCE\_CLEAR", and "MARKET\_MERCHANT\_RETURN\_REWARD" |
| startTime | LONG | NO | Timestamp in ms to get funding from INCLUSIVE. |
| endTime | LONG | NO | Timestamp in ms to get funding until INCLUSIVE. |
| limit | INT | NO | Default 100; max 1000 |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
* If neither `startTime` nor `endTime` is sent, the recent 7-day data will be returned.
* If `incomeType` is not sent, all kinds of flow will be returned
* "trandId" is unique in the same incomeType for a user
### Notional and Leverage Brackets (USER\_DATA)
> **Response:**
```
[
{
"symbol": "ETHUSDT",
"brackets": [
{
"bracket": 1, // Notional bracket
"initialLeverage": 75, // Max initial leverage for this bracket
"notionalCap": 10000, // Cap notional of this bracket
"notionalFloor": 0, // Notional threshold of this bracket
"maintMarginRatio": 0.0065, // Maintenance ratio for this bracket
"cum":0 // Auxiliary number for quick calculation
},
]
}
]
```
> **OR** (if symbol sent)
```
{
"symbol": "ETHUSDT",
"brackets": [
{
"bracket": 1,
"initialLeverage": 75,
"notionalCap": 10000,
"notionalFloor": 0,
"maintMarginRatio": 0.0065,
"cum":0
},
]
}
```
`GET /fapi/v1/leverageBracket`
**Weight:** 1
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ----------- |
| symbol | STRING | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
### Position ADL Quantile Estimation (USER\_DATA)
> **Response:**
```
[
{
"symbol": "ETHUSDT",
"adlQuantile":
{
// if the positions of the symbol are crossed margined in Hedge Mode, "LONG" and "SHORT" will be returned a same quantile value, and "HEDGE" will be returned instead of "BOTH".
"LONG": 3,
"SHORT": 3,
"HEDGE": 0 // only a sign, ignore the value
}
},
{
"symbol": "BTCUSDT",
"adlQuantile":
{
// for positions of the symbol are in One-way Mode or isolated margined in Hedge Mode
"LONG": 1, // adl quantile for "LONG" position in hedge mode
"SHORT": 2, // adl qauntile for "SHORT" position in hedge mode
"BOTH": 0 // adl qunatile for position in one-way mode
}
}
]
```
`GET /fapi/v1/adlQuantile`
**Weight:** 5
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ----------- |
| symbol | STRING | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
* Values update every 30s.
* Values 0, 1, 2, 3, 4 shows the queue position and possibility of ADL from low to high.
* For positions of the symbol are in One-way Mode or isolated margined in Hedge Mode, "LONG", "SHORT", and "BOTH" will be returned to show the positions' adl quantiles of different position sides.
* If the positions of the symbol are crossed margined in Hedge Mode:
* "HEDGE" as a sign will be returned instead of "BOTH";
* A same value caculated on unrealized pnls on long and short sides' positions will be shown for "LONG" and "SHORT" when there are positions in both of long and short sides.
### User's Force Orders (USER\_DATA)
> **Response:**
```
[
{
"orderId": 6071832819,
"symbol": "BTCUSDT",
"status": "FILLED",
"clientOrderId": "autoclose-1596107620040000020",
"price": "10871.09",
"avgPrice": "10913.21000",
"origQty": "0.001",
"executedQty": "0.001",
"cumQuote": "10.91321",
"timeInForce": "IOC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "SELL",
"positionSide": "BOTH",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"origType": "LIMIT",
"time": 1596107620044,
"updateTime": 1596107620087
}
{
"orderId": 6072734303,
"symbol": "BTCUSDT",
"status": "FILLED",
"clientOrderId": "adl_autoclose",
"price": "11023.14",
"avgPrice": "10979.82000",
"origQty": "0.001",
"executedQty": "0.001",
"cumQuote": "10.97982",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"closePosition": false,
"side": "BUY",
"positionSide": "SHORT",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"origType": "LIMIT",
"time": 1596110725059,
"updateTime": 1596110725071
}
]
```
`GET /fapi/v1/forceOrders`
**Weight:** 20 with symbol, 50 without symbol
**Parameters:**
| Name | Type | Mandatory | Description |
| ------------- | ------ | --------- | ----------------------------------------------------------- |
| symbol | STRING | NO | |
| autoCloseType | ENUM | NO | "LIQUIDATION" for liquidation orders, "ADL" for ADL orders. |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| limit | INT | NO | Default 50; max 100. |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
* If "autoCloseType" is not sent, orders with both of the types will be returned
* If "startTime" is not sent, data within 7 days before "endTime" can be queried
### User Commission Rate (USER\_DATA)
> **Response:**
```
{
"symbol": "BTCUSDT",
"makerCommissionRate": "0.0002", // 0.02%
"takerCommissionRate": "0.0004" // 0.04%
}
```
`GET /fapi/v1/commissionRate (HMAC SHA256)`
**Weight:** 20
**Parameters:**
| Name | Type | Mandatory | Description |
| ---------- | ------ | --------- | ----------- |
| symbol | STRING | YES | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
## User Data Streams
* The base API endpoint is: [**https://fapi.asterdex.com**](https://fapi.asterdex.com/)
* A User Data Stream `listenKey` is valid for 60 minutes after creation.
* Doing a `PUT` on a `listenKey` will extend its validity for 60 minutes.
* Doing a `DELETE` on a `listenKey` will close the stream and invalidate the `listenKey`.
* Doing a `POST` on an account with an active `listenKey` will return the currently active `listenKey` and extend its validity for 60 minutes.
* The baseurl for websocket is **wss\://fstream.asterdex.com**
* User Data Streams are accessed at **/ws/\<listenKey>**
* User data stream payloads are **not guaranteed** to be in order during heavy periods; **make sure to order your updates using E**
* A single connection to **fstream.asterdex.com** is only valid for 24 hours; expect to be disconnected at the 24 hour mark
### Start User Data Stream (USER\_STREAM)
> **Response:**
```
{
"listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}
```
`POST /fapi/v1/listenKey`
Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active `listenKey`, that `listenKey` will be returned and its validity will be extended for 60 minutes.
**Weight:** 1
**Parameters:**
None
### Keepalive User Data Stream (USER\_STREAM)
> **Response:**
```
{}
```
`PUT /fapi/v1/listenKey`
Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 60 minutes.
**Weight:** 1
**Parameters:**
None
### Close User Data Stream (USER\_STREAM)
> **Response:**
```
{}
```
`DELETE /fapi/v1/listenKey`
Close out a user data stream.
**Weight:** 1
**Parameters:**
None
### Event: User Data Stream Expired
> **Payload:**
```
{
'e': 'listenKeyExpired', // event type
'E': 1576653824250 // event time
}
```
When the `listenKey` used for the user data stream turns expired, this event will be pushed.
**Notice:**
* This event is not related to the websocket disconnection.
* This event will be received only when a valid `listenKey` in connection got expired.
* No more user data event will be updated after this event received until a new valid `listenKey` used.
### Event: Margin Call
> **Payload:**
```
{
"e":"MARGIN_CALL", // Event Type
"E":1587727187525, // Event Time
"cw":"3.16812045", // Cross Wallet Balance. Only pushed with crossed position margin call
"p":[ // Position(s) of Margin Call
{
"s":"ETHUSDT", // Symbol
"ps":"LONG", // Position Side
"pa":"1.327", // Position Amount
"mt":"CROSSED", // Margin Type
"iw":"0", // Isolated Wallet (if isolated position)
"mp":"187.17127", // Mark Price
"up":"-1.166074", // Unrealized PnL
"mm":"1.614445" // Maintenance Margin Required
}
]
}
```
* When the user's position risk ratio is too high, this stream will be pushed.
* This message is only used as risk guidance information and is not recommended for investment strategies.
* In the case of a highly volatile market, there may be the possibility that the user's position has been liquidated at the same time when this stream is pushed out.
### Event: Balance and Position Update
> **Payload:**
```
{
"e": "ACCOUNT_UPDATE", // Event Type
"E": 1564745798939, // Event Time
"T": 1564745798938 , // Transaction
"a": // Update Data
{
"m":"ORDER", // Event reason type
"B":[ // Balances
{
"a":"USDT", // Asset
"wb":"122624.12345678", // Wallet Balance
"cw":"100.12345678", // Cross Wallet Balance
"bc":"50.12345678" // Balance Change except PnL and Commission
},
{
"a":"BUSD",
"wb":"1.00000000",
"cw":"0.00000000",
"bc":"-49.12345678"
}
],
"P":[
{
"s":"BTCUSDT", // Symbol
"pa":"0", // Position Amount
"ep":"0.00000", // Entry Price
"cr":"200", // (Pre-fee) Accumulated Realized
"up":"0", // Unrealized PnL
"mt":"isolated", // Margin Type
"iw":"0.00000000", // Isolated Wallet (if isolated position)
"ps":"BOTH" // Position Side
},
{
"s":"BTCUSDT",
"pa":"20",
"ep":"6563.66500",
"cr":"0",
"up":"2850.21200",
"mt":"isolated",
"iw":"13200.70726908",
"ps":"LONG"
},
{
"s":"BTCUSDT",
"pa":"-10",
"ep":"6563.86000",
"cr":"-45.04000000",
"up":"-1423.15600",
"mt":"isolated",
"iw":"6570.42511771",
"ps":"SHORT"
}
]
}
}
```
Event type is `ACCOUNT_UPDATE`.
* When balance or position get updated, this event will be pushed.
* `ACCOUNT_UPDATE` will be pushed only when update happens on user's account, including changes on balances, positions, or margin type.
* Unfilled orders or cancelled orders will not make the event `ACCOUNT_UPDATE` pushed, since there's no change on positions.
* Only positions of symbols with non-zero isolatd wallet or non-zero position amount will be pushed in the "position" part of the event `ACCOUNT_UPDATE` when any position changes.
* When "FUNDING FEE" changes to the user's balance, the event will be pushed with the brief message:
* When "FUNDING FEE" occurs in a **crossed position**, `ACCOUNT_UPDATE` will be pushed with only the balance `B`(including the "FUNDING FEE" asset only), without any position `P` message.
* When "FUNDING FEE" occurs in an **isolated position**, `ACCOUNT_UPDATE` will be pushed with only the balance `B`(including the "FUNDING FEE" asset only) and the relative position message `P`( including the isolated position on which the "FUNDING FEE" occurs only, without any other position message).
* The field "m" represents the reason type for the event and may shows the following possible types:
* DEPOSIT
* WITHDRAW
* ORDER
* FUNDING\_FEE
* WITHDRAW\_REJECT
* ADJUSTMENT
* INSURANCE\_CLEAR
* ADMIN\_DEPOSIT
* ADMIN\_WITHDRAW
* MARGIN\_TRANSFER
* MARGIN\_TYPE\_CHANGE
* ASSET\_TRANSFER
* OPTIONS\_PREMIUM\_FEE
* OPTIONS\_SETTLE\_PROFIT
* AUTO\_EXCHANGE
* The field "bc" represents the balance change except for PnL and commission.
### Event: Order Update
> **Payloa프로젝트로 돌아가기