批量修改委託單
提示
該接口支持批量修改委託單
- 您只能修改那些未成交或部分成交的訂單. 條件單不支持批量修改.
- 最多支持單個請求中修改, 期權: 20個訂單, 反向合約: 10個訂單, 正向合約: 10个訂單, 現貨: 10個訂單.
HTTP請求
POST /v5/order/amend-batch
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型linear , option , spot , inverse linear , option , spot |
request | true | array | Object |
> symbol | true | string | 合約名稱 |
> orderId | false | string | 訂單Id. orderId 和orderLinkId 必傳其中一個 |
> orderLinkId | false | string | 用戶自定義訂單Id. orderId 和orderLinkId 必傳其中一個 |
> orderIv | false | string | 隱含波動率. 僅option 有效. 按照實際值傳入, e.g., 對於10%, 則傳入0.1 |
> triggerPrice | false | string |
|
> qty | false | string | 修改後的訂單數量. 若不修改,請不要傳該字段 |
> price | false | string | 修改後的訂單價格. 若不修改,請不要傳該字段 |
> tpslMode | false | string | 止盈止損模式
|
> takeProfit | false | string | 修改後的止盈價格. 當傳"0"時, 表示取消當前訂單上設置的止盈. 若不修改,請不要傳該字段 |
> stopLoss | false | string | 修改後的止損價格. 當傳"0"時, 表示取消當前訂單上設置的止損. 若不修改,請不要傳該字段 |
> tpTriggerBy | false | string | 止盈價格觸發類型. 若下單時未設置該值,則調用該接口修改止盈價格時,該字段必傳 |
> slTriggerBy | false | string | 止損價格觸發類型. 若下單時未設置該值,則調用該接口修改止損價格時,該字段必傳 |
> triggerBy | false | string | 觸發價格的觸發類型 |
> tpLimitPrice | false | string | 觸發止盈後轉換為限價單的價格. 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 |
> slLimitPrice | false | string | 觸發止損後轉換為限價單的價格. 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 |
響應參數
參數 | 類型 | 說明 |
---|---|---|
result | Object | |
> list | array | Object |
>> category | string | 產品類型 |
>> symbol | string | 合約名稱 |
>> orderId | string | 訂單Id |
>> orderLinkId | string | 用戶自定義訂單Id |
retExtInfo | Object | |
> list | array | Object |
>> code | number | 成功/錯誤碼 |
>> msg | string | 成功/錯誤信息 |
信息
ack僅表示請求被成功接受. 請使用websocket-order推送來確認訂單狀態
請求示例
- HTTP
- Python
- Java
- .Net
- Node.js
POST /v5/order/amend-batch HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672222935987
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"category": "option",
"request": [
{
"symbol": "ETH-30DEC22-500-C",
"qty": null,
"price": null,
"orderIv": "6.8",
"orderId": "b551f227-7059-4fb5-a6a6-699c04dbd2f2"
},
{
"symbol": "ETH-30DEC22-700-C",
"qty": null,
"price": "650",
"orderIv": null,
"orderId": "fa6a595f-1a57-483f-b9d3-30e9c8235a52"
}
]
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.amend_batch_order(
category="option",
request=[
{
"category": "option",
"symbol": "ETH-30DEC22-500-C",
"orderIv": "6.8",
"orderId": "b551f227-7059-4fb5-a6a6-699c04dbd2f2"
},
{
"category": "option",
"symbol": "ETH-30DEC22-700-C",
"price": "650",
"orderId": "fa6a595f-1a57-483f-b9d3-30e9c8235a52"
}
]
))
import com.bybit.api.client.restApi.BybitApiAsyncTradeRestClient;
import com.bybit.api.client.domain.ProductType;
import com.bybit.api.client.domain.TradeOrderType;
import com.bybit.api.client.domain.trade.*;
import com.bybit.api.client.service.BybitApiClientFactory;
import java.util.Arrays;
BybitApiClientFactory factory = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET");
BybitApiAsyncTradeRestClient client = factory.newAsyncTradeRestClient();
var amendOrderRequests = Arrays.asList(TradeOrderRequest.builder().symbol("BTC-10FEB23-24000-C").qty("0.1").price("5").orderLinkId("9b381bb1-401").build(),
TradeOrderRequest.builder().symbol("BTC-10FEB23-24000-C").qty("0.1").price("5").orderLinkId("82ee86dd-001").build());
var amendBatchOrders = BatchOrderRequest.builder().category(ProductType.OPTION).request(amendOrderRequests).build();
client.createBatchOrder(amendBatchOrders, System.out::println);
using bybit.net.api.ApiServiceImp;
using bybit.net.api.Models.Trade;
var order1 = new OrderRequest { Symbol = "XRPUSDT", OrderId = "xxxxxxxxxx", Qty = "10", Price = "0.6080" };
var order2 = new OrderRequest { Symbol = "BLZUSDT", OrderId = "xxxxxxxxxx", Qty = "15", Price = "0.6090" };
var orderInfoString = await TradeService.AmendBatchOrder(category:Category.LINEAR, request: new List<OrderRequest> { order1, order2 });
Console.WriteLine(orderInfoString);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.batchAmendOrders('option', [
{
symbol: 'ETH-30DEC22-500-C',
orderIv: '6.8',
orderId: 'b551f227-7059-4fb5-a6a6-699c04dbd2f2',
},
{
symbol: 'ETH-30DEC22-700-C',
price: '650',
orderId: 'fa6a595f-1a57-483f-b9d3-30e9c8235a52',
},
])
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {
"list": [
{
"category": "option",
"symbol": "ETH-30DEC22-500-C",
"orderId": "b551f227-7059-4fb5-a6a6-699c04dbd2f2",
"orderLinkId": ""
},
{
"category": "option",
"symbol": "ETH-30DEC22-700-C",
"orderId": "fa6a595f-1a57-483f-b9d3-30e9c8235a52",
"orderLinkId": ""
}
]
},
"retExtInfo": {
"list": [
{
"code": 0,
"msg": "OK"
},
{
"code": 0,
"msg": "OK"
}
]
},
"time": 1672222808060
}