I agree with Grant 100%.
If you want a simpler method you can set per stock limits. That is the method suggested by the example source code.
# In these two lines, we set the maximum and minimum we want our algorithm
# to go long or short our security. You don't have to set limits like this
# when you write an algorithm, but it's good practice.
context.max_notional = 1000000.1
context.min_notional = -1000000.0
The idea is that you would check the amount the stock is long (or short) against those limits and stop buying (shorting) once they are reached.
The problem with this "simple" approach is that you may still end up borrowing a large amount of cash if you are trading multiple stocks.
# check cash position of stock
shares = context.portfolio.positions[context.aapl].amount
dollars = shares * context.portfolio.positions[context.aapl].cost_basis
if dollars < context.max_notional and dollars > context.min_notional: