First off, Welcome to Quantopian.
The code above simply makes a list of all the securities we want to hold long positions for.
context.longs will be a python list of security objects. At this point there is no calculation for 'how much'. It's also not actually ordering anything at this point.
In that same lecture (Pipeline Tutorial - Lesson 12 "Moving to the IDE") there is a function called
compute_target_weights. That is where the algo takes the
context.longs list and now assigns a weight to each position. The result is a python dic object. Most times the ordering on Quantopian is thought of as a 'target weight'. In other words, we'd like to place an order so our final position will represent X percent of our portfolio. That isn't required though. One can place an order for a specific number of shares, or a specific dollar value, or several other ways (see all the order types in the docs here)
The specific order type where one specifies 'volume', or quantity of shares, is the basic
order type (see https://www.quantopian.com/docs/api-reference/algorithm-api-reference#quantopian.algorithm.order)
my_stock = symbol('AAPL')
qty_of_shares = 120
The second question "why is [the leverage] so low in Quantopian algorithms". The Quantopian definition of leverage is the "sum of the absolute value of long and short positions divided by the total portfolio value". If a portfolio is all cash, the leverage will be 0. If one has no cash but also hasn't dipped into their margin, the leverage will be 1. If one has bought shares worth 120% of the portfolio value (ie bought an additional 20% using margin), the leverage will be 1.2.
Realistic margin levels are between 0-2. Brokers do let you go higher for intra-day trading though. However, when building an algo it's best to assume a leverage of 1. When complete, scale up (or down) the leverage to see the performance impact. Typically, measures like return, volatility, and drawdown will scale linearly with leverage but there are always exceptions. One thing to note. Currently, margin interest is not calculated by the backtester. This will make highly leveraged algos look better than they really are.
Good questions! Hope that helps.