Amend Order
info
You can only modify unfilled or partially filled orders.
HTTP Request
POST /v5/order/amend
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type |
symbol | true | string | Symbol name, like BTCUSDT , uppercase only |
orderId | false | string | Order ID. Either orderId or orderLinkId is required |
orderLinkId | false | string | User customised order ID. Either orderId or orderLinkId is required |
orderIv | false | string | Implied volatility. option only. Pass the real value, e.g for 10%, 0.1 should be passed |
triggerPrice | false | string |
|
qty | false | string | Order quantity after modification. Do not pass it if not modify the qty |
price | false | string | Order price after modification. Do not pass it if not modify the price |
tpslMode | false | string | TP/SL mode
linear & inverse |
takeProfit | false | string | Take profit price after modification. If pass "0", it means cancel the existing take profit of the order. Do not pass it if you do not want to modify the take profit. valid for spot (UTA), linear , inverse |
stopLoss | false | string | Stop loss price after modification. If pass "0", it means cancel the existing stop loss of the order. Do not pass it if you do not want to modify the stop loss. valid for spot (UTA), linear , inverse |
tpTriggerBy | false | string | The price type to trigger take profit. When set a take profit, this param is required if no initial value for the order |
slTriggerBy | false | string | The price type to trigger stop loss. When set a take profit, this param is required if no initial value for the order |
triggerBy | false | string | Trigger price type |
tpLimitPrice | false | string | Limit order price when take profit is triggered. Only working when original order sets partial limit tp/sl. valid for spot (UTA), linear , inverse |
slLimitPrice | false | string | Limit order price when stop loss is triggered. Only working when original order sets partial limit tp/sl. valid for spot (UTA), linear , inverse |
info
The ack of amend order request indicates that the request is successfully accepted. Please use websocket order stream to confirm the order status
Response Parameters
Parameter | Type | Comments |
---|---|---|
orderId | string | Order ID |
orderLinkId | string | User customised order ID |
Request Example
- 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);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"orderId": "c6f055d9-7f21-4079-913d-e6523a9cfffa",
"orderLinkId": "linear-004"
},
"retExtInfo": {},
"time": 1672217093461
}