# Create Grid

## **Before Creating a Grid**

#### 1. **Ensure the following prerequisites are completed:**

* **Create a project**: Follow the steps to create a new project.
* **Add an account**: Link your exchange account to the platform.
* **Create a bot**: Set up a bot with the necessary parameters.

#### 2. **Proceed to create a grid:**

Once the above steps are completed, click the **plus button ("+")** to begin configuring the grid.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FDDHWj6hNZ9kF5rnqplyh%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2015.55.32.png?alt=media&#x26;token=bc81d2eb-1236-4bce-ba02-78b4a199d7fa" alt="how to Create Grid on origami tech"><figcaption></figcaption></figure>

## **Creating a Grid: Initial Setup**

#### **1. Click the "+" button**

After clicking the **plus button ("+")**, a basic grid configuration will automatically appear, pre-filled with default values.

#### **2. Default settings**

* A single **buy order** will be placed at the **last trade price** for the current pair and exchange, as determined by the bot's configuration ( [<mark style="color:blue;">`ticker`</mark>](https://docs.origami.tech/function/functions/ticker)`()`).
* The **order size** is set to **100 tokens** of the base currency ([<mark style="color:blue;">Base</mark>](https://docs.origami.tech/function/shortcuts#base)).

These pre-filled values provide a quick start, allowing you to adjust further settings as needed.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FTCoVpVNft5NgrNiCnlbo%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-20%20%D0%B2%2016.48.39.png?alt=media&#x26;token=5a37cd3d-6d1f-4975-a177-691062296750" alt="Create Grid on origami tech "><figcaption></figcaption></figure>

## Mandatory Fields:

### 1. [<mark style="color:purple;">execute\_price</mark>](https://docs.origami.tech/function/required-parameters/execute-price):&#x20;

* **Type**: Number
* **Description**: The price levels at which orders will be placed.
* **Formula**: Prices are calculated based on the parameter **order\_pos**, which determines the relative position of the orders.
  * **For Buy Orders**: The `order_pos` parameter takes values in the range `[-1,...,-`[<mark style="color:purple;">`buy_orders_count`</mark>](https://docs.origami.tech/function/required-parameters/buy-orders-count)`].`
  * **For Sell Orders**: The `order_pos` parameter takes values in the range`[1,...,`[<mark style="color:purple;">`sell_order_count`</mark>](https://docs.origami.tech/function/required-parameters/sell-orders-count)`]`.

This parameter ensures the grid accurately places multiple orders at varying price levels, both above and below the market price.

<details>

<summary>Example:</summary>

[<mark style="color:blue;">`ticker`</mark>](https://docs.origami.tech/function/functions/ticker)<mark style="color:red;">`()`</mark>&#x20;

[<mark style="color:blue;">`orderbook`</mark>](https://docs.origami.tech/function/structures#orderbook)<mark style="color:red;">`().`</mark>[<mark style="color:blue;">`bid`</mark>](https://docs.origami.tech/function/structures#groupbalance)<mark style="color:red;">`[0].`</mark>[<mark style="color:blue;">`price`</mark>](https://docs.origami.tech/function/structures/orderbook)&#x20;

[<mark style="color:blue;">`orderbook`</mark>](https://docs.origami.tech/function/structures#orderbook)<mark style="color:red;">`().`</mark>[<mark style="color:blue;">`ask`</mark>](https://docs.origami.tech/function/structures/orderbook)<mark style="color:red;">`[0].`</mark>[<mark style="color:blue;">`price`</mark>](https://docs.origami.tech/function/structures/orderbook)<mark style="color:red;">`* (1 +`</mark> [<mark style="color:blue;">`order_pos`</mark>](https://docs.origami.tech/function/pre-defined-parameters#order_pos-integer) <mark style="color:red;">`* 0.005)`</mark>&#x20;

<mark style="color:red;">`1000.05`</mark>

<mark style="color:red;">`1000.05 * (1 +`</mark> [<mark style="color:blue;">`order_pos`</mark>](https://docs.origami.tech/function/pre-defined-parameters#order_pos-integer)<mark style="color:red;">`* 0.005)`</mark>&#x20;

<mark style="color:red;">`1000 if`</mark> [<mark style="color:blue;">`side`</mark>](https://docs.origami.tech/function/pre-defined-parameters#side-string)<mark style="color:red;">`=='`</mark>[<mark style="color:blue;">`buy`</mark>](https://docs.origami.tech/function/pre-defined-parameters#order_pos-integer)<mark style="color:red;">`' else 1500`</mark>

</details>

### **2.** [<mark style="color:purple;">execute\_volume</mark>](https://docs.origami.tech/function/required-parameters/execute-volume#execute_volume-decimal-or-formula-greater-than-decimal):

* **Type**: Number
* **Description**: The trading volume for each order, expressed in the **Base** token.
* **Formula**: The volume is calculated based on the **order\_pos** parameter:
  * **For Buy Orders**: `order_pos` takes values from `[-1,...,-`[<mark style="color:purple;">`buy_orders_count`</mark>](https://docs.origami.tech/function/required-parameters/buy-orders-count)`].`
  * **For Sell Orders**: `order_pos` takes values from `[1,...,`[<mark style="color:purple;">`sell_order_count`</mark>](https://docs.origami.tech/function/required-parameters/sell-orders-count)`]`.

This parameter determines the amount of the base currency to be traded at each price level, ensuring consistent volume allocation across the grid.

<details>

<summary>Example:</summary>

[<mark style="color:blue;">`orderbook`</mark>](https://docs.origami.tech/function/structures#orderbook)<mark style="color:red;">`().`</mark>[<mark style="color:blue;">`ask`</mark>](https://docs.origami.tech/function/structures/orderbook)<mark style="color:red;">`[0].`</mark>[<mark style="color:blue;">`amount`</mark>](https://docs.origami.tech/function/structures/orderbook)

[<mark style="color:blue;">`orderbook`</mark>](https://docs.origami.tech/function/structures#orderbook)<mark style="color:red;">`().`</mark>[<mark style="color:blue;">`bid`</mark>](https://docs.origami.tech/function/structures#groupbalance)<mark style="color:red;">`[0].`</mark>[<mark style="color:blue;">`amount`</mark>](https://docs.origami.tech/function/structures/orderbook)<mark style="color:red;">`* (1 +`</mark> [<mark style="color:blue;">`order_pos`</mark>](https://docs.origami.tech/function/pre-defined-parameters#order_pos-integer) <mark style="color:red;">`* 0.005)`</mark>&#x20;

<mark style="color:red;">`5250.75`</mark>&#x20;

<mark style="color:red;">`5250.75 /`</mark>[<mark style="color:blue;">`execute_price`</mark>](https://docs.origami.tech/function/required-parameters/execute-price)

<mark style="color:red;">`5250.75 /`</mark> [<mark style="color:blue;">`ticker`</mark>](https://docs.origami.tech/function/functions/ticker)<mark style="color:red;">`()`</mark>&#x20;

<mark style="color:red;">`1000.05 +`</mark> [<mark style="color:blue;">`order_pos`</mark>](https://docs.origami.tech/function/pre-defined-parameters#order_pos-integer) <mark style="color:red;">`* 0.005`</mark>&#x20;

<mark style="color:red;">`1000 if`</mark> [<mark style="color:blue;">`side`</mark>](https://docs.origami.tech/function/pre-defined-parameters#side-string)<mark style="color:red;">`=='`</mark>[<mark style="color:blue;">`buy`</mark>](https://docs.origami.tech/function/pre-defined-parameters#order_pos-integer)<mark style="color:red;">`' else 1500`</mark>

</details>

### **3.** [<mark style="color:purple;">buy\_order\_count</mark>](https://docs.origami.tech/function/required-parameters/buy-orders-count):

* **Type**: Number
* **Description**: The number of buy orders (**bid**) to be placed for the [**Base** ](https://docs.origami.tech/function/shortcuts/base#base)token.
* **Formula**: Defines the total count of buy orders, with prices determined using the **order\_pos** parameter in the range `[-1,...,-`[<mark style="color:purple;">`buy_orders_count`</mark>](https://docs.origami.tech/function/required-parameters/buy-orders-count)`]`.

### **4.** [<mark style="color:purple;">**sell\_order\_count**</mark>](https://docs.origami.tech/function/required-parameters/sell-orders-count#sell_orders_count-integer-or-formula-greater-than-integer)**:**

* **Type**: Number
* **Description**: The number of sell orders (**ask**) to be placed for the  [**Base**](https://docs.origami.tech/function/shortcuts/base#base) token.
* **Formula**: Defines the total count of sell orders, with prices determined using the **order\_pos** parameter in the range `[1,...,`[<mark style="color:purple;">`sell_order_count`</mark>](https://docs.origami.tech/function/required-parameters/sell-orders-count)`]`.

These parameters ensure that the grid creates the specified number of buy and sell orders at their respective price levels.

<details>

<summary>Example:</summary>

<mark style="color:red;">`5`</mark>&#x20;

<mark style="color:red;">`5 if`</mark> [<mark style="color:blue;">`ticker`</mark>](https://docs.origami.tech/function/functions/ticker)<mark style="color:red;">`() > 0.05 else 0`</mark>&#x20;

<mark style="color:red;">`5 if`</mark> [<mark style="color:blue;">`balance`</mark>](https://docs.origami.tech/function/functions/balance)<mark style="color:red;">`('counter').`</mark>[<mark style="color:blue;">`total`</mark>](https://docs.origami.tech/function/technical-analysis/stop-and-reverse) <mark style="color:red;">`< 5000 else 0`</mark>&#x20;

<mark style="color:red;">`5 if`</mark> [<mark style="color:blue;">`group_balance`</mark>](https://docs.origami.tech/function/structures/groupbalance)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`base`</mark>](https://docs.origami.tech/function/shortcuts/base)<mark style="color:red;">`').`</mark>[<mark style="color:blue;">`current`</mark>](https://docs.origami.tech/function/technical-analysis/relative-strenght-index)<mark style="color:red;">`.`</mark>[<mark style="color:blue;">`total`</mark>](https://docs.origami.tech/function/technical-analysis/stop-and-reverse) <mark style="color:red;">`> 10000 else 0`</mark>

</details>

## **Optional Fields**

### 1. [<mark style="color:purple;">time\_between\_orders</mark>](https://docs.origami.tech/function/optional-parameters/time-between-orders):&#x20;

* **Type**: Number
* **Description**: The time interval (in seconds) between placing successive orders in a single grid.
* **Purpose**: Reduces the frequency of API requests to the exchange, helping avoid exceeding the exchange's rate limits.

### 2. [<mark style="color:purple;">**sleep\_after\_seconds**</mark>](https://docs.origami.tech/function/optional-parameters/sleep-after-seconds#sleep_after_seconds-greater-than-decimal):

* **Type**: Number
* **Description**: The time interval (in seconds) between grid updates.
* **Purpose**: Controls how often the grid is refreshed, balancing performance and API usage efficiency.

These fields are not mandatory but can optimize grid operations by managing API request frequency and reducing the likelihood of exceeding exchange limits.

<details>

<summary>Example:</summary>

<mark style="color:red;">`300`</mark>&#x20;

<mark style="color:red;">`300 * (1 +`</mark> [<mark style="color:blue;">`random`</mark>](https://docs.origami.tech/function/functions/random)<mark style="color:red;">`())`</mark>&#x20;

<mark style="color:red;">`300 + 150 *`</mark> [<mark style="color:blue;">`random`</mark>](https://docs.origami.tech/function/functions/random)<mark style="color:red;">`()`</mark>

</details>

## **Post-Only**

* **Description**: When this option is enabled, users act as market makers.
* **Functionality**:
  * If the **Post-Only** option is selected, any limit order you place will never immediately match with an existing order in the order book.
  * Instead, it ensures that your order always enters the order book as a maker order, providing liquidity rather than taking it.

This option is useful for users looking to avoid taker fees or ensure their orders contribute to market liquidity.

## **Working with the Grid**

### 1. **Activating the Grid**

* To activate the grid, toggle the **Toggle Switch** to the **enabled** state.

This action will initiate the grid and start executing the configured trading strategy.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2Fp9RAjvH1HghovBuWwSL2%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.07.47.png?alt=media&#x26;token=0b8b2a8e-6b49-4baf-840e-fead88952e5d" alt="activating grid on origami tech"><figcaption></figcaption></figure>

## **Adding Additional Parameters**

* To create and configure additional parameters for your grid, click the **+ Add Row** button.

This allows you to define custom settings or expand the functionality of your grid configuration as needed.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FOOIYIjwHesvikLKLzbOn%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.10.00.png?alt=media&#x26;token=c6f06f46-560f-4736-8cda-4345ee3526bb" alt="adding parameters to the grid"><figcaption></figcaption></figure>

## **Configuring Additional Parameters**

### **1. Enter Variable Name and Value**

* In the newly added row, input the **variable name** and its corresponding **value**.
* You can create auxiliary parameters to be used in formulas for more advanced configurations.

### 2. **Save Changes**

* After making any adjustments to the grid, ensure you **save the changes** to apply the new settings.

This approach enables dynamic and flexible grid customization tailored to specific trading strategies.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FBaQukLJ3dNVull2kJx0C%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.35.36.png?alt=media&#x26;token=8d9374a8-73d9-4ff6-8a4d-ac887c636216" alt="save changes on origami tech new grid"><figcaption></figcaption></figure>

## **Previewing Calculated Orders**

* To view the pre-calculated orders based on the logic defined in the grid, click the **Research** button.

This feature allows you to verify and analyze the orders before activation, ensuring the grid is configured correctly and aligns with your trading strategy.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2F1FxpkNNJBYZSDSu5glPJ%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-23%20%D0%B2%2000.59.43.png?alt=media&#x26;token=f2f877ec-75be-460e-bff5-e6006360d345" alt="Previewing Calculated Orders on origami tech"><figcaption></figcaption></figure>

#### Custom parameter with floating point (decimal) value

It is possible to create custom parameters with decimal or integer value

*Example:*

*Create custom parameter <mark style="color:red;">`spread`</mark>* *and use it in* [<mark style="color:purple;">execute\_price</mark>](https://docs.origami.tech/function/required-parameters/execute-price)

#### Custom formula

Also, it is possible to create custom formula as parameter’s value and use parameter’s key as alias for it.

1. Define new parameter with some name (ex:  <mark style="color:red;">`spread`</mark>)
2. Define parameter value with some formula (ex: [<mark style="color:blue;">`random`</mark>](https://docs.origami.tech/function/functions/random)<mark style="color:red;">`() * 2`</mark>)

An example of using additional parameters to set a grid with a spread of 1% and a step of 2% for subsequent orders.

```json
{
"execute_price": "ticker() * (1 - spread / 2 + order_pos * gap if side=='buy' else 1 + spread / 2 + order_pos * gap)",
"execute_volume": "50 / execute_price",
"buy_orders_count": "3",
"sell_orders_count": "3",
"spread": "0.01",
"gap": "0.02"
}
```

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FcV0nkNr0ayjfmZInRB4z%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.39.08.png?alt=media&#x26;token=8baa1043-9751-4361-bf6d-2b37fa12a15d" alt="creating custom formula on the grid for origami tech"><figcaption></figcaption></figure>

## **Editing in JSON Format**

### 1. **Switch to JSON Mode**

* Click the **Turn into JSON** button to enable editing the grid in JSON format.

### 2. Use Cases:

* Quickly **insert** a previously saved or pre-written grid configuration.
* **Copy** the current grid settings for reuse or backup.
* Make detailed edits directly in the JSON structure for faster and precise adjustments.

### 3. Save Changes

* After editing, ensure you save the configuration to apply the updates.

This feature is ideal for users who prefer direct JSON manipulation or need to efficiently manage complex grid setups.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FLSumNPfjdLOOjVuMzmPX%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.35.36.png?alt=media&#x26;token=b5b0091c-f4ee-46ac-9027-1d1dec5e2417" alt="save changes on the grid on origami tech"><figcaption></figcaption></figure>

## **Verifying Variables Before Saving**

1. **Preview Variables**
   * Before saving your changes in JSON format, click the **Show Form** button.
2. **Purpose**:
   * This step ensures that all variables and parameters are correctly recorded and properly mapped to the grid's logic.
3. **Save Changes**
   * Once verified, proceed to save the configuration to finalize the grid setup.

This process helps avoid errors and ensures the grid operates as intended.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FjoO9LYhIzJeMoEfeqC2S%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.47.15.png?alt=media&#x26;token=35f66280-9c05-4e59-aed6-99dad3a27865" alt="Verifying Variables Before Saving on origami tech"><figcaption></figcaption></figure>

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2F2RwCXk2TAuMetooouJvk%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.51.30.png?alt=media&#x26;token=243bf404-0c21-454a-bda2-c184d23aa23e" alt="save form and Verifying Variables Before Saving"><figcaption></figcaption></figure>

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2F6zwST3VZ4IC0sHkPXbf5%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202024-12-22%20%D0%B2%2016.51.48.png?alt=media&#x26;token=6435e9f2-80e0-4406-8197-dac69c6a63bc" alt="bot grid set up on origami tech"><figcaption></figcaption></figure>

***


---

# 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.origami.tech/user-guide/create-grid.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.
