ENH: Factor out API methods. Add support for algo scripts.

This is a step towards the goal of uniting Quantopian scripts
and zipline.

To make the syntax of zipline identical to Quantopian
we break out the API methods (like order) and turn them into
functions. To access the algo object we add a thread local reference
to the current algorithm that is accessed in the API functions.

TradingAlgorithm now takes either a string or two functions
(initialize and handle_data) that it executes.

Use api method decorator for methods available in algoscript.

Ported appropriate algorithm tests from internal code.
ENH: Add Brazilian calendar for BMF&Bovespa stock market

Add Brazilian Bovespa Stock Market calendar
BLD: Update to latest Cython release.

0.19.2 -> 0.20
BLD: Update to latest tornado release.

Used by IPython notebook, update version from 3.1.1 to 3.2
BLD: Add mock to requirements file.

mock was recently added as part of the testing of port of the script
API for algorithms.
BUG: Fix typo in requirements file.

Fix incorrect number of '='
MAINT: Use more exact boolean checks for pandas structures.

To prepare for being compatible with pandas==0.13.0, which is stricter
on boolean checks.
BUG: adjust benchmark events to match market hours

Previously benchmark events were emitted at 0:00 on the day the
benchmark related to: in 'minute' emission mode this meant that
the benchmarks were emitted before any intra-day trades were
processed.

See: https://github.com/quantopian/zipline/issues/241
BUG: ensure perf stats are generated for all days

When running with minutely emissions the simulator would report to the
user that it simulated 'n - 1' days (where n is the number of days
specified in the simulation params).  Now the correct number of trading
days are reported as being simulated.
BUG: NoopAlgorithm requires initialize().
Merge branch to adjust benchmark times in minute mode.
ENH: Add hdf5 and csv source.

This creates a data source for csv and hdf5 files, a generator to create a sample csv, and a pytables generator to go from a list of dated gzipped csv's in a directory to a pytables data source.

This does not add a unittest yet which we should write for the future.
BUG: Python 3 fix.
BUG: Fix repr for cumulative risk metrics.

The __repr__ for RiskMetricsCumulative was referring to an older
structure of the class, causing an exception when printed.

Convert to printing the last values in the metrics DataFrame.
BLD: Update TA-Lib to latest version.

Keeping current with TA-Lib release.
Also, TA-Lib 0.4.7 has been removed from PyPI, so 0.4.8
is required for fresh PyPI based installs.
MAINT: Allow sim_params to provide data frequency for the algorithm.

In the case that data_frequency of the algorithm is None,
allow the sim_params to provide the data_frequency.

For less redundancy when setting up an algorithm.
MAINT: Always defer to the algorithms data frequency.

For compatibility with existing behavior of having the,
data_frequency of the algorithm override the simulation parameters.

We may want to consider throwing an exception if the two do not match.
BUG: Prevent minute emission from crashing at end of available data.

The next day calculation was causing an error when a minute
emission algorithm reached the end of available data.

Instead of a generic exception when available data is reached,
raise and catch a named exception so that the tradesimulation loop
can skip over, since the next market close is not needed at the end.
ENH: Limit handle_data to times with market data.

To prevent cases where custom data types had unaligned timestamps,
only call handle_data when market data passes through.

Custom data that comes before market data will still update
the data bar. But the handling of that data will only be done
when there is actionable market data.
BUG: Fix pandas indexing in trading calendar.