You can place market, limit and scale orders on every market. Each fill happens
at the price of the order already resting on the book.

## Time in force

Every order has a time in force: how long it stays open before whatever hasn't
filled is cancelled.

| Short name | Full name           | What happens                                          |
| ---------- | ------------------- | ----------------------------------------------------- |
| GTC        | Good till cancelled | Rests on the book until it fills or you cancel it     |
| IOC        | Immediate or cancel | Fills what it can right away; the rest is cancelled   |
| FOK        | Fill or kill        | Fills completely right away, or is cancelled entirely |

## Order types

| Order type | What it does                                              | Time in force        |
| ---------- | --------------------------------------------------------- | -------------------- |
| Market     | Fills right away, within your slippage limit              | IOC (default) or FOK |
| Limit      | Fills at your price or better; the rest waits on the book | GTC                  |
| Scale      | Places a ladder of limit orders across a price range      | GTC, IOC or FOK      |

- **Market:** anything that can't fill within your slippage setting (1% by
  default, up to 4%) is cancelled.
- **Scale:** splits your size across 1 to 20 orders (5 by default), evenly
  spaced in price. Sizes are equal unless you set **Size skew** to weight them
  toward one end of the range.

## Order options

- **Post only** (limit and scale): only adds liquidity, so it always pays the
  maker fee. It's rejected if any part would fill right away. Always GTC.
- **Reduce only:** can only make your current position smaller, so it never
  opens a new position or reverses one. It can't be bigger than your position:
  if you're long 1 BTC, a reduce-only sell for more than 1 BTC is rejected.

## Order size

- **Minimum:** $5 per order on-chain, including each order in a scale ladder.
  The app also asks for at least $10 on market and limit orders. Reduce-only
  orders skip the $10 minimum, but one under $5 must close your whole position.
- **Maximum:** each market caps order and position size, and the order form
  shows your max order size. Open orders count toward the position cap.

## Price bands

GUM Perps rejects orders priced further from the
[mark price](/perps/overview#mark-price-and-last-price) than these bands. Limit
and post-only orders are checked on buys above the mark and sells below it;
market orders on their worst possible fill price.

| Order               | JUP | All other markets |
| ------------------- | --- | ----------------- |
| Limit and post-only | 20% | 10%               |
| Market              | 10% | 5%                |

A resting order that ends up outside its band is cancelled rather than filled.

## Self-trade prevention

If your order would match your own resting order in the same sub-account, GUM
Perps cancels the resting one and your new order carries on against other
orders.

## TP/SL

A take profit (TP) or stop loss (SL) closes some or all of a position you hold
once the price reaches a trigger you set. Setting one is free; when it
triggers, its order pays the taker fee.

| Position | Take profit triggers at | Stop loss triggers at |
| -------- | ----------------------- | --------------------- |
| Long     | The trigger or above    | The trigger or below  |
| Short    | The trigger or below    | The trigger or above  |

- **Trigger price:** the
  [mark price](/perps/overview#mark-price-and-last-price) by default, or the
  last price. A last-price TP/SL only counts trades made after you set or last
  edited it.
- **Entry price:** a take profit must be on the profit side of your entry price
  and a stop loss on the loss side. It's checked against your entry, not the
  mark, so one that's already past the mark triggers right away.
- **Size:** a share of the position, a quantity, or a USD amount converted at
  the trigger price. A share is worked out when it triggers, so it follows the
  position as it grows or shrinks. A TP/SL never closes more than the position.
- **Limits:** up to 8 TP/SL per position. Your take profits together can't be
  bigger than the position, and neither can your stop losses.

When it triggers, GUM Perps places a reduce-only order that fills right away
(IOC):

- **Market** (the default): goes ahead only if the book can close the whole
  size within the market [price band](#price-bands). Otherwise GUM Perps tries
  again, and cancels the TP/SL after 5 failed tries.
- **Limit:** fills at your limit price or better, and whatever can't fill right
  away is cancelled. The limit can't be better than the trigger: at or below it
  when closing a long, at or above it when closing a short.

<Warning>
  A trigger isn't a guaranteed exit price. A market TP/SL fills at the prices
  on the book, which can be worse than the trigger in a fast market.
</Warning>

A TP/SL ends when:

- it triggers and its order is placed, even if a limit order fills only partly
  or not at all;
- the position is closed or reversed, which removes every TP/SL on it;
- a limit TP/SL's price is outside the price band when it triggers;
- it would close less than the $5 order minimum, and not the whole position.

When a TP/SL triggers, your reduce-only orders in that market that would no
longer fit the position are cancelled. Order history shows them as **Replaced
by take profit** or **Replaced by stop loss**.

While the sub-account is being liquidated, TP/SL don't trigger and you can't
add or edit them.

## Why an order is rejected

- It's below the minimum or above the maximum size, or would take your position
  past its cap.
- Its price is outside the price band.
- It's post-only and would fill right away.
- It's reduce-only and you have no position, or it's bigger than your position.
- The sub-account already uses the other margin mode in that market. See
  [Cross and isolated margin](/perps/margin-and-leverage#cross-and-isolated-margin).
- There isn't enough Available margin.
- The sub-account is being liquidated, or GUM Perps is under maintenance.
