Commit Graph

1373 Commits

Author SHA1 Message Date
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 7443b0c602 Pulls alias_dt wrapper out of sequential_transforms.
So that stepping through/cProfile output are a little clearer.
2013-01-30 16:20:58 -05:00
Eddie Hebert 946ecfafc0 Adds a trading day index to tradingcalander.
The trading day index is all business days in range minus the
non trading days we are already calculating.

Also, uses trading calendar indexes for batch transform, since the
batch transform was the only use of non_trading_days.

Instead of constantly adding and removing holidays to do market
day delta math, uses pandas DatetimeIndex to get the index of the dates
and uses the index difference to calculate market days.
2013-01-30 14:36:37 -05:00
Eddie Hebert 47c8015489 Moves creation of non_trading_days into a function.
So that we're not leaving rules used for configuration hanging in
module space.
2013-01-30 14:33:44 -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 2587cd6512 Enriches message returned for test batch transform.
Adds formatting of the failing values when ReturnPriceBatchTransform's
data shape does not match the window_length.
2013-01-30 14:04:17 -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 5b294faf0c Removes unused method. 2013-01-28 23:22:04 -05:00
Eddie Hebert c65522c787 Merge pull request #66 from rday/sortino_ratio
Add the Sortino ratio for downside risk
2013-01-28 11:14:59 -08:00
Ryan Day bb16eda1fa Force float value, and compare result against boundary 2013-01-28 14:08:44 -05:00
Ryan Day 64ffa055c9 Add the Sortino ratio for downside risk 2013-01-28 08:55:14 -05:00
Eddie Hebert 88070a0f12 Fixes dictionary-style lookup on Position and Portfolio.
Typo on method name, /__getattr__/__getitem__
2013-01-27 22:49:20 -05:00
Eddie Hebert 2352c1e576 Adds dictionary style access to Portfolio object. 2013-01-27 21:21:01 -05:00
Eddie Hebert 480ca65f56 Adds dictionary style access to Position object. 2013-01-27 21:19:59 -05:00
Eddie Hebert b3e8d56c02 Removes unused parameters in test trade info creation.
This code hasn't used `random` in a while, removing the parameter
left as an artifact.
2013-01-26 09:44:43 -05:00
Jonathan Kamens 629b6d6bd8 Upgrade to Pandas 0.10.1 2013-01-24 20:24:44 -05:00
Eddie Hebert a49bd4af4b Adds a contains method to SIDData to support in statement. 2013-01-23 17:17:35 -05:00
Eddie Hebert 87f99331e8 Uses an object for sid data to be passed to handle data.
Moving another datatype off of ndict, to make it easier to inspect
objects in memory when debugging.
2013-01-23 13:41:57 -05:00
Eddie Hebert 4723e836e7 Changes use of ndict in transforms to be name object.
So that when inspecting memory, it's easier to find each datatype.
2013-01-23 09:30:26 -05:00
Eddie Hebert 6f6434cf51 Converts slippage orders to use a simple object.
Reducing the number of ndicts that are created, so that profiling
has less noise.
2013-01-23 09:21:59 -05:00
Eddie Hebert d5a0446f7b Moves slippage transactions off of ndict.
So that the datatype is unique.
2013-01-22 20:55:24 -05:00
Eddie Hebert 649fb10c8e Creates a new averages container for each call to get_averages.
Ideally, we'd want to avoid multiple object creation,
but currently not playing well with generator chain.
2013-01-22 20:40:37 -05:00
Eddie Hebert 9313077152 Creates a container object for averages in mavg window.
Moving another data type off of ndict on the path to making
it easier to discern between types when
2013-01-22 20:21:15 -05:00
Jonathan Kamens e2f091c96e Upgrade nose-parameterized to 0.2 2013-01-21 09:37:37 -05:00
Eddie Hebert f017218b64 Uses class constants for message text instead of ndict.
Reducing use of ndict on the path to fixing a memory leak.

So that pulling an instance of ndict with objgraph is more likely
to be a use of ndict that is causing the leak.

