`for s in data` and methods like `for s in data.keys` were not producing
the same list of active sids
Make the other iteration methods match __iter__ by using the contains
method to check whether or not the sid is active.
For use of data outside of the algoscript context, which needs access
to all data fields use data._data
A bug in the create_random_simulation_parameters allows the period
start to be a non-trading day.
That bug was causing the commission tests to randomly fail, e.g.
when the period start was on Good Friday, because the commission was
created on hour three of Good Friday, instead of the next Monday.
When it hit that case, the test commission is never processed.
Defend against that bug by using the first open of the simulation
parameters which is more guaranteed to be during market hours,
when creating the test commission.
This is in place of fixing the bug in the random parameters function
or making the parameters non-random, which are other potential fixes.
So that each reference to `.portfolio` in the algoscript,
cache the value of the portfolio, and mark the need for a new
value at the end of each dt in the tradesimulation loop.
The market_open_and_close method was a performance bottleneck,
since it was creating new dates on each query for open and close.
Instead use the pre-rendered frame of open and closes values
from the trading environment.
The code that was consuming noop_environment now uses a
real trading environment.
As more behavior relies on an accurate trading calendar, maintaining
the noop environment was a constraint that was more overhead than it
is worth.
Passing the exchange time timestamp to is_market_hours was ending
up with odd behavior due to conversion back to UTC when checking
the is_trading_day boolean.
Changes to trading calendar and environments for supporting market
minutes, etc. have made the non-NYSE stock exchange support lag.
Disabling the test, with the intent of bringing support back up to
parity with NYSE.
Use the early closes to populate a DataFrame which includes
the open and close minute for each day.
To be used by the environment instead of calculating each value
mid-backtest.
In the performance period the max_leverage, max_capital_used,
cumulative_capital_used were calculated but not used.
At least one of those calculations, max_leverage, was causing a
divide by zero error.
Instead of papering over that error, the entire calculation was
a bit suspect so removing, with possibility of adding it back in
later with handling the case (or raising appropriate errors) when
the algorithm has little cash on hand.