Commit Graph

1990 Commits

Author SHA1 Message Date
Eddie Hebert f2dc979fbc BUG: Make all iteration related methods fo BarData match __iter__
`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
2013-12-20 00:05:53 -05:00
Thomas Wiecki 8524039580 REF: Moved trading-related methods from AlgoProxy. 2013-12-19 09:59:34 -05:00
David Stephens 108ffc6608 BLD: Add LD_LIBRARY_PATH to fix Travis CI failures. 2013-12-10 15:47:36 -05:00
Eddie Hebert 6f3a3dab04 TST: Defend against non-trading days as period start in commission test.
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.
2013-12-10 13:07:25 -05:00
Thomas Wiecki d52a7b6d8e DOC: Added doc string for instant_fill. 2013-12-04 07:16:18 -05:00
Thomas Wiecki 5f4d8817e8 ENH: Add len() functionality to BarData. 2013-12-03 16:29:17 -05:00
Eddie Hebert bbad5b386a MAINT: Removed unused test_utils.check functions.
The test_utils were the only references to the blist package,
removing so that blist can be removed as a dependency.
2013-12-02 13:19:00 -05:00
Thomas Wiecki 860a340e55 BUG: Erroneous call to log. 2013-11-25 19:52:05 -05:00
Thomas Wiecki 37ef8f6a93 STY: Removed unused import. 2013-11-25 18:07:36 -05:00
Thomas Wiecki c199a0d956 STY: Move order_value from blotter to TradingAlgorithm. 2013-11-25 17:38:30 -05:00
Thomas Wiecki 579cb56663 STY: Long line break for pep8. 2013-11-25 12:16:41 -05:00
Thomas Wiecki 9cb9831c08 STY: Prepend order_ to all target methods. 2013-11-25 11:28:27 -05:00
Eddie Hebert 571e07f89c MAINT: Add data_frequency to SimulationParameters repr. 2013-11-22 14:10:27 -05:00
Richard Frank a07c94665b BUG: Need to set portfolio_needs_update on the algorithm
not on the simulator
2013-11-19 16:56:09 -05:00
Eddie Hebert cfe6296a3e Merge lazy loading of portfolio and related values. 2013-11-19 14:42:36 -05:00
Eddie Hebert ccb7f493f7 PERF: Only update the portfolio once per dt.
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.
2013-11-19 14:39:19 -05:00
fawce 6d46eb71ea PERF: moved performance calculation out of inner loop
lazy loading for portfolio
less repeating in performance period updates
2013-11-19 10:39:57 -05:00
Eddie Hebert 50800a9863 BUG: Fix data cache filepath on Windows.
Prevent the ':' char, generated by converting a datetime to a string,
from creating on incompatible filepath for Windows.
2013-11-18 20:37:45 -05:00
Jonathan Kamens e9dbffbbaa MAINT: Upgrade Logbook to 0.6.0. 2013-11-18 16:16:51 -05:00
stanh 1f1be35734 ENH: Added commission model PerDollar
Commissions will be calculated based on total dollar traded.
2013-11-15 11:49:58 -05:00
fawce 395ce67c53 PERF: using comparison operation instead of tolerant_equals 2013-11-13 21:08:13 -05:00
fawce 923d3e4cbc PERF: re-ordered if statements, made into exclusive checks 2013-11-13 20:47:49 -05:00
Eddie Hebert 9b22b86703 BLD: Peg pytz to latest.
2013b -> 2013.8
2013-11-13 10:37:41 -05:00
Eddie Hebert 4a317762d1 BLD: Peg tornado to latest version.
3.1 -> 3.1.1
2013-11-13 10:35:20 -05:00
fawce f33193069c PERF: Remove in operator from inner loop.
Ask forgiveness via exception handling instead.
2013-11-12 22:32:30 -05:00
Eddie Hebert f8755a5602 STY: Remove unused imports. 2013-11-12 13:26:08 -05:00
Eddie Hebert b555af157b PERF: Use stored values for open and close.
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.
2013-11-12 13:12:12 -05:00
Eddie Hebert a2a56f7c63 MAINT: Remove noop_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.
2013-11-12 13:11:52 -05:00
Eddie Hebert 102cfcbe5b BUG: Fix bad dates from test factory.
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.
2013-11-12 12:45:05 -05:00
Eddie Hebert 20e0ad191b TST: Disable test covering London stock exchange.
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.
2013-11-12 12:12:35 -05:00
Eddie Hebert aff8311f2f MAINT: Change name of column in open and close frame.
Use more natural sounding 'market_open' and 'market_close'.
2013-11-11 16:05:10 -05:00
Eddie Hebert 48be898a13 ENH: Add open and closes to trading calendar.
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.
2013-11-11 15:48:44 -05:00
Eddie Hebert 43b85cffb0 MAINT: Calculate tradingcalendar with days beyond the current day.
To make 'next open' calculations more straight ahead, calculate more
than enough days in the trading calendar.
2013-11-11 15:48:44 -05:00
Eddie Hebert 797cb8ece3 BUG: Fix bad reference to benchmark timezone in loader. 2013-11-11 14:39:11 -05:00
Eddie Hebert 89793e371c MAINT: Protect loader against Series saved with no tz.
Checking for tz.UTC is not sufficient, since it is possible for
the index.tz value to be None.
2013-11-11 14:17:14 -05:00
Eddie Hebert 408c129760 BLD: Remove Delorean as a build and setup dependency.
Now that we use pandas Timestamp throughout, Delorean is no longer
needed as a dependency.
2013-11-11 11:47:41 -05:00
Eddie Hebert 796b9fb67a MAINT: Use Timestamp for calculating next_trading_dt in test factory.
Instead of Delorean, use pandas Timestamp.

Could also consider using environment trading_days directly.
2013-11-11 11:44:40 -05:00
Eddie Hebert 4d11ca131e TST: Use Timestamp instead of Delorean for trading calendar test.
Removes another use of Delorean in favor of Timestamp 'today'.
2013-11-11 10:38:04 -05:00
Eddie Hebert dd95b6bfa3 MAINT: Use Timestamp instead of Delorean for tradingcalendar end.
Instead of Delorean, use pandas `today` behavior for Timestamp.
2013-11-11 10:13:05 -05:00
Richard Frank 8014d9d938 BUG: Order.status now returns correct value
whether or not Order.open has been queried
2013-11-06 14:31:49 -05:00
Richard Frank 4dbdf45006 MAINT: Factored process_transactions out of blotter's process_trade 2013-11-06 14:27:19 -05:00
Eddie Hebert 3f89904e33 MAINT: Remove unused calculations of max_leverage, et al.
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.
2013-11-06 14:22:20 -05:00
Richard Frank 2492feb938 ENH: Keep track of total commissions as attribute on Order
Value is summed from TRANSACTION and COMMISSION events.
Defaults to None, meaning unset.
2013-11-01 17:23:50 -04:00
Eddie Hebert 4b023a852a MAINT: Use 1 as the first bitmask value instead of 0.
To prevent a possible future bug where values like SELL | STOP | LIMIT
would accidentally match STOP | LIMIT.
2013-11-01 16:26:48 -04:00
Eddie Hebert 1575867b40 STY: Use named args for Transaction object creation.
Instead of creating and passing a dict of the object values,
use named args directly.
2013-11-01 16:10:19 -04:00
Eddie Hebert a192ba01a2 STY: Used named args in hardcoded test objects.
Instead of unrolling a dictionary, use named args.
2013-11-01 15:28:35 -04:00
Jonathan Kamens 73faf9133e MAINT: Clean up imports of zipline.finance.trading
Use "from zipline.finance import trading" instead of "import
zipline.finance.trading as trading".
2013-10-29 13:50:14 -04:00
Eddie Hebert 1794e4e716 DEV: Update flake8 to latest release. 2013-10-29 13:40:28 -04:00
Eddie Hebert f0465c5b87 STY: Tweak over-indented code.
flake8 recommendation
2013-10-29 13:38:31 -04:00
Eddie Hebert c45c1a22e1 BUG: Only localize benchmark index if it is naive.
Check for whether or not the index's timezone is UTC or not before
attempting to localize, since an already localized index throws an
error when tz_localize is called.
2013-10-29 13:17:58 -04:00