curl --request GET \
--url https://test.deribit.com/api/v2/private/close_position \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 6130,
"method": "private/close_position",
"params": {
"instrument_name": "ETH-PERPETUAL",
"type": "limit",
"price": 145.17
}
}
'{
"jsonrpc": "2.0",
"id": 6130,
"result": {
"trades": [
{
"trade_seq": 1966068,
"trade_id": "ETH-2696097",
"timestamp": 1590486335742,
"tick_direction": 0,
"state": "filled",
"reduce_only": true,
"price": 202.8,
"post_only": false,
"order_type": "limit",
"order_id": "ETH-584864807",
"matching_id": null,
"mark_price": 202.79,
"liquidity": "T",
"instrument_name": "ETH-PERPETUAL",
"index_price": 202.86,
"fee_currency": "ETH",
"fee": 0.00007766,
"direction": "sell",
"amount": 21
}
],
"order": {
"web": false,
"time_in_force": "good_til_cancelled",
"replaced": false,
"reduce_only": true,
"price": 198.75,
"post_only": false,
"order_type": "limit",
"order_state": "filled",
"order_id": "ETH-584864807",
"max_show": 21,
"last_update_timestamp": 1590486335742,
"label": "",
"is_rebalance": false,
"is_liquidation": false,
"instrument_name": "ETH-PERPETUAL",
"filled_amount": 21,
"direction": "sell",
"creation_timestamp": 1590486335742,
"average_price": 202.8,
"api": true,
"amount": 21
}
}
}Places a reduce-only order to close an existing position. Reduce-only orders can only reduce or close a position; they cannot open a new position or increase an existing one.
You can specify whether to use a market or limit order. If using a limit order, provide the price. The order will automatically be set to reduce-only to ensure it only closes the position.
Scope: trade:read_write
curl --request GET \
--url https://test.deribit.com/api/v2/private/close_position \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 6130,
"method": "private/close_position",
"params": {
"instrument_name": "ETH-PERPETUAL",
"type": "limit",
"price": 145.17
}
}
'{
"jsonrpc": "2.0",
"id": 6130,
"result": {
"trades": [
{
"trade_seq": 1966068,
"trade_id": "ETH-2696097",
"timestamp": 1590486335742,
"tick_direction": 0,
"state": "filled",
"reduce_only": true,
"price": 202.8,
"post_only": false,
"order_type": "limit",
"order_id": "ETH-584864807",
"matching_id": null,
"mark_price": 202.79,
"liquidity": "T",
"instrument_name": "ETH-PERPETUAL",
"index_price": 202.86,
"fee_currency": "ETH",
"fee": 0.00007766,
"direction": "sell",
"amount": 21
}
],
"order": {
"web": false,
"time_in_force": "good_til_cancelled",
"replaced": false,
"reduce_only": true,
"price": 198.75,
"post_only": false,
"order_type": "limit",
"order_state": "filled",
"order_id": "ETH-584864807",
"max_show": 21,
"last_update_timestamp": 1590486335742,
"label": "",
"is_rebalance": false,
"is_liquidation": false,
"instrument_name": "ETH-PERPETUAL",
"filled_amount": 21,
"direction": "sell",
"creation_timestamp": 1590486335742,
"average_price": 202.8,
"api": true,
"amount": 21
}
}
}Instrument name Unique instrument identifier
"BTC-PERPETUAL"
The order type
limit, market Optional price for limit order.
Success response
The JSON-RPC version (2.0)
2.0 Hide child attributes
Hide child attributes
Unique order identifier
"ETH-100234"
Order state: "open", "filled", "rejected", "cancelled", "untriggered"
open, filled, rejected, cancelled, untriggered, triggered Order type: "limit", "market", "stop_limit", "stop_market"
market, limit, stop_market, stop_limit Order time in force: "good_til_cancelled", "good_til_day", "fill_or_kill" or "immediate_or_cancel"
good_til_cancelled, good_til_day, fill_or_kill, immediate_or_cancel Unique instrument identifier
"BTC-PERPETUAL"
The timestamp (milliseconds since the Unix epoch)
1536569522277
The timestamp (milliseconds since the Unix epoch)
1536569522277
Direction: buy, or sell
buy, sell Price in base currency or "market_price" in case of open trigger market orders
User defined label (up to 64 characters)
true for post-only orders only
true if created with API
Original order type. Optional field
market, market_limit Optional (only for spot). true if order was automatically created during cross-collateral balance restoration
Optional (not added for spot). true if order was automatically created during liquidation
true if order has reject_post_only flag (field is present only when post_only is true)
Optional (not added for spot). 'true for reduce-only orders only'
true if created via Deribit frontend (optional)
Optional field with value true added only when created with Mobile Application
The initial display amount of iceberg order. Iceberg order display amount will be refreshed to that value after match consuming actual display amount. Absent for other types of orders
The actual display amount of iceberg order. Absent for other types of orders.
It represents the requested order size. For perpetual and inverse futures the amount is in USD units. For options and linear futures it is the underlying base currency coin.
It represents the order size in contract units. (Optional, may be absent in historical data).
Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
Average fill price of the order
advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
usd, implv Implied volatility in percent. (Only if advanced="implv")
Option price in USD (Only if advanced="usd")
Whether the trigger order has been triggered
Trigger type (only for trigger orders). Allowed values: "index_price", "mark_price", "last_price".
index_price, mark_price, last_price Trigger price (Only for future trigger orders)
The maximum deviation from the price peak beyond which the order will be triggered (Only for trailing trigger orders)
The price of the given trigger at the time when the order was placed (Only for trailing trigger orders)
true if order made from block_trade trade, added only in that case.
true
true if the order is a MMP order, otherwise false.
true if the order is marked by the platform as a risk reducing order (can apply only to orders placed by PM users), otherwise false.
true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
If order is a quote. Present only if true.
Name of the MMP group supplied in the private/mass_quote request. Only present for quote orders.
Identifier of the QuoteSet supplied in the private/mass_quote request. Only present for quote orders.
The same QuoteID as supplied in the private/mass_quote request. Only present for quote orders.
Id of the trigger order that created the order (Only for orders that were created by triggered orders).
"SLIB-370"
The name of the application that placed the order on behalf of the user (optional).
"Example Application"
true if order was cancelled by mmp trigger (optional)
true
Enumerated reason behind cancel "user_request", "autoliquidation", "cancel_on_disconnect", "risk_mitigation", "pme_risk_reduction" (portfolio margining risk reduction), "pme_account_locked" (portfolio margining account locked per currency), "position_locked", "mmp_trigger" (market maker protection), "mmp_config_curtailment" (market maker configured quantity decreased), "edit_post_only_reject" (cancelled on edit because of reject_post_only setting), "oco_other_closed" (the oco order linked to this order was closed), "oto_primary_closed" (the oto primary order that was going to trigger this order was cancelled), "settlement" (closed because of a settlement)
user_request, autoliquidation, cancel_on_disconnect, risk_mitigation, pme_risk_reduction, pme_account_locked, position_locked, mmp_trigger, mmp_config_curtailment, edit_post_only_reject, oco_other_closed, oto_primary_closed, settlement The Ids of the orders that will be triggered if the order is filled
Order Id
The fill condition of the linked order (Only for linked order types), default: `first_hit`.
first_hit, complete_fill, incremental Unique reference that identifies a one_cancels_others (OCO) pair.
ID of the order that triggered this order.
"ETH-100234"
true if the order is an order that can be triggered by another order, otherwise not present.
true if the order is an order that can trigger an OCO pair, otherwise not present.
Hide child attributes
Unique (per currency) trade identifier
The sequence number of the trade within instrument
Unique instrument identifier
"BTC-PERPETUAL"
The timestamp of the trade (milliseconds since the UNIX epoch)
1517329113791
Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
Always null
Trade direction of the taker
buy, sell Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
0, 1, 2, 3 Index Price at the moment of trade
The price of the trade
Trade amount. For perpetual and inverse futures the amount is in USD units. For options and linear futures it is the underlying base currency coin.
User's fee in units of the specified fee_currency
Currency, i.e "BTC", "ETH", "USDC"
BTC, ETH, USDC, USDT, EURR Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
open, filled, rejected, cancelled, untriggered, archive Mark Price at the moment of trade
Order type: "limit, "market", or "liquidation"
limit, market, liquidation Advanced type of user order: "usd" or "implv" (only for options; omitted if not applicable)
usd, implv Trade size in contract units (optional, may be absent in historical trades)
Option implied volatility for the price (Option only)
Underlying price for implied volatility calculations (Options only)
Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
M, T, MT Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
M, T User defined label (presented only when previously set for order by user)
Block trade id - when trade was part of a block trade
"154"
ID of the Block RFQ - when trade was part of the Block RFQ
ID of the Block RFQ quote - when trade was part of the Block RFQ
true if user order is reduce-only
true if user order is post-only
true if user order is MMP
true if user order is marked by the platform as a risk reducing order (can apply only to orders placed by PM users)
true if user order was created with API
Profit and loss in base currency.
Optional field containing leg trades if trade is a combo trade (present when querying for only combo trades and in combo_trades events)
Optional field containing combo instrument name if the trade is a combo trade
Optional field containing combo trade identifier if the trade is a combo trade
QuoteSet of the user order (optional, present only for orders placed with private/mass_quote)
QuoteID of the user order (optional, present only for orders placed with private/mass_quote)
List of allocations for Block RFQ pre-allocation. Each allocation specifies user_id, amount, and fee for the allocated part of the trade. For broker client allocations, a client_info object will be included.
Hide child attributes
Amount allocated to this user.
Fee for the allocated part of the trade.
User ID to which part of the trade is allocated. For brokers the User ID is obstructed.
Optional client allocation info for brokers.
Hide child attributes
ID of a client; available to broker. Represents a group of users under a common name.
ID assigned to a single user in a client; available to broker.
Name of the linked user within the client; available to broker.
The id that was sent in the request
Was this page helpful?