Commit Graph

1682 Commits

Author SHA1 Message Date
Eddie Hebert e9d80cc044 BUG: Fix out of order emission of performance with minutely data.
With the benchmark returns marked at midnight, the performance packet
for a day was emitted *before* any events for that day were processed.

Fix by expecting benchmarks marked at the market close, for backtests
that use minute data but emit performance results daily, so that the
benchmark handles at the end of day.

TST: Also, add test that exercises the event loop with minutely data,
(with benchmarks that are marked end of day), since that combination
was previously uncovered.
2013-05-08 21:20:25 -04:00
Eddie Hebert 74e743b8c6 MAINT: Add data frequency to simulation parameters.
Working towards performance and risk logic being aware of
data frequency, as different handling of order of events based
on the data frequency is needed.
2013-05-08 21:11:16 -04:00
Eddie Hebert 24019de573 BUG: Paper over multiple types for algorithm returns.
The Seriess-style indexing causes a crash on the list during unit tests.

TODO: Investigate whether the list type of algorithm returns can
      be removed.
2013-05-08 20:58:28 -04:00
fawce 5a2a51f796 MAINT: Use cumulative benchmark and algo returns in risk report.
So that RiskMetricsBatch can use the same benchmark returns that
are collected cumulatively as events are streamed through the system.
2013-05-08 18:41:37 -04:00
Eddie Hebert c0acbe2bc1 MAINT: Revert slice into returns containers instead of using .valid()
Backing out slice vs. valid(), because of an incompatiblity with
starting a minutely emitted session mid-day, since the midday start
date is not yet wired through SimulationParameters.
2013-05-08 18:29:49 -04:00
Eddie Hebert ad06acd49d MAINT: Slice into returns containers instead of using .valid()
The slicing syntax is more explicit about declaring:
'get all returns up until the current dt'.

Also, protects against NaNs that occur before the current dt
being silently ignored.
i.e. the *_returns_cont series *should* have values from start
to current dt, but the .valid() call was occluding a bug where
it wasn't.
2013-05-08 11:29:35 -04:00
Eddie Hebert 16c488e5bc TST: Fix increment in risk test that drops leading values.
The leading date of the date range was never called with update,
because in the main loop the todays_date variable was
incremented before update was called.

Fix by moving the increment to the next trading day to after the
call to update.
2013-05-08 08:31:08 -04:00
Eddie Hebert 41f1200dbd BLD: Exclude test_examples from Travis-CI, also exclude scipy.
scipy build was getting too heavyweight for the Travis-CI build.

Removes test_examples from Travis-CI run, since the examples
depend on scipy and other compiled libraries.

Please, still run test_examples before submitting patches.
2013-05-07 21:20:55 -04:00
Eddie Hebert cdc3886e91 Merge fixes for intraday perfomance.
Contains bugs and protocol compatibility changes.
2013-05-07 19:48:40 -04:00
fawce ede8471663 BUG: Fix next trading calculation.
If we are in a day beyond the historical data use the last close,
instead. Relevant for trading current data.
2013-05-07 19:26:24 -04:00
fawce 3d8674ffb6 MAINT: Cleaned up to_dict highlighting daily and minutely difference.
Make the difference between the two emission rates more exact.
2013-05-07 19:24:47 -04:00
fawce 2d850d0970 BUG: Fix calculation of cumulative risk stats.
- Use current dt instead of market_close.
- Handle intraday close
- Remove zeroing out of sharpe etc.
2013-05-07 19:21:20 -04:00
Eddie Hebert 32835b87f3 MAINT: Rename perfomances intraday_perf to minute_perf.
minute_perf is more precise than intraday_perf as a naming scheme
for the performance packet type.
2013-05-07 19:21:20 -04:00
fawce b53da8d4b3 MAINT: Refactor check_entry method to also look at np.inf
Also, make the method a module function.
2013-05-07 19:20:49 -04:00
Eddie Hebert 5c883659b5 BUG: Fix missing values from supplemental data in batch transform.
Adapt the supplemental data fill so that it works with the new
shape of the batch transform that was switched to with the rolling
panel optimizations.
2013-05-07 18:17:08 -04:00
Eddie Hebert d3ade5050c MAINT: Tune logging of StateTransform start/end to debug.
These log lines are useful for debugging, but a bit spurious
on every algorithm run.
2013-05-07 17:27:06 -04:00
Eddie Hebert 3e1ac4f19a TST: Add tests to verify risk calcualtions from streamed events.
So that we can verify the risk metrics as they are calculated.
Work towards being able to hand verify risk calculations.
2013-05-07 17:21:56 -04:00
Eddie Hebert 91e5abbc44 MAINT: Use a for loop for main algorithm run loop instead of list
So that stepping through a debugger is a little easier, with
respect to having easy access to the algorithm object, and seeing
which step in `self.gen` the interpreter is currently at.
2013-05-07 17:19:38 -04:00
Eddie Hebert aa54d0ae0e MAINT: Allow the algorithm benchmark returns to be overrideable.
So that test data can be well defined with a short list of benchmarks.

