> For the complete documentation index, see [llms.txt](https://gitbook.hashpower.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.hashpower.io/04.trading-guide.md).

# Trading Guide

This guide explains how to trade on HPDX Hashprice Futures, from placing your first order to managing positions.

***

## Prerequisites

Before trading, ensure you have:

1. **Settlement Tokens**: USDC or the configured token in your wallet
2. **Wallet Connection**: Connected to the correct network (Base)
3. **Margin Deposit**: Collateral deposited in the Futures contract

***

## Depositing Collateral

Before placing an order, you need to deposit collateral into the Futures contract.

***

## Understanding Order Types

### Long Orders (Buy)

Buying hashrate futures gives you:

* **Long exposure** to hashprice, cash-settled at maturity
* **Obligation to pay** if hashprice falls below entry
* **Profit** if hashprice rises above entry

```
Quantity: +1 (positive = buy/long)
```

### Short Orders (Sell)

Selling hashrate futures gives you:

* **Short exposure** to hashprice, cash-settled at maturity
* **Obligation to pay** if hashprice rises above entry
* **Profit** if hashprice falls below entry

```
Quantity: -1 (negative = sell/short)
```

***

## Order Matching

### How Matching Works

Orders are matched automatically when:

1. **Same Price**: Opposing orders at identical price
2. **Same Maturity Date**: For the same maturity (`deliveryAt`)
3. **Opposite Direction**: Buy matches with Sell

```
┌───────────────────────────────────────────────────────────────────┐
│                     ORDER BOOK (Maturity: Jan 1)                  │
├───────────────────────────────────────────────────────────────────┤
│                                                                    │
│   SELL ORDERS          PRICE          BUY ORDERS                  │
│   (Queue)                             (Queue)                      │
│                                                                    │
│   [Seller A]  ───────  0.15  ───────                              │
│   [Seller B]  ───────  0.14  ───────                              │
│   [Seller C]  ───────  0.12  ───────  [Buyer X]                   │
│               ───────  0.11  ───────  [Buyer Y, Buyer Z]          │
│               ───────  0.10  ───────  [Buyer W]                   │
│                                                                    │
│   If new BUY @ 0.12 → matches with Seller C (FIFO)                │
│   If new SELL @ 0.11 → matches with Buyer Y (first in queue)      │
│                                                                    │
└───────────────────────────────────────────────────────────────────┘
```

### FIFO Priority

When multiple orders exist at the same price, the **oldest order matches first**:

```
Queue at 0.10 USDC:
  1. Buyer A (placed 10:00)  ← Matches first
  2. Buyer B (placed 10:05)
  3. Buyer C (placed 10:10)

New Sell @ 0.10 → Creates position with Buyer A
```

### Self-Matching Prevention

You cannot match with your own opposite order. Instead, your own orders offset:

```
Existing: Buy @ 0.10
You place: Sell @ 0.10

Result: Your buy order is cancelled, no position created
```

***

## Closing Positions

### Method 1: Offset Before Maturity

Place an opposite order at any price to close your position:

```
+1 @ 4.10 USDC/day
-1 @ 4.12 USDC/day

Entry Price:  4.10 USDC/day
Exit Price:   4.12 USDC/day
Duration:     7 days

Profit = (4.12 - 4.10) × 7 = 0.14 USDC per contract
```

### Method 2: Cash Settlement at Maturity

Hold the position until maturity (`deliveryAt`). Once matured, the position is cash-settled at the oracle mark price via the permissionless `settlePosition` — anyone (typically a keeper) can trigger it, and there is no payment, escrow, or destination endpoint to manage (see [Settlement](/05.delivery-settlement.md)).

***

## Order Limits & Fees

### Maximum Orders

Each address has a limit for open orders. Outdated orders (past maturity date) are not counted towards the limit when placing new orders.

### Order Fees

A fee is charged when creating or updating orders. The fee is deducted from your margin balance and collected by the contract.

***

## Read next

* [Settlement](/05.delivery-settlement.md) - Cash settlement of positions at maturity
