Commit Graph

85 Commits

Author SHA1 Message Date
jfkirk 9996502573 DEP: Removes use of 'count'-defined test sources
Test sources are now defined by the sim_params period_start and period_end, rather than by the period_start and a defined 'count' of bars. This allows us to consider the sim_params.period_end as the canonical definition of the end of a simulation.
2015-05-28 12:29:33 -04:00
Joe Jevnik e3d8b1034e ENH: Replaces the simple transforms with history calls. Switches
transforms to quantopian syntax.

Adds the sid attribute to the siddata so it is aware of which security
it represents.
2014-11-17 13:16:30 -05:00
Scott Sanderson d02dd972d5 BUG: Fix crash in transforms on malformed CUSTOM events.
Fixes a crash in various transforms when providing CUSTOM events whose fields
don't match the fields required for the transform.

This is fixed by requiring all `EventWindow` subclasses to supply a `fields`
property, which returns a list of strings that are required keys for any event
that can be processed by the window.  Any CUSTOM events the don't supply the
required fields for a transform window are ignored by that window.
2014-08-13 12:54:29 -04:00
Thomas Wiecki e9b7209c13 MAINT: Factor talib tests out to separate file. 2014-08-04 13:17:21 +02:00
Eddie Hebert 352c8a6a8a MAINT: Change variable name in test transforms comprehension.
Using `n` conflicts with using `n` in an interactive debugger, like
pdb. Use `name` instead.
2014-03-27 22:38:57 -04:00
Eddie Hebert 64b2a7377c 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.
2014-03-26 15:47:09 -04:00
Eddie Hebert b4959e46cf MAINT: Use six for Python 3 compatible names and behavior.
Use the six module to import functions and types that are
consistent between Python 2 and 3, so that one code base can
support both versions.

- Use integer types instead of int and long.
- Use string_types instead of basestring.
- Account for iteritems, itervalues, iterkeys.
- Use six.moves for filter and zip, reduce
- Use compatible bytes for md5 hasher.
- xrange and range
2014-01-07 11:33:50 -05:00
Eddie Hebert 54ddd1c109 MAINT: print function clean up in preparation for Python 3
- Use `print()` function for all print calls
- Fix strip and format calls that were on the outside of the
  print function for some reason.
  (Which were breaking in Python 3 because of print returning None.)
- Remove commented out print calls.
2014-01-04 20:55:43 -05:00
Eddie Hebert eac882b773 ENH: Enable TALib transforms to perform on multiple stocks.
The TALib transform only supported operating on the first value
of a given batch transform panel row.

Instead of returning the one value, even if an panel with multiple
sids was provided, return a dictionary that maps stock to TALib
result.
2013-07-10 14:40:58 -04:00
Eddie Hebert 3d8bdeb429 ENH: Enable minute bar data with TALib transform.
Add a `bars` keyword arg, as is used with BatchTransform.

Also, instead of overwriting the window_length kwarg with timeperiod,
always use the lookback value from the created TALib function,
as timeperiod will be an input into that value if it exists.

Calculate `window_length` in minute mode so that there are enough
days to cover the minutes in the timeperiod.
2013-07-09 11:26:26 -04:00
Eddie Hebert 5fb837bf37 MAINT: Use numpy testing method instead of assertTrue.
So that when the test fails, the comparison is in a more readable
format.
2013-07-08 17:30:48 -04:00
Eddie Hebert ab0d07d8d0 API: Conform timeperiad to TALib interface instead of BatchTransform's.
For the creation of a TALib transform use timeperiod intsead of
window_length, to be more in the style of TALib usage, since all
TALib functions may not ending up using BatchTransform, so start
the practice of adhering to TALib conventions to make porting and
explanation easier.
2013-07-03 13:46:32 -04:00
Eddie Hebert 5d76c0b8a4 ENH: Remove need to pass sid to TALib transform constructor.
Now that BatchTransforms use RollingPanels under the hood, passing
an sid is no longer needed, passing the data will to handle_data
will suffice.
2013-06-27 19:12:01 -04:00
Eddie Hebert 832a39706e STY: Remove unused import from transform tests. 2013-06-27 19:11:15 -04:00
Thomas Wiecki 84e6050c65 BUG: Fix randomly failing talib unittest that relied on dict order. 2013-06-27 17:50:35 -04:00
Eddie Hebert e160f9afd8 TST: Skip TALib related tests.
The TALib related tests randomly fail, skip for now, as it causes
noise when developing against the latest versions of the codebase.

