Commit Graph
18 Commits
Author SHA1 Message Date
Jonathan Kamens e942275108 STY: Flake8
Upgrade the version of the flake8, pep8, and mccabe PyPI packages, and
make the code changes necessary for compatibility with the updated
packages.
2015-03-19 17:21:25 -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 7d5194ec2c ENH: Include TALib output names in ta transform results.
For TALib functions like MACD that have output names, return a
DataFrame that for which the columns are the output names of the
function.

So that when using a TALib function, the algorithm doesn't need
to know the index position of the desired result, in favor of using
the name of the result.

e.g.

```
macd_result['AAPL'][0]
```

becomes,
```
macd_result['AAPL']['macd']
```

and
```
macd_result['AAPL'][1]
```

becomes,
```
macd_result['AAPL']['macdsignal']
```

Also, change return type of functions that return floats from a
dictionary to a Series, so that the function is always returning a
pandas type.
2013-08-19 16:46:11 -04:00
Thomas Wiecki b89886297f STY: autopep8 codebase. 2013-08-08 16:46:44 -04:00
Thomas Wiecki f75d781b02 DOC: Fix talib sphinx warnings. Closes #171. 2013-08-08 10:50:00 -04:00
Eddie Hebert e85306524b BUG: Prevent crashes for TALib functions when stocks have nans.
If a stock stops gettign updated values, e.g. if a stock rolls out
of a universe strategy, currently the underlying batch transform
for TALib may have nans (which is another issue that could be addressed),
the nans cause crashes when passed to some TALib function, e.g. Bollinger
Bands are incompatible with all nan values.

So, drop sids that only have nan values for the current data panel.
2013-08-05 18:17:20 -04:00
Eddie Hebert 0dbdf5b1d3 BUG: Fix duplicated values for multi-stock TALib transform.
A multi-stock TALib transform was returning the same value for
all stocks, specifically the value for the first stock in the panel.

Index into the datapanel using `sid` instead of using the `[0:]`
index which was used when only supporting one sid.
2013-07-11 15:44:38 -04: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 37352210c0 MAINT: Make TALib zipline_wrapper a module level function.
Prepare for making the zipline_wrapper operate on multiple sids,
as the needed nested logic will get cramped within the nested function.

Also, should help clearly define the inputs of the zipline_wrapper
function that are needed before it is passed to the BatchTransform
constructor.
2013-07-10 14:38:57 -04:00
Eddie Hebert 15323a8179 BUG: Enable return values on first day using minute TALib functions.
Set the `compute_only_full` to False so that the 'is window full' logic
is delegated to the TALib's lookback function.
If the window is not full to the `timeperiod` or other lookback setting,
then TALib returns a `np.nan`.

Also, fix the bars/data_frequency not being passed to the BatchTransform
init.
This further shows need to create a minute test for TALib transforms.
2013-07-09 14:54:38 -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 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 4510c56142 MAINT: Use TALib abstract function names value when creating transforms.
Instead of using reading the __all__ value and filtering out Function,
use the abstract internal variable that lists all functions.
2013-06-28 16:22:22 -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
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
Thomas WieckiandEddie Hebert c22b86194f DOC: Add __doc__ string for all talib functions. 2013-05-11 14:41:51 -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 LowinandEddie Hebert 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