# Extended Grid Bot

#### Prerequisites

Before you start, make sure you have:

1. **An Extended API Wallet** — Add one through Dextrabot's Wallet Management. See below for detailed steps.
2. **USDC Balance** — Fund your wallet with USDC. Minimum depends on your leverage settings.

<figure><img src="/files/VOgh8fWuMqGSVMqxIXff" alt=""><figcaption></figcaption></figure>

***

#### Getting Your API Keys

Follow these steps to add your Extended wallet to Dextrabot:

**Step 1: Get API Credentials from Extended Exchange**

1. Go to [Extended API Management](https://app.extended.exchange/api-management)
2. Find your **Main Account** row
3. Click **Generate API Key**
4. Click **Show API Details** to reveal your credentials

<figure><img src="/files/uiq2HPmkjsCACbQxirm6" alt=""><figcaption></figcaption></figure>

**Step 2: Add Wallet to Dextrabot**

1. Go to [Dextrabot Wallet Management](https://app.dextrabot.com/wallet-management#extended)
2. Click **Add Account**
3. Select **Add API Wallet** and choose **EXTENDED**
4. Fill in the following fields:
   * **Wallet Name:** A tag/label for your wallet (for your reference)
   * **Login Address:** The wallet address you want to trade with
   * **API Key:** Your API key from Extended
   * **Stark Key Public:** Your public stark key from Extended
   * **Stark Key Private:** Your private stark key from Extended
   * **Vault Number:** Your vault number from Extended
5. Click **Generate** to save your wallet

<figure><img src="/files/RyTzgeuL36DpbBV2G3iD" alt=""><figcaption></figcaption></figure>

***

#### Fees

| Fee Type                  | Amount                                                               |
| ------------------------- | -------------------------------------------------------------------- |
| **Dextrabot Fee**         | 0.01% per trade                                                      |
| **Extended Trading Fees** | Standard Extended exchange trading fees apply to each executed trade |

***

#### Quick Start Guide

Get your grid bot running in under 5 minutes:

1. **Go to Terminal** — Navigate to `app.dextrabot.com/terminal/extended/BTC` (or any trading pair)
2. **Select Extended** — Make sure the **Extended** toggle is selected in the top-left corner
3. **Select Grid Bot** — On the right panel, click the **Grid Bot** tab
4. **Choose Wallet** — Select your funded Perps Wallet from the dropdown
5. **Configure Settings** — Set your price range, number of grids, and investment amount (or click **Autofill** for suggested values)
6. **Start!** — Click the green **Start** button and let the bot do its magic ✨

***

#### Configuration Parameters

Here's a detailed breakdown of each setting:

| Parameter                       | Description                                                                                                                                                                                             |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Perps Wallet**                | Select the wallet you want the bot to trade with. Shows wallet address and current USDC balance.                                                                                                        |
| **Grid Mode**                   | Choose how the bot opens positions: **Neutral** (default) opens both long and short positions for sideways markets. **Short Only** opens only short positions. **Long Only** opens only long positions. |
| **Open a Position on Creation** | *(Short Only & Long Only modes only)* When enabled, the bot immediately opens a position at current price when created. When disabled, the bot waits until price reaches the first grid level.          |
| **Price Range**                 | **Lower & Upper:** Define the price boundaries for your grid. The bot only operates within this range. Click **Autofill** to automatically set a range based on current market conditions.              |
| **Mark Price**                  | Displays the current mark price of the asset for reference when setting your price range.                                                                                                               |
| **Number of Grids**             | How many grid levels to create (even numbers only). More grids = more frequent smaller trades. Fewer grids = less frequent larger trades.                                                               |
| **Grid Type**                   | **Arithmetic:** Equal dollar spacing between grids. **Geometric:** Equal percentage spacing between grids.                                                                                              |
| **Investment**                  | Amount in USDC to allocate to the bot. Use the slider (25%, 33%, 50%, 66%, 75%, 100%) or type a custom amount. Toggle between USDC and leverage multiplier (e.g., 10x).                                 |
| **Max Position Size**           | Maximum position size the bot can hold, displayed in the asset (e.g., Max BTC).                                                                                                                         |
| **Qty per Order**               | The quantity allocated to each individual grid order.                                                                                                                                                   |
| **Margin Mode**                 | Currently only **Cross Margin** is supported. Your entire account balance serves as collateral.                                                                                                         |
| **Est. Liq Long**               | Estimated liquidation price for long positions. If price drops to this level, long positions may be liquidated.                                                                                         |
| **Est. Liq Short**              | Estimated liquidation price for short positions. If price rises to this level, short positions may be liquidated.                                                                                       |

**Grid Modes Explained**

The Grid Mode setting determines how your investment is distributed across orders and whether the bot opens an initial position. Choose the mode that matches your market outlook.

**1) NEUTRAL (Default)**

* No initial position is opened
* The entire investment is distributed across grid orders
* Best for sideways/ranging markets

**Formula:**

```
Order Size = Investment / (Short + Long)
```

**Example:**

* Investment: $100
* Shorts: 4
* Longs: 6

$100 / (4 + 6) = **$10 per order**

* 4 SELL orders × $10 = $40
* 6 BUY orders × $10 = $60
* **Total: $100**

This mode is fully direction-neutral.

***

**2) LONG ONLY**