This could also lead to having more customizable benchmarks for
backtests.
2013-05-07 16:09:58 -04:00
fawce e6c156c50b ENH: Add intraday risk and performance for minute emission.
Both risk and performance now calculate performance since inception
(cumulative) and since the open. Both periods are updated intraday
and both are reported.

Batch risk for periods starting after the end of the treasury curve
history now use most recent curve.
2013-05-06 22:01:41 -04:00
Eddie Hebert 6afc85c17d BUG: Fix missing and delayed transaction last_sale_price's.
Critical that trade events be last, so that the perf tracker's
position information be updated with both the transaction and
the trade for last_sale.

Without, the first transaction would be recorded with a last_sale
of 0.

With @fawce
2013-05-06 16:28:47 -04:00
fawce 1752f78447 ENH: Allow algorithm to run past end of trading.environment history.
Work towards running an algorithm against 'live' data, which can't
be bound to the available benchmarks and treasuries, since the
benchmarks and treasury curves for that day won't be published
until that night.
2013-05-06 15:09:56 -04:00
Eddie Hebert d686fac02d MAINT: Use property for tradesimulation perf_key. 2013-05-05 11:32:33 -04:00
Eddie Hebert a04ece1840 MAINT: Use up-to-date field names in test_source
TRANSACTION member of Event had been removed.
close_price and open_price, are preferred to to close and open
2013-05-05 11:09:59 -04:00
Eddie Hebert 4b7afb43d2 MAINT: Change repr's so that they are both human and machine readable.
For printability in the repr when debugging algo config and state,
change the repr of TradingAlgorithm and the objects it contains
so that the more closely adhere to the repr interface of being
able to recreate an object instance.
2013-05-04 22:26:28 -04:00
Eddie Hebert 5ae1aab2af TST: Add nose-ignore-docstring plugin to requirements and setup.cfg
So that docstrings can be added for test documentation, but suppress
those docstrings in test output by default.
2013-05-04 12:52:38 -04:00
Eddie Hebert e3c783e163 BLD: Add scipy to test requirements.
For example scripts. Though compiling scipy for TravisCI may be the
straw that breaks the camel's back as far as total suite run time.
2013-05-03 13:32:30 -04:00
Eddie Hebert 727f7bef19 BLD: Use statsmodels 0.4.3 for test scripts.
0.5.0 is unavailable via the pep syntax, an incongruity
between the results of `pip install` and `pip freeze`
2013-05-03 09:40:27 -04:00
Eddie Hebert 42ad791f39 BLD: Add libraries needed for running examples.
Add statsmodels and patsy, since they are used by example scripts
and example scripts are now run as part of the unit test suite.
2013-05-03 09:17:17 -04:00
Eddie Hebert c3cbe4e6b1 Merge addition of unit tests that exercise examples.
Also, multiple fixes to examples that the unit tests uncovered.
2013-05-02 17:05:06 -04:00
Eddie Hebert 7bc20639da BLD: Add matplotlib to test requirements.
Example scripts use matplotlib, so add to requirements_dev.txt
so that CI will include matplotlib.
2013-05-02 16:54:57 -04:00
Thomas Wiecki b748ba62e0 MAINT: Shortened time frame over which examples are run to speed up tests.
Minor fix pairtrade to now use record.
2013-05-02 16:54:57 -04:00
Thomas Wiecki f5a8d76a91 BUG: Do not update last price if price is nan. 2013-05-02 16:54:57 -04:00
Thomas Wiecki d56f1b73f8 BUG: Removed SlippageModel from olmar example.
Fix crash due to 'delay' was no longer supported.
But removing SlippageModel override, since current configs
should be functionally equivalent to FixedSlippage.
2013-05-02 16:54:08 -04:00
Thomas Wiecki b8b21b347f TST: Added unittest that runs all examples. 2013-05-02 16:33:08 -04:00
Eddie Hebert 3711bf3775 ENH: Add a utility to reverse a utc timestamp to dst.
Mirror the exchange_dt_in_exchange helper function.
Useful for inspecting data interactively.
2013-05-02 15:52:48 -04:00
Eddie Hebert 823416e9fd MAINT: Remove unecessary conversion to Series on each risk update.
We were converting to pd.Series for historical reasons as an artifact
during development, now that we pass dt we can just pass the float values
instead of wrapping it in a series.
2013-05-02 14:36:10 -04:00
fawce 4ed0250424 added a fake window_length to be compatible
with transform protocol
2013-05-01 22:42:17 -04:00
fawce 59dcf0f6cd exposes stateful transform's window length 2013-05-01 22:05:06 -04:00
Eddie Hebert 440e7ce076 BLD: Add Cython as a requirement. For TA-Lib. 2013-04-30 21:24:50 -04:00
Jonathan Kamens 16e75a31d4 TST: Fix check() test utility function to detect all list differences
The check() function in zipline.utils.test_utils was only comparing
lists up to the length of the shortest list. This fix uses
izip_longest instead of izip so it compares up to the length of the
longest list, which among other things means that it will now
correctly report when one list is empty and the other is not.
2013-04-30 21:13:18 -04:00
Eddie Hebert 419c03dedb BUG: Smooth test and compile issues with TALib
So that TALib is still available, but smooth out the ability to
run tests with some issues that bear investigating.

