diff --git a/protocol/0014-ORDT-order_types.md b/protocol/0014-ORDT-order_types.md index 82ce90845..6906a7665 100644 --- a/protocol/0014-ORDT-order_types.md +++ b/protocol/0014-ORDT-order_types.md @@ -75,7 +75,7 @@ An OCO submission allows a user to have a stop loss and take profit applied to t - The stop order submission wraps a normal order submission. -- A stop order submission may have an optional `Size Override`: +- Providing the stop order is not being submitted to a Spot market, a stop order submission may have an optional `Size Override`: - If unset, the size within the contained normal order submission will be used - If set to `Position`, triggering should override the contained order's size with the trader's entire current position on the market. - The `Position` override configuration should also include the option `position_fraction` which determines what proportion of the position is closed when the stop order is triggered. At time of triggering the size of the order will be determined by $fraction \cdot position$. @@ -100,11 +100,13 @@ Therefore the trigger level of a stop order moves with the market allowing the t - Spam prevention: - - Stop orders will only be accepted from keys with either a non-zero open position or at least one active order. + - In markets which allow leverage. Stop orders will only be accepted from keys with either a non-zero open position or at least one active order. - A network parameter will control the maximum number of stop orders per party (suggested initial value: between 4 and 10). - - If the trader's position size moves to zero exactly, and they have no open orders, all stop orders will be cancelled. + - In markets which allow leverage. If the trader's position size moves to zero exactly, and they have no open orders, all stop orders will be cancelled. + + - In spot markets, as their is no concept of a position, the trader will need to lock the funds required to execute the wrapped order in the holding account even before the stop order is triggered. Refer to section [spot trading](./0080-SPOT-product_builtin_spot.md#7-trading) for the calculation of the required funds. ### Iceberg / transparent iceberg orders @@ -338,66 +340,67 @@ In Spot market, for multiple iceberg orders submitted as a batch of orders with ### Stop orders -- Once triggered, a stop order is removed from the book and cannot be triggered again. (0014-ORDT-041) +- Once triggered, a stop order is removed from the book and cannot be triggered again. (0014-ORDT-041). For spot products (0014-ORDT-XXX) - A stop order placed by a key with a zero position and no open orders will be rejected. (0014-ORDT-042) - A stop order placed by a key with a zero position but open orders will be accepted. (0014-ORDT-043) -- Attempting to create more stop orders than is allowed by the relevant network parameter will result in the transaction failing to execute. (0014-ORDT-044) +- In a spot market, a stop order placed by a key with no position or open orders will be accepted. (0014-ORDT-XXX) +- Attempting to create more stop orders than is allowed by the relevant network parameter will result in the transaction failing to execute. (0014-ORDT-044). For spot products (0014-ORDT-XXX) -- A stop order wrapping a limit order will, once triggered, place the limit order as if it just arrived as an order without the stop order wrapping. (0014-ORDT-045) -- A stop order wrapping a market order will, once triggered, place the market order as if it just arrived as an order without the stop order wrapping. (0014-ORDT-046) +- A stop order wrapping a limit order will, once triggered, place the limit order as if it just arrived as an order without the stop order wrapping. (0014-ORDT-045). For spot products (0014-ORDT-XXX) +- A stop order wrapping a market order will, once triggered, place the market order as if it just arrived as an order without the stop order wrapping. (0014-ORDT-046). For spot products (0014-ORDT-XXX) -- With a last traded price at 50, a stop order placed with `Rises Above` setting at 75 will be triggered by any trade at price 75 or higher. (0014-ORDT-047) -- With a last traded price at 50, a stop order placed with `Rises Above` setting at 25 will be triggered immediately (before another trade is even necessary). (0014-ORDT-048) -- With a last traded price at 50, a stop order placed with `Falls Below` setting at 25 will be triggered by any trade at price 25 or lower. (0014-ORDT-049) -- With a last traded price at 50, a stop order placed with `Falls Below` setting at 75 will be triggered immediately (before another trade is even necessary). (0014-ORDT-050) +- With a last traded price at 50, a stop order placed with `Rises Above` setting at 75 will be triggered by any trade at price 75 or higher. (0014-ORDT-047). For spot products (0014-ORDT-XXX) +- With a last traded price at 50, a stop order placed with `Rises Above` setting at 25 will be triggered immediately (before another trade is even necessary). (0014-ORDT-048). For spot products (0014-ORDT-XXX) +- With a last traded price at 50, a stop order placed with `Falls Below` setting at 25 will be triggered by any trade at price 25 or lower. (0014-ORDT-049). For spot products (0014-ORDT-XXX) +- With a last traded price at 50, a stop order placed with `Falls Below` setting at 75 will be triggered immediately (before another trade is even necessary). (0014-ORDT-050). For spot products (0014-ORDT-XXX) - With a last traded price at 50, a stop order placed with any trigger price which does not trigger immediately will trigger as soon as a trade occurs at a trigger price, and will not wait until the next mark price update to trigger. (0014-ORDT-051) -- A stop order with expiration time `T` set to expire at that time will expire at time `T` if reached without being triggered. (0014-ORDT-052) -- A stop order with expiration time `T` set to execute at that time will execute at time `T` if reached without being triggered. (0014-ORDT-053) - - If the order is triggered before reaching time `T`, the order will have been removed and will *not* trigger at time `T`. (0014-ORDT-054) - - An OCO stop order with expiration time `T` with one side set to execute at that time will execute at time `T` if reached without being triggered, with the specified side triggering and the other side cancelling. This must be tested both sides (fall below and rise above). (0014-ORDT-131) - - An OCO stop order with expiration time `T` with both sides set to execute at that time will be rejected on submission (0014-ORDT-130) +- A stop order with expiration time `T` set to expire at that time will expire at time `T` if reached without being triggered. (0014-ORDT-052). For spot products (0014-ORDT-XXX) +- A stop order with expiration time `T` set to execute at that time will execute at time `T` if reached without being triggered. (0014-ORDT-053). For spot products (0014-ORDT-XXX) + - If the order is triggered before reaching time `T`, the order will have been removed and will *not* trigger at time `T`. (0014-ORDT-054). For spot products (0014-ORDT-XXX) + - An OCO stop order with expiration time `T` with one side set to execute at that time will execute at time `T` if reached without being triggered, with the specified side triggering and the other side cancelling. This must be tested both sides (fall below and rise above). (0014-ORDT-131). For spot products (0014-ORDT-XXX) + - An OCO stop order with expiration time `T` with both sides set to execute at that time will be rejected on submission (0014-ORDT-130). For spot products (0014-ORDT-XXX) -- A stop order set to trade volume `x` with a trigger set to `Rises Above` at a given price will trigger at the first trade at or above that price. (0014-ORDT-055) -- If a pair of stop orders are specified as OCO, one being triggered also removes the other from the book. (0014-ORDT-056) -- If a pair of stop orders are specified as OCO and one triggers but is invalid at time of triggering (e.g. a buy when the trader is already long) the other will still be cancelled. (0014-ORDT-058) +- A stop order set to trade volume `x` with a trigger set to `Rises Above` at a given price will trigger at the first trade at or above that price. (0014-ORDT-055). For spot products (0014-ORDT-XXX) +- If a pair of stop orders are specified as OCO, one being triggered also removes the other from the book. (0014-ORDT-056). For spot products (0014-ORDT-XXX) +- If a pair of stop orders are specified as OCO and one triggers but is invalid at time of triggering (e.g. a buy when the trader is already long) the other will still be cancelled. (0014-ORDT-058). For spot products (0014-ORDT-XXX) - A trailing stop order for a 5% drop placed when the price is `50`, followed by a price rise to `60` will: - - Be triggered by a fall to `57`. (0014-ORDT-059) - - Not be triggered by a fall to `58`. (0014-ORDT-060) + - Be triggered by a fall to `57`. (0014-ORDT-059). For spot products (0014-ORDT-XXX) + - Not be triggered by a fall to `58`. (0014-ORDT-060). For spot products (0014-ORDT-XXX) - A trailing stop order for a 5% rise placed when the price is `50`, followed by a drop to `40` will: - - Be triggered by a rise to `42`. (0014-ORDT-061) - - Not be triggered by a rise to `41`. (0014-ORDT-062) + - Be triggered by a rise to `42`. (0014-ORDT-061). For spot products (0014-ORDT-XXX) + - Not be triggered by a rise to `41`. (0014-ORDT-062). For spot products (0014-ORDT-XXX) - A trailing stop order for a 25% drop placed when the price is `50`, followed by a price rise to `60`, then to `50`, then another rise to `57` will: - - Be triggered by a fall to `45`. (0014-ORDT-063) - - Not be triggered by a fall to `46`. (0014-ORDT-064) + - Be triggered by a fall to `45`. (0014-ORDT-063). For spot products (0014-ORDT-XXX) + - Not be triggered by a fall to `46`. (0014-ORDT-064). For spot products (0014-ORDT-XXX) -- A stop order placed during an auction will not execute during an auction, nor will it participate in the uncrossing. (0014-ORDT-065) -- A stop order placed during an auction, where the uncrossing price is within the triggering range, will immediately execute following uncrossing. (0014-ORDT-066) +- A stop order placed during an auction will not execute during an auction, nor will it participate in the uncrossing. (0014-ORDT-065). For spot products (0014-ORDT-XXX) +- A stop order placed during an auction, where the uncrossing price is within the triggering range, will immediately execute following uncrossing. (0014-ORDT-066). For spot products (0014-ORDT-XXX) -- A stop order placed prior to an auction will not execute during an auction, nor will it participate in the uncrossing. (0014-ORDT-134) -- A stop order placed prior to an auction, where the uncrossing price is within the triggering range, will immediately execute following uncrossing. (0014-ORDT-135) -- An order with a stop is placed during continuous trading. The market goes into auction. The market exits auction, the condition for triggering the stop is not met. The stop order is still present. (0014-ORDT-136) +- A stop order placed prior to an auction will not execute during an auction, nor will it participate in the uncrossing. (0014-ORDT-134). For spot products (0014-ORDT-XXX) +- A stop order placed prior to an auction, where the uncrossing price is within the triggering range, will immediately execute following uncrossing. (0014-ORDT-135). For spot products (0014-ORDT-XXX) +- An order with a stop is placed during continuous trading. The market goes into auction. The market exits auction, the condition for triggering the stop is not met. The stop order is still present. (0014-ORDT-136). For spot products (0014-ORDT-XXX) -- A party places a stop order on a market in continuous trading, the market moves to an auction and the party cancels the stop order. When the market exits the auction the party no longer has a stop order. (0014-ORDT-132) -- A stop order placed during the opening auction, will be rejected. (0014-ORDT-133) +- A party places a stop order on a market in continuous trading, the market moves to an auction and the party cancels the stop order. When the market exits the auction the party no longer has a stop order. (0014-ORDT-132). For spot products (0014-ORDT-XXX) +- A stop order placed during the opening auction, will be rejected. (0014-ORDT-133). For spot products (0014-ORDT-XXX) - If a trader has open stop orders and their position moves to zero whilst they still have open limit orders their stop orders will remain active. (0014-ORDT-067) - If a trader has open stop orders and their position moves to zero with no open limit orders their stop orders are cancelled. (0014-ORDT-068) -- A Stop order that hasn't been triggered can be cancelled. (0014-ORDT-071) -- All stop orders for a specific party can be cancelled by a single stop order cancellation. (0014-ORDT-072) -- All stop orders for a specific party for a specific market can be cancelled by a single stop order cancellation. (0014-ORDT-073) +- A Stop order that hasn't been triggered can be cancelled. (0014-ORDT-071). For spot products (0014-ORDT-XXX) +- All stop orders for a specific party can be cancelled by a single stop order cancellation. (0014-ORDT-072). For spot products (0014-ORDT-XXX) +- All stop orders for a specific party for a specific market can be cancelled by a single stop order cancellation. (0014-ORDT-073). For spot products (0014-ORDT-XXX) - If a stop order is placed with a position_fraction equal to 0.5 and the position size is 5 then the rounding should be equal to 3 (0014-ORDT-138) ## Stop Orders - Negative Cases -- Stop orders submitted with post_only=True are rejected. (0014-ORDT-074) -- Stop orders submitted with invalid values for trigger price (0, negative values) and trailing percentage (0, negative values) are rejected. (0014-ORDT-075) -- Stop orders submitted with expiry in the past are rejected. (0014-ORDT-076) -- GFA Stop orders submitted are rejected. (0014-ORDT-077) -- Stop orders once triggered can not be cancelled. (0014-ORDT-078) +- Stop orders submitted with post_only=True are rejected. (0014-ORDT-074). For spot products (0014-ORDT-XXX) +- Stop orders submitted with invalid values for trigger price (0, negative values) and trailing percentage (0, negative values) are rejected. (0014-ORDT-075). For spot products (0014-ORDT-XXX) +- Stop orders submitted with expiry in the past are rejected. (0014-ORDT-076). For spot products (0014-ORDT-XXX) +- GFA Stop orders submitted are rejected. (0014-ORDT-077). For spot products (0014-ORDT-XXX) +- Stop orders once triggered can not be cancelled. (0014-ORDT-078). For spot products (0014-ORDT-XXX) - If a stop order is placed with a position_fraction equal to 0 the order should be rejected. (0014-ORDT-139) - A party with a long position cannot enter a buy stop order, and a party with a short position cannot enter a sell stop order (0014-ORDT-137) @@ -414,6 +417,7 @@ In Spot market, for multiple iceberg orders submitted as a batch of orders with - A stop order with a size override linked to the position of the trader will use the current position as an override of the triggered order size. (0014-ORDT-127) - All stop orders with a position size override should be cancelled if the trader's position flips sides (long->short or short->long). (0014-ORDT-128) - A stop order with a position size override with a position_fraction set to 0.75, for a trader with long position 20, should create a stop order for selling size 15 when triggered (0014-ORDT-129) +- Given a spot market, a stop order with a position size override will be rejected (0014-ORDT-XXX) ## Perpetuals @@ -423,6 +427,11 @@ In Spot market, for multiple iceberg orders submitted as a batch of orders with - Icebergs (0014-ORDT-122) - All stop order types (0014-ORDT-123) +## Spot + +- A trader submitting a stop order wrapping a buy limit order will have the funds required to execute that order locked in the relevant holding account for the quote asset. (0014-ORDT-XXX) +- A trader submitting a stop order wrapping a sell limit order will have the funds required to execute that order locked in the relevant holding account for the base asset (0014-ORDT-XXX) + ### See also - [0068-MATC-Matching engine](./0068-MATC-matching_engine.md)