> 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

&#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="/files/AVQCNTkiTlz1f5E9F6no" 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="/files/ZTRxYsmimvgwhikBRbV4" 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>