- Ignore MAVP during tests.
- Temporarily use a "regular" member instead of  __doc__ string.
  (TODO: look into using `type` to generate the class)
- During tests wait until a window exists.
2013-04-30 20:19:37 -04:00
Eddie Hebert 56dae3a288 BLD: Include TA-Lib package as a dependency.
CI build was failing due to lack of package.
2013-04-30 19:52:40 -04:00
Eddie Hebert 4b102676a5 Merge in branch with support for TALib based transforms. 2013-04-30 17:39:58 -04:00
Eddie Hebert ae6e40499b BLD: Add build ta-lib to Travis config.
So that TALibTransforms tested on Travis.
2013-04-30 17:36:53 -04:00
Jeremiah Lowin cc39ec3aef ENH: Add support for TALib based transforms.
Provide a subclass of BatchTransforms that are powerd by the ta-lib
library.
2013-04-30 17:35:56 -04:00
fawce beecebc7d8 ENH: Support multi-day minutely emission.
Change the event loop so that minute emission has rollovers
between days.
2013-04-30 17:19:22 -04:00
fawce d381865a89 BUG: Ensure that order exists before attempting to cancel. 2013-04-30 17:19:16 -04:00
fawce 34f1dd783a STY: Tweak comments in performance to match rest of file. 2013-04-30 17:19:09 -04:00
fawce 28df9ec423 MAINT: Refactor performance tracker as part of algorithm.
Instead of having the performance tracker as part of the
tradesimulation class, hold on to it inside of the algorithm
object, so that the perf_tracker is more easily accessed for
reset behavior, etc.
2013-04-30 17:19:01 -04:00