By default, each buy() is for 1 unit. A sizer decides for you how many units to buy or sell; you add it with cerebro.addsizer().
cerebro.addsizer(bt.sizers.FixedSize, stake=10) always buys 10 units: it is a fixed size, simple but blind to price and volatility.
cerebro.addsizer(bt.sizers.PercentSizer, percents=20) commits about 20% of the available cash: the size adapts to the price and to how the capital evolves.
For a custom rule, such as risking 1% of capital between entry and stop, you write a class inheriting from bt.Sizer and code _getsizing(). A size passed directly to buy() still takes priority.
Examples
SIZE-X (fictional market) : Near the green line (low price), the same stake buys many units; near the red line (high price), it buys fewer. A percentage sizer does this calculation for you at each entry.
The Kelly criterion (1956) : In 1956, John Kelly, a researcher at Bell Labs, published a formula that sets the share of capital to commit according to the edge you have. This “Kelly criterion” is known to be very aggressive: many practitioners only use a fraction of it to limit drops in capital.