Hello Vijay,
I'll fill you in where I can, and others can confirm or correct my feedback:
--It says handle_data is called whenever "a market event occurs for any of your algorithm's specified securities." What classifies as a market event?
Basically a "market event" is an entry in the Quantopian backtest database listing historical trade data for a security identified by a sid number (rather than a symbol). The available data are listed under "Event Properties" on the help page. There are actually two market event databases, one daily and one minutely. As I understand, the database entries don't correspond to actual historical market events but are valid proxies for backtesting. As a side note to the Quantopian team, I am curious how the database is derived...does your vendor openly publish the details?
--How often is handle_data called (at most) when it's doing daily vs minute backtesting?
As implied, handle_data is called once per day under daily backtesting and once per minute under minutely backtesting. However, handle_data will not be called if there are no market data for the specified securities on a given day or in a given minute.
--What about when there are multiple securities in your context? Multiple events could be happening for various securities; does this mean handle_data is called one for each event for every security?
When there are multiple securities, the handle_data method only gets called once per market tic. Within that call, your algorithm then can then loop through some or all of the specified securities.
--How does a corresponding order work for handle_data when dealing with multiple securities? That is, if a market event deals with one security, do I still have to place an order for all the securities?
To my knowledge, orders can only be placed on individual securities. You can't define a group of securities and then, for example, buy 100 shares of each with a single order. However, it is straightforward to loop through a list of securities to place orders.
--What is being plotted on the backtest graph when dealing with multiple securities? That is, I only see one graph as opposed to one graph for each security.
The backtest graph plots the overall return of the algorithm. Reportedly, Quantopian is working on the means to add additional time-series data to the graph.
A few more notes:
Regarding multiple securities, I found it instructive to run both liquid and thinly traded securities, to understand how the backtester handles these when multiple securities are specified. An example:
context.stocks = [sid(41290),sid(41425),sid(39479),sid(33972),sid(41159)]
Additionally, the "order" method described on the help page is really a "submit_order" method. The order does not get fulfilled until the next market event for the security being transacted (and to my knowledge, there is no way to modify an order once it has been submitted, e.g. cancel it).
Grant