* An initial **LONG position** is opened at the start
* SELL orders close the position, so they are given **2× weight**
* Best when you expect price to rise

**Formula:**

```
Order Size = Investment / (Short × 2 + Long)
```

**Example:** $100 / (4 × 2 + 6) = $100 / 14 = **$7.14 per order**

* 4 SELL orders × $7.14 = $28.56
* 6 BUY orders × $7.14 = $42.84
* Initial LONG position size = total SELL allocation = **$28.56**
* **Total: ≈ $100**

*Logic: SELL orders act both as grid orders and as position-closing orders, so they are weighted twice.*

***

**3) SHORT ONLY**

* An initial **SHORT position** is opened at the start
* BUY orders close the position, so they are given **2× weight**
* Best when you expect price to fall

**Formula:**

```
Order Size = Investment / (Short + Long × 2)
```

**Example:** $100 / (4 + 6 × 2) = $100 / 16 = **$6.25 per order**

* 4 SELL orders × $6.25 = $25.00
* 6 BUY orders × $6.25 = $37.50
* Initial SHORT position size = total BUY allocation = **$37.50**
* **Total: $100**

*Logic: BUY orders act both as grid orders and as position-closing orders, so they are weighted twice.*

***

**Quick Reference Summary**

| Mode       | Formula           | Example ($100, 4S/6L)  |
| ---------- | ----------------- | ---------------------- |
| Neutral    | inv / (S + L)     | $100 / 10 = **$10.00** |
| Long Only  | inv / (S × 2 + L) | $100 / 14 = **$7.14**  |
| Short Only | inv / (S + L × 2) | $100 / 16 = **$6.25**  |

***

#### Supported Trading Pairs

The Extended Grid Bot supports perpetual trading pairs including:

* BTC/USD
* ETH/USD
* And more...

Simply navigate to the desired pair in the Terminal (e.g., `/terminal/extended/ETH`) and the Grid Bot will automatically adjust to that market.

***

#### Bot Behavior

**When You Click Start**

The bot immediately places orders at each grid level based on your configuration. The number of orders equals the number of grids you selected.

**During Operation**

* When price drops to a grid level → Bot opens a long position
* When price rises to the next grid level → Bot closes for profit
* This cycle repeats as price oscillates within your range

**Restarting the Bot**

To restart: Click **Stop** → Wait for open orders/positions to close → Click **Start** again with your desired settings.

***

#### Managing Your Bots

At the bottom of the terminal, you can see all your active and stopped grid bots with the following information:

| Column         | Description                                |
| -------------- | ------------------------------------------ |
| **Status**     | Current state of the bot (Running/Stopped) |
| **Coin**       | The trading pair the bot is operating on   |
| **Wallet**     | The connected wallet address               |
| **Grids**      | Number of grid levels configured           |
| **Lower**      | Lower bound of the price range             |
| **Upper**      | Upper bound of the price range             |
| **Investment** | Total USDC allocated to the bot            |
| **Lev**        | Leverage multiplier being used             |
| **Grid Type**  | Arithmetic or Geometric spacing            |
| **Actions**    | Start/Stop and Edit controls               |

***

#### Monitoring Your Bot

You can monitor your positions and bot activity through:

* **Dextrabot Terminal:** The order book on the left shows current market depth and your grid levels
* **Bot List:** View all your bots, their configurations, and current status at the bottom of the terminal

***

#### Risk Warning

**Only invest what you can afford to lose.** Grid bots work best in ranging/sideways markets. In strong trending markets, the bot may accumulate positions that move against you. Consider starting with small amounts to understand the strategy before committing larger capital.


---

# 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://docs.dextrabot.com/grid-bot/extended-grid-bot.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.
