MAINT: More precise extraction of returns from returns container.

Use slice to date, `[:dt]` instead of `pd.Series.valid` to extract
from returns containers.

Using `valid` lead to some confusion when debugging tests, because
it papers over missing data.

The use of `.valid` was based on the assumption that all values
from the zeroth date to the current algo date are populated,
with no trailing values.
`[:dt]` extracts the same data, but in a hopefully more precise
and explicit fashion.
ENH: Add simulated random trade source.

This adds a new data source that emits events
with certain user-specified frequency (minute
or daily).

This allows users to backtest and debug an
algorithm in minute mode to provide a cleaner
path towards Quantopian.
MAINT: Using dictionary literal syntax and combining lines

for readability
MAINT: Set initial values so to_dict can be called immediately

Previously, it would raise an exception.
MAINT: Remove unused members of TradingEnvironment.

The following members are no longer referenced elsewhere:
- `full_trading_day`
- `early_close_trading_day`
BUG: check that self.logger exists

`self.logger` is initialized as `None` and there is no guarantee that
users have set it, so check that it exists before trying to pass
messages to it.
MAINT: Factor out downside risk calculation.

Move the downside risk calculation into the main risk module;
so that the same calculation can eventually be used by both
the period and cumulative calculations, to prevent implementation
drift.
Add symbol to __all__

Currently symbol is not in __all__. So added it.
STY: PEP8 fixes.
TST: Disable talib default params test.

The data zipline_transform.window is always evaluating to empty,
thus the actual checks are not being used because of the
`if not data` done before running the `asserts`.

This behavior should be fixed, and we should either remove the
`not data` check, or bubble up that the check is being hit too
many times; but in the meantime, disabling this test which takes
a non-trivial amount of time to run.

When run as an algorithm, outside of unit tests the talib wrapper
does work, so the cause of the window always being empty may be to
due to the machinery of the unit test.
MAINT: Use current_data instead of last_sale_price

It seems more clear to get price values from
`self.trading_client.current_data[sid].price` than
from `self.portfolio.positions[sid].last_sale_price`.

The two values are the same, so this is just a readability change,
but it is also the same behavior as in `self.order_value()` and it's
good to have them all be the same.
BUG: Fix misalignment of downside series calc when using exact dates.

An oddity that was exposed while working on making the return series
passed to the risk module more exact, the series comparison between
the returns and mean returns was unbalanced, because the mean returns
were not masked down to the downside data points; however, in most,
if not all cases this was papered over by the call to `.valid()`
MAINT: Change variable name in test transforms comprehension.

Using `n` conflicts with using `n` in an interactive debugger, like
pdb. Use `name` instead.
MAINT: Remove unused setup from trading calendar test.

The values in the setup are unused in the test suite, so remove.

Also remove imports.
BUG: Random source did not generate last days' event
BUG: Prevent out of sync market closes in performance tracker.

In situations where the performance tracker has been reset or patched
to handle state juggling with warming up live data, the `market_close`
member of the performance tracker could end up out of sync with the
current algo time as determined by the

The symptom was dividends never triggering, because the end of day
checks would not match the current time.

Fix by having the tradesimulation loop be responsible, in minute/minute
mode, for advancing the market close and passing that value to the
performance tracker, instead of having the market close advanced by
the performance tracker as well.
ENH: Remove dependency on benchmark for trading day calendar.

Instead of the benchmarks' index, use the trading calendar to
populate the environment's trading days.

Remove `extra_date` field, since unlike the benchmarks list,
the trading calendar can generate future dates, so dates for
current day trading do not need to be appended.

Motivations:
- The source for the open and close/early close calendar and the
  trading day calendar is now the same, which should help prevent
  potential issues due to misalignment.
- Allows configurations where the benchmark is provided as a
  generator based data source to need to supply a second benchmark
  list just to populate dates.
TST: Use benchmark returns from spreadsheet.

The risk unit tests were using the public Yahoo! data instead
of the returns from the answer key spreadsheet, change the RiskPeriod's
created in tests to use the values in the benchmark returns
column of the answer key.

Also, change the spreadsheet's benchmark volatility calculation
to use sample.
The use of population was exposed when the input values were
corrected.
BLD: Peg CI versions of lint checker libraries.

Match the revisions found in the dev requirements file, so that the
versions used during development and continuous integration.

Pegging the versions in two separate places may end being brittle,
but suppress the build failure because the unpegged installation
of flake8 pulled in newer versions of pyflakes and pep8.
ENH: Add OHLC to simulated data source