> For the complete documentation index, see [llms.txt](https://docs.origami.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.origami.tech/user-guide/grids-examples/selling-at-the-best-price-with-minimum-price-and-balance-constraints.md).

# Selling at the Best Price with Minimum Price and Balance Constraints

Learn to configure Origami Tech grid strategies to sell assets at optimal prices while maintaining defined balance and price constraints.

&#x20;Grid 1: Selling at the Best Price with Minimum Price and Balance Constraints

```json
{
"gap": "0.005",
"execute_price": "max(orderbook().ask[0].price-symbol().price_precision,min_ask_price)*(1+gap*(order_pos-1))",
"min_ask_price": "orderbook().bid[0].price+symbol().price_precision",
"execute_volume": "10/execute_price+abs(order_pos)*10/execute_price",
"buy_orders_count": "0",
"sell_orders_count": "5 if balance('counter').total < 5000 else 0"
}
```

**The grid places sell orders at the best price.**\
An additional parameter, **gap**, is used to calculate the order prices. In this example, it is set to **0.5%**, and the price increment is calculated as: <mark style="color:red;">`1+gap*(`</mark>[<mark style="color:blue;">`order_pos`</mark>](/function/pre-defined-parameters/order-pos.md)<mark style="color:red;">`-1)`</mark>

<mark style="color:red;">`min_ask_price`</mark> in this case :

<mark style="color:red;">`orderbook().bid[0].price+symbol().price_precision`</mark>

**Sets the minimum sell price to 1 price\_precision above the best bid.**\
A specific number can also be used as a constraint.

* **execute\_volume**: Sets the order volume in **Base** tokens.
  * For the first order, the volume corresponds to **20 Counter tokens**.
  * For each subsequent order, the volume increments by **10 Counter tokens**.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FePjaaWbfxDW5RFocW7l8%2Fimage.png?alt=media&amp;token=1aadee2e-3c88-4639-8160-f61a7d9d2415" alt=""><figcaption></figcaption></figure>

<mark style="color:red;">`10/`</mark>[<mark style="color:blue;">`execute_price`</mark>](/function/required-parameters/execute-price.md)<mark style="color:red;">`+`</mark>[<mark style="color:blue;">`abs`</mark>](/function/functions/abs.md)<mark style="color:red;">`(`</mark>[<mark style="color:blue;">`order_pos`</mark>](/function/pre-defined-parameters/order-pos.md)<mark style="color:red;">`)*10/`</mark>[<mark style="color:blue;">`execute_price`</mark>](/function/required-parameters/execute-price.md)

Orders will be placed until the balance of the Counter token exceeds 5000.

<figure><img src="https://3075831504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh6BkURa7HNU017yGuhBt%2Fuploads%2FSqo97gV3hDnK1KwnGvLs%2Fimage.png?alt=media&amp;token=c7f9a9d7-9679-49fb-8e9b-4a4b91a62c6e" alt=""><figcaption></figcaption></figure>

<mark style="color:red;">`group_balance('counter').current.total`</mark>

<mark style="color:red;">`5 if group_balance('counter').current.total < 5000 else 0`</mark>

or based on the token balanc&#x65;**.** <mark style="color:red;">`base balance('base').total`</mark>

<mark style="color:red;">`5 if balance('base').total > 5000 else 0`</mark>
