# Submit order As a user I want change my exposure on a market (e.g. open a position, increase or decrease my open volume), I want to submit an order with instructions for how my order should be executed so I have some control over the price that I get, as well as if when/my order should stay on the book. See [specs about orders](../protocol#orders) for more info. ## Before seeing a "deal ticket" When looking at a market, I... - **must** see/select the [Market](./9001-DATA-data_display.md#market) I am submitting the order for (7002-SORD-001) - **must** see the current `status` of the market (7002-SORD-061) if the market is in a state of `rejected`, `canceled` or `closed`: - **must** see that the market is not accepting orders and never will be (7002-SORD-062) if the market is in a state of `tradingTerminated`: - **must** see that the market is not accepting orders and never will be (7002-SORD-063) - **should** see the [price](9001-DATA-data_display.md#quote-price) that was used to settle the market - **should** see a link to oracle spec and data if the market is in a state of `settled`: - **must** see that the market is not accepting orders and never will be (7002-SORD-066) - **should** see the oracle events that terminated the market - **should** see a link to oracle spec and data if the market is in a state of `suspended`: - **should** see what suspended the market - **should** see the conditioned required for the auction to end - **should** see the current data values that the auction end is measured against (e.g. Supplied stake) ...so I know if the market is accepting orders. The rest of this document only applies if the state of the market is `pending`, `active` or `suspended`: ## Deal ticket When populating a deal ticket I... - **must** see the current market trading mode (Continuous, Auction etc) (7002-SORD-002) - If I have a 0 total balance of the settlement asset: **must** be warned that I have insufficient collateral (but also allow you to populate ticket because I might want to try before I deposit) (7002-SORD-003) - **should** have a way to easily deposit the required collateral - **must** select a side/direction e.g. long/short (note: some implementations may do this with two different submit buttons long/short rather than a toggle) (7002-SORD-004) - **must** be able to select the [order type](../protocol/0014-ORDT-order_types.md) that I wish to submit (7002-SORD-005) - **must** see limit order (7002-SORD-006) - **must** see market order (7002-SORD-007) - **must** see stop limit order (7002-SORD-008) - **must** see stop market order (7002-SORD-009) ## Order size ...need to select a size, when selecting a size for my order, I... - **must** input an order [size](9001-DATA-data_display.md#size) (aka amount or contracts) (7002-SORD-010) - **should** have the previous value for the selected market available e.g. pre-populated (last submitted or last changed) - **should** be able to quickly change the size by the market's min-contract size e.g. hit up/down on the keyboard to increase - **should** be able to use modifier keys (SHIFT, ALT etc) to increase/decrease in larger increments with arrows - **would** like to be able to enter a number followed be "k" or "m" or "e2" etc. to make it thousands or millions or hundreds, etc. - **must** be warned (pre-submit) if input has too many digits after the decimal place for the market's ["position" decimal places](9001-DATA-data_display.md#size) (7002-SORD-016) ... so I get the size of exposure (open volume) that I want ## Price - Limit order ... if wanting to place a limit on the price that I trade at, I... - **must** enter a [price](9001-DATA-data_display.md#quote-price). (7002-SORD-017) - **must** see the price unit (as defined in market) (7002-SORD-018) - **should** be able quickly pre-populate the price with the current mark price (if there is one, 0 if not) e.g. by focusing the input and hitting up/down - **should** have the previous value for the selected market pre-populated (last submitted or last changed) - **should** be able to hit up/down on the keyboard to increase the price by the market's tick size (if set, or smallest increment) - **should** be able to use modifier keys (SHIFT, ALT etc) to increase/decrease in larger increments with arrows - **would** like to be able to enter a number followed be "k" or "m" or "e2" etc. to make it thousands or millions or hundreds, etc. - **must** be warned (pre-submit) if the input price has too many digits after the decimal place for the market ["quote"](9001-DATA-data_display.md#quote-price) (7002-SORD-059) ... so that my order only trades at up/down to a particular price ## Price - Limit stop order ... if wanting to place a stop limit on the price that I trade at, I... - **must** enter a price (7002-SORD-020) - **must** see the price unit (as defined in market) (7002-SORD-021) - **must** have the previous value for the selected market pre-populated (last submitted or last changed) (7002-SORD-022) - **must** be able to hit up/down on the keyboard to increase the price by the market's tick size (if set, or smallest increment) (7002-SORD-029) - **must** be warned (pre-submit) if the input price has too many digits after the decimal place for the market "quote" (7002-SORD-032) - **must** select a trigger direction (7002-SORD-033) - **must** see rises above (7002-SORD-034) - **must** see falls below (7002-SORD-035) - if the user has not set a preference: trigger direction **must** default to `rises above` (7002-SORD-036) - **must** enter a trigger value (7002-SORD-037) - **must** select a trigger type (7002-SORD-038) - **must** see a trigger price (7002-SORD-049) - **must** see a trigger trailing percent offset (7002-SORD-050) - if the user has not set a preference: trigger type **must** default to `price` (7002-SORD-051) ... so that my order only trades after reaching the trigger and at up/down to a particular price - it is reduce only order ## Market order ... if wanting to trade regardless of price (or assuming that the market is liquid enough that the current best prices are enough of an indication of the price I'll get)... - **must not** see a price input (7002-SORD-019) - **should** be warning if the market is in auction and the market order may be rejected ... so I can quickly submit an order without populating the ticket with elements I don't care about ## Market stop order ... if wanting to trade regardless of price with trigger (or assuming that the market is liquid enough that the current best prices are enough of an indication of the price I'll get)... - **must not** see a price input (7002-SORD-052) - **must** see a price input (7002-SORD-054) - **must** select a trigger direction (7002-SORD-055) - **must** see rises above (7002-SORD-056) - **must** see falls below (7002-SORD-057) - **must** enter a trigger value (7002-SORD-058) - **must** select a trigger price (7002-SORD-064) - **must** select a trigger trailing percent offset (7002-SORD-065) - **must** copy a trigger value to the price field (7002-SORD-067) ... so that my order only trades after reaching the trigger and with market price - it is reduce only order ## Pegged ... submit an order where the price is offset from a price in system (best bid etc) - TODO ... so my order will move with the market ## Time in force ... should to select a time in force, when selecting a time in force, I... - **must** select a time in force - Good till canceled `GTC` - not applicable to Market orders (7002-SORD-023) - Good till time `GTT` - not applicable to Market orders (7002-SORD-024) - Fill or kill `FOK` (7002-SORD-025) - Immediate or cancel `IOC` (7002-SORD-026) - Good for normal trading only `GFN` - not applicable to Market orders (7002-SORD-027) - Good for auction only `GFA` - not applicable to Market orders (7002-SORD-028) - **should** only be warned if the time in force is not applicable to the order type I have selected - **should** only be warned if the time in force is not applicable to current period's trading mode - if the user has not set a preference: market orders **must** default to `IOC` (7002-SORD-030) - if the user has not set a preference: limit orders **must** default to `GTC` (7002-SORD-031) - if it is stop order limit or stop order market then **must** select - Fill or kill `FOK` (7002-SORD-068) - Immediate or cancel `IOC` (7002-SORD-069) - if the user has not set a preference: market orders **must** default to `FOK` (7002-SORD-070) ... so I can control if and how my order stays on the order book ## Execution flags ... could select some execution flags. When selecting execution flags (aka order conditions)... - **must** see an option to select "Post only" (7003-SORD-054) - **should** see explanation of what Post only is/does - **must** see the post only option is unselected and disabled (can not be checked) if the time in force is set to IOC or FOK (7003-SORD-055) - **must** see an explanation of why the option is disabled (7003-SORD-056) - **must** see an option to select "Reduce only" (7003-SORD-057) - **should** see explanation of what Reduce only is/does (7003-SORD-058) - **must** see that selecting "Post only" or "reduce only" de-select the other (if selected). As is it not possibly to apply them both to an order (7003-SORD-059) - **must** see an option to select expire for stop order limit and market (7002-SORD-071) - **must** select strategy for stop order limit and market (7002-SORD-072) - **must** see strategy submit (7002-SORD-073) if it is oco then submit strategy is not available (7002-SORD-081) - **must** see strategy cancel (7002-SORD-074) - **must** see expiry time/date (7002-SORD-075) - **must** see an option to select oco for stop order limit and market (7002-SORD-082) - **must** see a type to select market or limit (7002-SORD-083) - **must** see for market type - **must** see rises above (7002-SORD-084) - **must** see falls below (7002-SORD-085) - **must** enter a trigger value (7002-SORD-086) - **must** select a trigger price (7002-SORD-087) - **must** select a trigger trailing percent offset (7002-SORD-088) - **must** see for limit type - **must** enter a price (7002-SORD-089) - **must** select a trigger direction (7002-SORD-090) - **must** see rises above (7002-SORD-099) - **must** see falls below (7002-SORD-091) - if the user has not set a preference: trigger direction **must** default to `opposite to the one selected in the stop order` (7002-SORD-092) - **must** enter a trigger value (7002-SORD-093) - **must** select a trigger type (7002-SORD-094) - **must** see a trigger price (7002-SORD-095) - **must** see a trigger trailing percent offset (7002-SORD-096) - if the user has not set a preference: trigger type **must** default to `price` (7002-SORD-097) - if the trigger price is already met on submission, **must** warn the user that the stop order will be triggered immediately (7002-SORD-098) ... so I can control in more detail how my order is executed ## Auto Populating a deal ticket non-manual methods - TODO Populate by selecting a size/price in the order book - TODO Populate by selecting a size/price in the chart - TODO Populate by selecting a size/price in the depth chart - TODO Input price as a % of account, given the current price field - **should** be able to determine how much leverage I'd like (given general balance, and other inputs) ## See the potential consequences of an order before it is submit ... based on the current inputs I'd like an indication of the consequences of my order based on my position and the state of the market, I... - **could** see my resulting open volume - **could** see the amount this order might move the market in percentage terms - **could** see what the new best prices of the market would be after placing this order (assuming my order moves the market) - **could** see new volume weighted average entry price if not 0 - **could** see and indication the volume weighted price that this particular order - **could** see an indication of how much of the order will trade when it hits the book and how much might remain passive - **could** see a new liquidation level - **could** see an estimate of the fees that will be paid (if any) - **could** see my "position leverage" TODO - define this - **could** see my "account leverage" TODO - define this - **could** see an amount of realized Profit / Loss - **could** see any change in margin requirements (if more or less margin will be required) - **could** see the notional value of my order ... so that I can adjust my inputs before submitting ## Submit an order ... need to submit my order, when submitting my order, I... - if not already connected: **must** see a prompt to [connect a Vega wallet](0002-WCON-connect_vega_wallet.md) - **must** submit the [Vega submit order transaction](0013-WTXN-submit_vega_transaction.md). (7002-SORD-039) - **must** always be able to submit regardless of market state, trading mode or account balances (7002-SORD-060) - **must** see feedback on my order [status](https://docs.vega.xyz/docs/mainnet/grpc/vega/vega.proto#orderstatus) (not just transaction status above) (7002-SORD-040) - Active (aka Open) (7002-SORD-041) - Expired (7002-SORD-042) - Cancelled. see the txn that cancelled it and a link to the block explorer, if cancelled by a user transaction. (7002-SORD-043) - Stopped. see an explanation of why stopped (7002-SORD-044) - Partially filled. **must** see how much of the [size](9001-DATA-data_display.md#size) if filled/remaining (7002-SORD-045) - Filled. Must be able to see/link to all trades that were created from this order. (7002-SORD-046) - Rejected: **must** see the reason it was rejected (7002-SORD-047) - Parked: **must** see an explanation of why parked orders happen (7002-SORD-048) - All feedback must be a subscription so is updated as the status changes (7002-SORD-053) - **could** repeat the values that were submitted (order type + all fields) ... so that I am aware of the status of my order before seeing it in the [orders table](6002-MORD-manage_orders.md). ... so I get the sort of order, and price, I wish. ## Manage positions and order After submitting orders I'll want to [manage orders](7003-MORD-manage_orders.md). If my orders resulted in a position I may wish to [manage positions](7004-POSI-positions.md)). --- # Typical order scenarios to design/test for Market in continuous trading: - Limit order, Long, GTC, with a price that is lower than the current price - Limit order, Short, GFN, that crosses the book but only gets a partial fill when order is processed - Market order, IOC, that increases open volume (aka size of position) - a limit order GFA when market is in Auction - an limit that reduces exposure from something to 0 - a limit order, FOK, that squares and reverses e.g. I'm long 10, I short 20 to end short 10 Market in auction: - Attempt Market order in Auction mode: should warn order is invalid - Attempt limit order GFN when market is normally Continuous (but currently in auction), should warn that GFN will not work