# Order Types & Execution

PaperMarket lets you place two types of orders on top of the live Polymarket order book\
market orders and limit orders.\
The app also supports two time behaviours for orders\
immediate or cancel and good till cancel.

All execution happens on the PaperMarket backend.\
The backend always uses the current Polymarket CLOB book as the reference for prices and available size and never sends your orders to Polymarket itself.

### Price range

All orders in PaperMarket use prices between zero and one

* 0 means a token that is priced at zero cents in the simulation
* 1 means a token that is priced at one dollar

Limit prices outside this range are rejected by the backend.

Prices are expressed per one unit of the YES or NO token for the selected Polymarket market.

### Market orders

A market order tells the system that you want to trade immediately at the best prices that are currently visible in the Polymarket book.

When you submit a market order the backend

* fetches the latest order book for the chosen YES or NO token
* checks your virtual cash balance for a buy or your existing position size for a sell
* walks through the book starting from the best price and matches as much size as possible

For a market buy

* the system starts from the lowest ask price
* matches size level by level until your requested size is filled
* or until there is no more liquidity
* or until your virtual balance is fully used

For a market sell

* the system starts from the highest bid price
* matches size level by level until your requested size is filled
* or until you run out of position size in that token

Any part that cannot be matched at the time of the request simply remains unfilled for market orders.\
The backend creates one order record and one or more trade records for the filled part.\
Your virtual cash and your position are updated according to these trades.

### Limit orders

A limit order tells the system that you want to trade at a price that is no worse than a specific level.

A limit order has

* side
* token
* size
* limit price between zero and one

For a limit buy the backend will only match against asks that are at or below your limit price.\
For a limit sell it will only match against bids that are at or above your limit price.

When you submit a limit order the backend

1. fetches the latest order book for the selected token
2. filters the relevant side of the book by your limit price
3. checks your virtual cash or position size
4. matches as much as possible within those constraints
5. records executed trades
6. decides what to do with any unfilled remainder based on the time behaviour of the order

### Immediate or cancel (IOC)

Immediate or cancel means that the order is only used once against the current snapshot of the book.

For IOC orders the backend

* tries to fill as much as possible right away
* creates trades for the filled portion
* discards any remaining unfilled size

IOC behaviour is used for quick trades where you want to see immediately what you got from the current book and you do not want an order to stay open in the system.

The trade form on the main page uses IOC style execution for both market and limit orders.

### Good till cancel (GTC) limit orders

PaperMarket also supports limit orders that can stay open.

For GTC limit orders the backend

* first tries to execute against the current book in the same way as an IOC limit order
* creates trades for any filled part
* keeps the unfilled remainder as an open order in the PaperMarket database

These open orders do not exist on Polymarket.\
They are only stored inside PaperMarket as internal instructions that say how much you still want to buy or sell at a given limit price.

When you later update or refresh orders for a token the backend can once again compare the open GTC orders with the latest book and fill additional size if the market has moved to your limit price.

Open GTC orders remain active until

* the full size is filled
* or you cancel the order through the orders interface

### No short selling

The simulation does not allow short positions.

* A buy can only be funded from your virtual cash balance
* A sell can only be executed up to the size of your existing position in that token

If you try to sell more than you hold the backend limits the executed size to your current position and does not create a negative position.

### Execution and portfolio impact

Every piece of executed size results in a trade record with a concrete price and size.\
The average of these prices for each token determines your average entry price.

Once trades are stored

* your cash balance is updated
* your position size in the traded token is recalculated
* your portfolio view uses the latest mid price from the Polymarket book to show current value and PnL

This way you always see how your choice of order type and limit price would have played out if you traded against the real Polymarket book under the same conditions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://papermarket.gitbook.io/papermarket/using-papermarket/order-types-and-execution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
