> 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/grids/recipes/selling-at-the-best-price-with-minimum-price-and-balance-constraints.md).

# Selling at the best price with minimum price and balance constraints

Grid recipe: sell at the best available price without going below a minimum ask price, with order sizes tied to your balance.

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

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: `1+gap*(order_pos-1)`

`min_ask_price` in this case :

`orderbook().bid[0].price+symbol().price_precision`

**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&#x26;token=1aadee2e-3c88-4639-8160-f61a7d9d2415" alt=""><figcaption></figcaption></figure>

`10/execute_price+abs(order_pos)*10/execute_price`

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&#x26;token=c7f9a9d7-9679-49fb-8e9b-4a4b91a62c6e" alt=""><figcaption></figcaption></figure>

`group_balance('counter').current.total`

`5 if group_balance('counter').current.total < 5000 else 0`

or based on the token balanc&#x65;**.** `base balance('base').total`

`5 if balance('base').total > 5000 else 0`
