It seems your notional variable is not managed correctly. Be careful both how you initialize it, how you update it (+= or -=?), and how you use it in conditions. Also, I don't think you should limit your portfolio to a fixed amount - you want it to grow, don't you?
Instead, you should look at available cash. Quantopian maintains context.portfolio.cash for you, but updates it not at the time you send your order, but as your order is filled, in whole or in part. For this reason, a typical Quantopian approach is to do no trading when there are any outstanding orders.
You should also take commissions into account when calculating the number of shares you can afford. (And slippage, but I'll leave it as an exercise for the reader.)
Thus, if you want to buy stocks in chunks limited to $7000 and the available cash, you could use something like this:
cpt, cps = 0.0, 0.03 # commission in USD per trade, per share
if not get_open_orders():
for stock in context.stocks:
current_price = data[stock].price
if ...: # buying stock
number_of_shares = int((min(7000, context.portfolio.cash)-cpt)/(current_price+cps))
if number_of_shares > 0:
order(stock, number_of_shares)
log.info("Buying {}*{}@${}=${}, commission ${}".format(number_of_shares, stock.symbol,
current_price, number_of_shares*current_price,
cpt+number_of_shares*cps))
return # order nothing more this time, wait until this order is filled in full