> 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/function/required-parameters/buy-orders-count.md).

# Buy Orders Count

## <mark style="color:purple;">`buy_orders_count`</mark> \[*integer* | *formula* -> \[*integer*]]

Non-negative number of <mark style="color:red;">`side=’`</mark>[<mark style="color:blue;">`buy`</mark>](/function/pre-defined-parameters/side.md)<mark style="color:red;">`’`</mark> orders to place. Accepts values of integer and decimal types. It is possible to use <mark style="color:red;">`formula`</mark> as value.  If-else logic is also supported. When using float values, they are rounded down to the nearest whole number.

<details>

<summary>Example:</summary>

2 buy orders will be placed.

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

***

5 buy orders will be placed if the current total base token balance less than 5000.

<mark style="color:red;">`"buy_orders_count": "5 if`</mark> [<mark style="color:blue;">`balance`</mark>](/function/structures/balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`base`</mark>](/function/shortcuts.md#base)<mark style="color:red;">`').total < 5000 else 0"`</mark>

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

***

5 buy orders will be placed if the current total counter token group balance exceeds 5000.

<mark style="color:red;">`"buy_orders_count": "5 if`</mark> [<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`counter`</mark>](/function/shortcuts/counter.md)<mark style="color:red;">`').current.total > 5000 else 0"`</mark>

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

***

A buy order will be placed if the current total base token group balance is lower than the starting one and the first ask price is lower than the fair price, which is calculated based on the ratio of the differences in the starting and current balances of the base token and counter token.

<mark style="color:red;">`"buy_orders_count": "1 if`</mark> [<mark style="color:blue;">`orderbook`</mark>](/function/functions/orderbook.md)<mark style="color:red;">`().ask[0].price < (`</mark>[<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`base`</mark>](/function/shortcuts/base.md)<mark style="color:red;">`').start.total -`</mark>[<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`base`</mark>](/function/shortcuts/base.md)<mark style="color:red;">`').current.total)/(`</mark>[<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`counter`</mark>](/function/shortcuts/counter.md)<mark style="color:red;">`').current.total -`</mark>[<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`counter`</mark>](/function/shortcuts/counter.md)<mark style="color:red;">`').start.total) and`</mark> [<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`base`</mark>](/function/shortcuts/base.md)<mark style="color:red;">`').start.total >`</mark> [<mark style="color:blue;">`group_balance`</mark>](/function/functions/group-balance.md)<mark style="color:red;">`('`</mark>[<mark style="color:blue;">`base`</mark>](/function/shortcuts/base.md)<mark style="color:red;">`').current.total else 0"`</mark>

```
1 if orderbook().ask[0].price < (group_balance('base').start.total-group_balance('base').current.total)/(group_balance('counter').current.total-group_balance('counter').start.total) and group_balance('base').start.total > group_balance('base').current.total else 0
```

***

Random number of buy order will be placed in range \[0, 10], rounded down.

<mark style="color:red;">`"buy_orders_count": "`</mark>[<mark style="color:blue;">`random`</mark>](/function/functions/random.md)<mark style="color:red;">`() * 10"`</mark>

```
random() * 10
```

</details>
