修改委託單
important
您只能修改那些未成交或者部分成交的訂單。
HTTP請求
POST /v5/order/amend
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
category | true | string | 產品類型 |
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 | 止盈止損模式
linear 和inverse 有效 |
takeProfit | false | string | 修改後的止盈價格. 當傳"0"時, 表示取消當前訂單上設置的止盈. 若不修改,請不要傳該字段 適用於 spot (UTA), linear , inverse |
stopLoss | false | string | 修改後的止損價格. 當傳"0"時, 表示取消當前訂單上設置的止損. 若不修改,請不要傳該字段 適用於 spot (UTA), linear , inverse |
tpTriggerBy | false | string | 止盈價格觸發類型. 若下單時未設置該值,則調用該接口修改止盈價格時,該字段必傳 |
slTriggerBy | false | string | 止損價格觸發類型. 若下單時未設置該值,則調用該接口修改止損價格時,該字段必傳 |
triggerBy | false | string | 觸發價格的觸發類型 |
tpLimitPrice | false | string | 觸發止盈後轉換為限價單的價格 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 適用於 spot (UTA), linear , inverse |
slLimitPrice | false | string | 觸發止損後轉換為限價單的價格 當且僅當原始訂單下單時創建的是部分止盈止損限價單, 本字段才有效 適用於 spot (UTA), linear , inverse |
信息
ack僅表示請求被成功接受. 請使用websocket-order推送來確認訂單狀態
響應參數
參數 | 類型 | 說明 |
---|---|---|
orderId | string | 訂單Id |
orderLinkId | string | 用戶自定義訂單Id |
請求示例
- HTTP
- Python
- Java
- .Net
- Node.js
POST /v5/order/amend HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672217108106
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"category": "linear",
"symbol": "ETHPERP",
"orderLinkId": "linear-004",
"triggerPrice": "1145",
"qty": "0.15",
"price": "1050",
"takeProfit": "0",
"stopLoss": "0"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.amend_order(
category="linear",
symbol="ETHPERP",
orderLinkId="linear-004",
triggerPrice="1145",
qty="0.15",
price="1050",
takeProfit="0",
stopLoss="0",
))
import com.bybit.api.client.restApi.BybitApiTradeRestClient;
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.trade.*;
import com.bybit.api.client.service.BybitApiClientFactory;
BybitApiClientFactory factory = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET");
BybitApiAsyncTradeRestClient client = factory.newAsyncTradeRestClient();
var amendOrderRequest = TradeOrderRequest.builder().orderId("1523347543495541248").category(ProductType.LINEAR).symbol("XRPUSDT")
.price("0.5") // setting a new price, for example
.qty("15") // and a new quantity
.build();
var amendedOrder = client.amendOrder(amendOrderRequest);
System.out.println(amendedOrder);
using bybit.net.api.ApiServiceImp;
using bybit.net.api.Models.Trade;
BybitTradeService tradeService = new(apiKey: "xxxxxxxxxxxxxx", apiSecret: "xxxxxxxxxxxxxxxxxxxxx");
var orderInfoString = await TradeService.AmendOrder(orderId: "1523347543495541248", category:Category.LINEAR, symbol: "XRPUSDT", price:"0.5", qty:"15");
Console.WriteLine(orderInfoString);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.amendOrder({
category: 'linear',
symbol: 'ETHPERP',
orderLinkId: 'linear-004',
triggerPrice: '1145',
qty: '0.15',
price: '1050',
takeProfit: '0',
stopLoss: '0',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {
"orderId": "c6f055d9-7f21-4079-913d-e6523a9cfffa",
"orderLinkId": "linear-004"
},
"retExtInfo": {},
"time": 1672217093461
}