Should remove skips when TALib is closer to being fully supported.
2013-06-20 00:13:06 -04:00
Thomas Wiecki aa7d5de073 BUG: Fix off-by-one error in TALib wrapper.
When setting timeperiod in the talib function it subtracts by 1. We then used this subtracted value to set the window_length in the batch_transform which was then not passing a big enough panel. Ultimately this caused the talib transforms to always return nans.

This also makes the unittest more stringent by explicitly comparing the output of the wrapped TALib moving average to pandas rolling_mean().

Finally, this also allows passing of window_length instead of timeperiod to allow usage of the same interface as before.
2013-05-11 15:42:27 -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
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
Eddie Hebert a4ea33218d TST: Move batch transform tests to their own file.
From @twiecki's rolling batch transform work.
2013-04-26 23:56:35 -04:00
Eddie Hebert b3efb5eb69 MAINT: Remove ndict class.
Now that ndict is no longer used in any part of the system during
a backtest, remove all remaining references in tests, etc.
2013-04-26 16:03:01 -04:00
Eddie Hebert cfbbbe2f1c TEST: Ensure that test_transforms's algos are passed sim_params. 2013-04-12 12:54:11 -04:00
Eddie Hebert 58af62f18d REL: Update copyright on all files touched since end of 2012.
s/Copyright 2012/Copyright 2013/
2013-04-05 14:28:15 -04:00
fawce 2c7355a0dc Refactoring of TradingEnvironment to isolate the global state: index symbol and exchange timezone. Parameters that define the simulation (start, end, and capital base) were put in a new class, SimulationParameters.
Global state for the financial simulation environment is accessed through the
zipline.finance.trading module, which now contains a module variable:
environment.

Parameters are passed into an algorithm as a keyword argument, sim_params.
SimulationParameters creates a trading day index for the test period that
can be used to find trading days, calculate distance between trading days,
and other common operations. The sim params index is just selected from the
global state.

================

Details:

    - adding delorean to the requirements.
    - made index symbol a parameter for loading the benchmark data. changed
    messagepack storage to be symbol specific.
    - ported risk, performance, algorithm, transforms, batch transforms
    and associated tests to use simulation parameters and global environment
    - factory and sim factory use global state and sim params
    - factory method parameter names now reflect the class expected
2013-02-18 10:24:32 -05:00
fawce 817ed88e38 Adds dividends to performance tracking.
Algorithm returns and the risk calculations that depend on them now include
cash dividends. This commit does _not_ provide an API for user algorithms to
access dividends.

PerformanceTracker expects the dividend data to arrive as events, similar to
the way that Trades arrive. Dividends are expected to have adjusted payment
amounts that are inline with adjusted trades.

PerformanceTracker maintains state of all the unpaid dividends in the position
objects held in PerformancePeriod. Dividend objects contain all the relevant
dates (declared, ex, payment) as well as net and gross amounts. Dividends are
removed from the list as they are paid. Cash flow is not incremented until the
payment day. This creates the possibility of a dividend being owed but not
paid or realized before the end of a test. For example, a dividend with an
ex_date of today may have a pay date 2 weeks in the future. Right now the
algorithm does not receive any credit for unpaid dividends.

Tests cover buying/selling around the ex_date and payment_date, and checking
that the performance calculated is as expected.
2013-02-06 16:39:39 -05:00
Eddie Hebert be6572f1aa Change flag value on unit tests that use market_aware==False.
Changes these tests to use market_aware==True, so that unit tests
follow the same code path as actual execution.

All use of EventWindows against data follows market_aware behavior.

These tests are the only use of market_aware==False, so heading
down the path of removing market aware completely.
2013-02-01 21:05:49 -05:00
Eddie Hebert 2859afa032 Fixes assert type of window length check. 2013-01-31 21:16:41 -05:00
Eddie Hebert 3dd1b36d38 Changes unit tests asserts to UnitTest methods.
So that evaluated variables are printed on fail.
2013-01-31 20:10:47 -05:00
Eddie Hebert a6ce57ef4f Removes code branching on sequential/merged flags in StatefulTransform.
So that the unit tests exercise the same transform logic as what
is executed a TradingAlgorithm object.
2013-01-30 16:23:40 -05:00
Eddie Hebert 44140d2de7 Fixes dates used in test factory for batch transforms.
The test factory was creating non-market days.
i.e. the date range spanned the weekend.