Using a class level constant here suffices for the dot access
desired on messages.
2013-01-21 08:54:19 -05:00
Eddie Hebert b6779a85c7 Removes Jenkins configurations.
Public repo uses Travis-CI.
2013-01-21 01:01:27 -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
Eddie Hebert 9e31d83084 Fixes check of ticks in stddev, now that __len__ has been removed. 2013-01-17 18:11:27 -05:00
Eddie Hebert dbcfc0a2a5 Restores previous get_stddev method and uses the price value.
To maintain compatibility with existing algorithms.
2013-01-17 17:44:21 -05:00
Eddie Hebert 46b04ebe46 Merge pull request #63 from quantopian/transform_default_field
REF: fields now defaults to price for mavg and stddev transform. Also allows string specification.
2013-01-17 09:18:21 -08:00
Thomas Wiecki 685b2ed6fd REF: Fields is kwarg is MovingStandardDevWindow. 2013-01-17 12:10:09 -05:00
Thomas Wiecki eb1cb27a07 REF: fields now defaults to price for mavg and stddev transform. Also allows string specification. 2013-01-17 11:46:17 -05:00
Thomas Wiecki 0d6b8309b7 Merge branch 'master' of github.com:quantopian/zipline 2013-01-16 11:59:19 -05:00
Thomas Wiecki 4ab82601a5 Resolved unittest import problems. 2013-01-16 11:54:04 -05:00
Thomas Wiecki fd9bbbebfa Fix for stddev during merging. 2013-01-16 11:53:35 -05:00
Thomas Wiecki 77e9147a8b Merge branch 'master' of github.com:quantopian/zipline into stddev_multifield 2013-01-16 11:42:11 -05:00
Eddie Hebert 65138fbceb Uses numpy.dot instead numpy.vdot to calculate positions value.
Since the position amount and price ndarrays are one dimensional
and use real numbers, we do not need the overhead of the extra
case handling provided by numpy.vdot, which comes at a cost of
performance.

With thanks to @jlowin, for pointing out the better fit of numpy.dot.
2013-01-16 11:38:37 -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
Eddie Hebert a2b1b1b71e Uses vdot and numpy arrays for position totals.
Gets almost 100x speed up over iterating over the values and
summing up the values in Python.

Farms out the work to numpy and atlas by using the vector dot
product of the amounts and last sale prices.

Adds some wiring of keeping track of an index into the numpy arrays
for each position, so that value can be overwritten as events update
those amounts and sale prices.
2013-01-16 10:30:38 -05:00
Eddie Hebert c044648275 Rolls over existing PerformancePeriod.
Instead of doing the rollover by creating a new PerformancePeriod,
introduces a `rollover` method that resets the values that need
to be fresh in a new period, and moves the ending values to starting
values, and leaves positions intact.

This isn't a major runtime improvement in of itself, but it does
allow us to more easily keep track of position values from period
to period, which other improvements will use.
2013-01-16 10:30:38 -05:00
Jonathan Kamens 61773a2ebe Upgrade requests module to 1.1.0 2013-01-16 10:30:38 -05:00
Eddie Hebert a3235bb1a5 Recycles objects for positions.
Instead of creating a new ndict for each position on every event,
we change the values in the object that held the previous position.

The creation of new objects on each event was incurring too much
overhead.

Changes the position type returned by performance module.

For improved speed, changes from ndict to a simple Python object,
since the cost of setting ndict values is too expensive for the
number of times that positions are returned.

Also, changes the containing type of the positions to be dictionary
with the __missing__ overloaded, instead of the ndict that had that
behavior, to reduce the penalty of using ndicts.
2013-01-16 10:30:38 -05:00
Eddie Hebert a889f814fc Recycles the portfolio container to be passed to handle_data.
The creation of a new portfolio ndict on each call of handle_data
was creating a very high performance overhead.

Instead, we use the same the portfolio object for each event,
and replace the values contained within.
2013-01-16 10:30:38 -05:00
Eddie Hebert 48dba943db Uses a Portfolio object instead of an ndict.
Gains some performance by using a 'regular' object instead of
an ndict.

Also, directly sets up the values that we return, instead of going in
between with __core_dict and then removing values.

In it's entirety performanc.as_portfolio is the current
highest bottleneck, working on reducing time spent in that function.
2013-01-16 10:30:38 -05:00
Thomas Wiecki 0ecdac83f4 DOC: Typo. 2013-01-16 10:30:38 -05:00
Thomas Wiecki abf482c2a6 MIN: Changed isinstance check to allow more types. 2013-01-16 10:30: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 a63d4bca28 ENH: sid and field filter kwargs can also be strings or ints. 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