Commit Graph

1965 Commits

Author SHA1 Message Date
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
Jonathan Kamens 0a7539b6de MAINT: flake8 2013-10-29 12:02:51 -04:00
Jonathan Kamens c3ddbc258d ENH: Accept simulation parameters and benchmark source args to create_test_zipline 2013-10-29 11:39:07 -04:00
Jonathan Kamens e36f70f541 ENH: Allow market data loader to be specified to create_simulation_parameters 2013-10-29 11:17:41 -04:00
Eddie Hebert 2d64ab8bfe BUG: Fix naive timestamps in benchmarks.
Always convert the benchmarks to UTC, not just on reload.
2013-10-29 08:36:53 -04:00
Eddie Hebert 912539248f Merge fix for stop orders.
Pull in patch that fixes the stop orders so they behave correctly
with regard to the price being greater or less than the stop for both
buys and sells.

Also, update unit test and add a refactoring on top of the fix to
make each sell/buy, stop and limit combination more clear.
2013-10-28 21:10:46 -04:00
Eddie Hebert 7412cc97a0 MAINT: Use bitwise flags to help order cases easier to follow.
Instead of nesting order direction and related stop and limit logic,
derive a bitwise mask from the combination of order configurations
and use the mask as a 'switch'.
2013-10-28 20:43:38 -04:00
Eddie Hebert 32c1f93572 TST: Updates tests to fit fixed stop behavior.
Change the answers to the stop order tests to match the corrected
behavior, where results are opposite from previous behavior.
2013-10-28 20:40:32 -04:00
Peter Cawthron 28f86bc14e BUG: Fix handling of STOP, LIMIT and STOP LIMIT Orders
Includes specific handling of Buy Stop, Sell Stop, Buy Limit, Sell
Limit, Buy Stop Limit and Sell Stop Limit orders.
2013-10-28 20:40:09 -04:00
Eddie Hebert 0c71f95016 TST: Parameterize stop order test.
So that we can more clearly demarcate each case of buy/sell and
price compared to stop, and their expected outputs.

Also, add comment about the current behavior versus the behavior
that will be moved to in an upcoming fix.
2013-10-28 15:12:29 -04:00
fawce 279605dfb5 BUG: Fix excessive recalcuations in batch.
Downsampled batch transforms should only recalcuate on close
2013-10-20 08:06:39 -04:00
Eddie Hebert cdbafc534a BUG: Fix mismatch of stored benchmark timestamps.
Normalize the date, so that there is not an EST/EDT and UTC mismatch.
2013-10-20 08:00:17 -04:00
Eddie Hebert 37c56b9aa4 MAINT: Use Series throughout for daily returns.
Remove the lists of DailyReturn objects in favor of using pd.Series
to store the return values.

Should make it easier to inspect the values when stepping through,
make the windowing of data to a certain range more facile by using,
and have some performance increases due to removing object creation
and member access.
2013-10-19 23:06:18 -04:00
fawce 76887e2855 BUG: Fix non-trading advancement of trading day count and downsample.
Add a guard so that we do not advance trading day count or downsample
on non-trading days.
2013-10-18 14:07:49 -04:00
Eddie Hebert aedf3766a8 Revert "MAINT: Store values for market open and close in environment."
This reverts commit 17b8980fb9.

Backing out rigidness of market and close, while sorting out how
to handle events that are not on a day in the trading calendar.
2013-10-18 12:30:01 -04:00
fawce 0ceabb590b BUG: Group and aggregate downsampling by trading day.
Otherwise, out of market events would result in a mishaped
panel.
2013-10-17 22:41:20 -04:00
Eddie Hebert 17b8980fb9 MAINT: Store values for market open and close in environment.
Instead of creating the market open and close mid-simulation,
calculate upfront the values for market open and close in a
DataFrame, so that they values can be looked up by date, as
viewed as series while investigating data issues.

One downside of this implementation is that the entire history
has open and close values calculated, even though the simulation
may only be a subset of the trade data on record.
Should consider moving the `times` property and other methods
that care about the start and end date of a simulation to
SimulationParameters or another like object.
2013-10-17 17:46:23 -04:00
Eddie Hebert 800210fbb3 MAINT: Ensure that test sources only provide market days.
Instead of using all calendar days between start and end in test
sources, use the trading calendar for test sources.

Needed for an incoming refactoring of market open and close,
where the opens and closes are indexed by market days.
2013-10-17 16:45:51 -04:00
fawce 3a1ca1ddb2 BUG: Mask of batch_transform columns to match keys in data parameter.
The underlying RollingPanel in batch_transform was always accumulating
all values to ever appear in data.

However, at any given algo time the desired return value is what the
current active sids are.

Instead, mask down to the sids that are passed in as the data parameter.
2013-10-16 15:16:03 -04:00
Eddie Hebert 0224aeb552 MAINT: Use enviroment normalize_date instead of dt.replace
Continue path of removing scattered calls to dt.replace.
2013-10-16 15:14:24 -04:00
Eddie Hebert 37e1e74391 TST: Add logging of sim params for perf tracker tests.
These tests use the random simulation parameters, which is leading
to an intermittent failure.

We may want to consider removing the randomness, but in the meantime
the randomness is exposing a case where the cost basis is not the value
expected, so logging the sim parameter values to help track down what
parameters cause the failure.
2013-10-16 12:07:14 -04:00
fawce f8ce7d944b ENH: Add downsampling to BatchTransform.
So that with minute data, 2.5 orders of magnitude of data can
be cut, allowing for longer window_lenghts, when the daily
values are what are desired for a signal.
2013-10-11 16:48:08 -04:00
John Ricklefs 9ac180d4bb BUG: Ensure compounded_log_returns set on first dt. 2013-10-11 13:06:11 -04:00
Eddie Hebert d177ddd860 Merge branch with annualized cumulative risk metrics. 2013-10-11 00:27:20 -04:00
Eddie Hebert 1bad245675 ENH: Use annualized returns for beta and alpha.
So that the units match the other risk calculations, also
use annualized returns for beat and alpha.

Update answer key to match values calculated on the first day.

Also, update performance tracker test so that the returns used
are fractional instead of > 1, so that the annualized numbers are
more in line with real world values.
2013-10-11 00:27:03 -04:00
Eddie Hebert dad34d2ddb TST: Add annualized alpha and beta to answer key.
Add a column that uses annualized mean returns as the inputs into
alpha and beta.
2013-10-11 00:27:03 -04:00