Using pandas' BDay frequency so that only business days are created.

This specific date range doesn't have holidays, so not accounting
for holidays in the factory.

Also, widens the range of the trading calendar to cover the test dates
generated by the factory which include 1990.
Previously the trading calendar began with 2002, meaning that holiday
and weekend adjustments with the data exercised by the factory did
not trigger when run with data in 1990.

This does increase the memory footprint of the tradingcalendar module.
However, only by a couple MB, so taking the hit there to enable
correct behavior.
2013-01-30 14:06:56 -05:00
Eddie Hebert d52a9f3a67 Corrects wording on event_window test, with regards to empty values.
These tests ensure that there are three, not two, empty values
at the beginning of the transform.

Also, ensures that we are using a window length of 3 on the tests.
So that wordings of errors,etc. match the window length.
2013-01-30 14:00:06 -05:00
Eddie Hebert 39f44a44f8 Reverting changes MovingStandardDevWindow.
Though the addition of tracking mulitple values in the window
is powerful, the changes broke behavior of existing algorithms
by changing method signatures and names.

So temporarily reverting these changes, to be pulled back in when
a way to have the multiple fields tracked with the existing API
is written, or a cutover of the API is figured out and determined.
2013-01-21 00:12:33 -05:00
Thomas Wiecki 4ab82601a5 Resolved unittest import problems. 2013-01-16 11:54:04 -05:00
Thomas Wiecki 77e9147a8b Merge branch 'master' of github.com:quantopian/zipline into stddev_multifield 2013-01-16 11:42:11 -05:00
Elektra58 d0640d56c8 Refactored stdev transform to be applied to multiple fields, not just price
UnitTest for transforms refactored to account for changed stdev transform, introduced AssertAlmostEqual
2013-01-16 10:33:38 -05:00
Thomas Wiecki 456639d02c ENH: New batch_transform feature: compute_only_full. 2013-01-16 10:30:37 -05:00
Thomas Wiecki 52b099f6db ENH: Added new kwarg to batch_transform: create_panel. 2013-01-16 10:30:37 -05:00
Thomas Wiecki b815a57430 ENH: batch_transform now supports field filtering. 2013-01-16 10:30:37 -05:00
Thomas Wiecki b68c51afb4 ENH: batch_transform now supports sid-filtering. DOC: Added docs to batch_transform. 2013-01-16 10:30:37 -05:00
Thomas Wiecki 0f88e4133d ENH: New batch_transform feature: compute_only_full. 2013-01-07 12:44:55 -05:00
Thomas Wiecki d1dace948e ENH: Added new kwarg to batch_transform: create_panel. 2013-01-07 12:44:19 -05:00
Thomas Wiecki 2729936aff ENH: batch_transform now supports field filtering. 2013-01-07 12:43:41 -05:00
Thomas Wiecki 0e3b1e76e8 ENH: batch_transform now supports sid-filtering. DOC: Added docs to batch_transform. 2013-01-07 12:43:26 -05:00
Thomas Wiecki f8e4d8ade6 Revert "BUG: EventWindow now always contains constant number of days."
This reverts commit 7a0a6f5231.
2012-12-11 12:12:51 -05:00
Thomas Wiecki a14d702a0d STY: Replaced hardcoded values with variables. 2012-12-06 15:26:49 -05:00
Thomas Wiecki ba46c6292f ENH: DataPanel is now created more flexible over all sids and all given fields. Added unittest to test for nan-filling. Added backwards filling by default. 2012-12-06 14:43:20 -05:00
Thomas Wiecki 5f6839beea BUG: Refactored batch_transform unittests and fixed some bugs. 2012-12-06 12:36:47 -05:00
Thomas Wiecki 7a0a6f5231 BUG: EventWindow now always contains constant number of days. 2012-12-06 12:33:18 -05:00
Thomas Wiecki f81addb7df ENH: batch_transform now adds arbitrary keys to datapanel. 2012-12-03 13:41:37 -05:00
Eddie Hebert cf0de17b13 Merge pull request #22 from quantopian/fix_batch_transform_days
BUG: batch_transform was wrongly updating when days < refresh_period.
2012-11-19 12:40:26 -08:00