Modify an Order
The method PATCH v4/orders/
enables you to provide a set of new properties to an existing order, such as changing the price or amount. Hence, you no longer need to cancel and place a new order when you want to change any of its modifiable properties.
To use this endpoint effectively, be cautious with the following constraints:
- Order's direction and type are unchangeable: You cannot modify an order's direction or type.
- Not all orders are modifiable: Market, completed, or cancelled orders are unavailable for modifications.
- Configure a valid update: Several property combinations cannot be modified. For example, you can update the
stop
parameter only on un-triggered Stop Orders. - Account must have an available balance: Your account must maintain sufficient available balance to cover the difference in value or amount when modifying an order. For a more detailed understanding of balances, refer to the section, Get Account Balance.
Newmajor
orminor
value calculations may be triggered based on the order direction (buy or sell) and the request payload. If you only modify theprice
, then no additional balance is required.
The amount, expressed in the major currency, is computed using the formula: amount = value / price ,
while the value, expressed in minor, is calculated using the equation: value = amount × price .
The following examples showcase calculations in the BTC/USD order book:
Buy Order Example:
- Consider a buy order with the following values:
minor
: 100K USDprice
: 100K USD- Amount: 1 BTC
- Locked balance: 100K USD
- A modify request is submitted with the following parameter:
price
: 120K USD- The resulting order values are:
minor
: 100K USD (unchanged)price
: 120K USD (changed from request)major
: 0.83333333 BTC (changed automatically)- Locked balance: 100K USD (unchanged)
- Now, a modify request is submitted with the
price
andmajor
parameters (to move the order up or down in the book): price
: 130K USDmajor
: 1 BTC- The resulting order values are:
minor
: 130K USD (changed automatically)price
: 130K USD (changed from request)major
: 1 BTC (changed from request)- Locked balance: 130K USD (an additional 30K USD are locked)
Sell Order Example:
- Consider a sell order with the following values:
minor
: 100K USDprice
: 100K USD- Amount: 1 BTC
- Locked balance: 1 BTC
- A modify request is submitted with the following parameter:
price
: 120K USD- The resulting order values are:
minor
: 120K USD (changed automatically)price
: 120K USD (changed from request)major
: 1 BTC (unchanged)- Locked balance: 1 BTC (unchanged)
- Now, a modify request is submitted with the
price
andminor
parameters (to move the order up or down in the book): price
: 130K USDminor
: 100K USD- The resulting order values are:
minor
: 100K USD (changed from request)price
: 130K USD (changed from request)major
: 0.76923077 BTC (changed automatically)- Locked balance: 0.76923077 BTC (0.23076923 BTC are unlocked)
HTTP Request
You have two ways to specify the identifier of the order to update:
- A path parameter: Use the Bitso-supplied ID.
- A query parameter: Use either the Bitso-supplied or user-supplied ID.
Request
- PATCH https://api-stage.bitso.com/api/v4/orders/{oid}
- PATCH https://api-stage.bitso.com/api/v4/orders?oid={oid}
- PATCH https://api-stage.bitso.com/api/v4/orders?origin_id={origin_id}
Path Parameters
Use the following path parameter to specify the order:
Parameter | Description | Required |
---|---|---|
oid | Specifies the Bitso-supplied identifier of the order to update. | No |
Query Parameters
However, if you prefer to use a query parameter, use either of the following ones to identify the order:
Parameter | Description | Required |
---|---|---|
oid | Specifies the Bitso-supplied identifier of the order to update. | No |
origin_id | Specifies by origin ID (client-supplied ID) the order to update. | No |
Body Parameters
Body parameters must be JSON encoded and precisely the same as the JSON payload used to construct the signature:
Parameter | Description | Required |
---|---|---|
cancel | A Boolean flag to indicate whether to cancel the order if it cannot be processed. Set it to"1" (true) to enable cancellation or "0" (false) to keep the order active. Default value "0". | No. See callout below. |
major | The amount of the major currency to update. | No. See callout below. |
minor | The amount of the minor currency to update, the order's value. You must specify an order in terms of either major or minor , never both. | No. See callout below. |
price | The price in minor at which to buy or sell the amount, the rate of the major/minor combination. | No. See callout below. |
stop | The price per unit of major at which to stop and place the order. Use this parameter only with Stop Orders. | No. See callout below. |
The request body must not be empty.
Your request must include at least one of the following body parameters:
major
minor
price
stop
The
cancel
parameter cannot be sent alone.
JSON Response Payload
The endpoint returns a JSON object representing the order. This object includes the following field:
Field Name | Description | Type |
---|---|---|
oid | The order's unique ID. | String |
The following response object exemplifies the JSON object returned:
{
"success": true,
"payload": {
"oid": "qlbga6b600n3xta7"
}
}
Updated 8 days ago