Commit Graph

1469 Commits

Author SHA1 Message Date
Thomas Wiecki 89ab65c413 REF: Import interface.
Makes TradingAlgorithm available at the top-level.
So that algorithms can do:
```
import zipline

class MyAlgo(zipline.TradingAlgorithm)
```

OR

```
from zipline import TradingAlgorithm

class MyAlgo(TradingAlgorithm)
```
2013-03-15 13:07:44 -04:00
Eddie Hebert ea11a43f68 MAINT: Removes unneeded assignment in slippage.
`direction` is set on each iteration of the loop,
making the initial assignment unneeded.
2013-03-12 20:37:36 -04:00
Eddie Hebert 43fac333a1 BUG: Fixes check reversal in slippage transact_stub.
Previous commit accidentally flipped the check when converting
to use `allclose`.
2013-03-12 20:34:16 -04:00
Eddie Hebert 2bf285b084 MAINT: More slippage comparison changes for floating point.
Continues conversion of floating point comparisons in slippage to
use numpy's allclose.
2013-03-12 20:28:47 -04:00
Eddie Hebert 27761f9dec MAINT: Uses copysign to extract order direction in FixedSlippage.
Uses copysign instead of division by fabs.
2013-03-12 19:47:01 -04:00
Eddie Hebert 080c54d4dc MAINT: Accounts for possible floating point rounding in slippage.
Uses numpy's allclose instead of straight comparison of floating
points, so that there is some tolerance of floating point rounding.
2013-03-12 19:40:24 -04:00
Eddie Hebert 39cfdaa7c9 MAINT: Updates copyright date of slippage module. 2013-03-12 19:18:52 -04:00
Eddie Hebert f7b4df4a09 MAINT: Uses copysign to extract direction of order.
Instead of using division of the amount by itself to extract
the direction, uses math's copysign.

Should be almost functionally equivalent,
but copysign won't have a possible floating point error leading
the direction to not be exactly 1.
2013-03-12 19:14:02 -04:00
Eddie Hebert 085eb040af MAINT: Updates pep8 from 1.4.4 -> 1.4.5 2013-03-09 17:32:55 -05:00
fawce 045773264b ENH: Adds a flag for optionally not serializing positions.
So that both computational and memory overhead is reduced,
this turns off serializing positions for cumulative performance.

Positions were essentially being doubled up by being stored
in both cumalative and daily.
2013-03-08 15:06:41 -05:00
Eddie Hebert a4e6520137 MAINT: Reverses polarity on keep transactions default.
So that transactions are kept by default.

This prepares for the addition of the serialize flag added by
@fawce.

Setting the default to True, so that the flags will be aligned.
2013-03-08 15:00:12 -05:00
Thomas Wiecki 0113765f70 Merge pull request #103 from mdengler/for-quantopian
README.md: update "Dependencies" section from setup.py
2013-03-07 11:29:30 -08:00
Martin Dengler 66fb0c583c README.md: update "Dependencies" section from setup.py 2013-03-07 01:08:21 +00:00
fawce 6a3e402a32 Merge pull request #101 from quantopian/fix_1516
Fix 1516
2013-03-06 14:26:33 -08:00
fawce a12eeb2383 incorporating feedback from @richafrank 2013-03-06 16:49:31 -05:00
Eddie Hebert e53622c930 MAINT: Changes unittest use of ndict to use specific objects.
Instead of using ndict, changing over to using the objects that
are created used when an algorithm is run.
2013-03-06 15:48:01 -05:00
Jeremiah Lowin 2095679a1d ENH: Adjust OHLC when loading bars to remove split/dividend noise
The adjustment is optional so that previous unadjusted values
can be compared to adjusted.
2013-03-06 11:04:24 -05:00
fawce b8144cea2a added tests to ensure:
- repeated calls with the same data window do not update batch transform
    windows.
    - repeated calls with the same data and same supplemental parameters do
    not update batch transform results
    - repeated calls with the same data and different supplemental params
    do update batch transform results
2013-03-05 22:59:31 -05:00
fawce 530f1cce55 added checks for change in optional parameters to trigger transform
recalculation.
2013-03-04 22:33:30 -05:00
Eddie Hebert 718ce0270a ENH: Improves handling of edge case in data update.
If the trading_days end date is not greater than the date being
tested, (this can happen if the algorithm's end date is set to a date
that is before the latest date available saved in the msgpacks),
then trying to get the location will fail, instead searchsorted
will get the lastest date available in the trading day map to use
as a test date.
2013-03-04 21:54:11 -05:00
Ryan Day 4170c05fb6 ENH: Update msgpack files if new data is available. 2013-03-04 21:54:05 -05:00
fawce a47143099c refining the batch transform interface:
- removed use_panel
  - default for refresh_period is now 0
  - refresh_period will only affect the recreation of the datapanel
  - user's transform method is invoked on every call to batch transform
2013-03-04 21:08:15 -05:00
Eddie Hebert 3e21ea52bc DEV: Adds a script to test data saved as msgpacks.
The loader_tool currently facilitates:
- Finding the last date in each source
- Forcing a complete reload of benchmark and treasury.
- Manipulating the msgpacks so that trailing dates are dropped,
  so that the condition for an update can be recreated.

This is intended to make it easier to test the update logic added
by @rday in PR #88
2013-03-04 17:07:36 -05:00
Eddie Hebert 092af814b8 MAINT: Adds license to treasuries module. 2013-03-04 11:11:57 -05:00
fawce 6329f477b8 removed data_panel option from BatchTransform.
- the underlying dequeue shouldn't be modified, so forwarding to the
user function is a bit misleading
- if we want to provide a dequeue we should consider another class
or an EventWindow decorator.
2013-03-04 06:26:41 -05:00
Jonathan Kamens 95e702ac84 MAINT: Update pyzmq version in dev requirements 2013-03-03 16:03:02 -05:00
Eddie Hebert e901e06f39 Changes the API for recording variables.
Uses a method called 'record' that provides a key value,
instead of providing keys to extract from context.

The variables are stored internally to the algorithm in a dictionary,
and not just stared as a property of the algorithm.

Main intent behind this change is to make the API more user friendly,
since the previous recorded_variables relies on the value to be set
in the algorithms context/self, the hope is that only having to use
the `record` method means less moving pieces and a more understandable
API.

i.e., instead of:

```
def initialize(self):
    recorded_variables('foo', bar')

def handle_data(self, data):
    self.foo = 1
    self.bar = 2
```

The API is now:

```
def initialize(self):
    pass

def handle_data(self, data):
    self.record(foo=1, bar=2)
```
2013-03-02 18:28:35 -05:00
Richard Frank ebdb5429aa MAINT: Moved DailyReturn to protocol module to break circular references
and removed code that solved that same problem with conditional imports.
2013-03-01 16:05:39 -05:00
Thomas Wiecki f1ff9cee0d ENH: New example algorithm OLMAR. 2013-03-01 15:33:12 -05:00
Richard Frank 7696abb169 MAINT: Removed unused prior_day_open from SimulationParameters 2013-03-01 13:21:28 -05:00
Eddie Hebert 414e12ecc9 BUG: Fixes error due to floating point rounding in stddev calc.
Adds a check to see if the s_squared value is near 0.

When the number was very near 0, a very small negative floating
point, the sqrt throws a 'math domain error', this prevents that
case.
2013-02-28 22:20:45 -05:00
Thomas Wiecki 46104fcd7c BUG: DataPanelSource was looping in the incorrect order. 2013-02-28 21:33:49 -05:00
Jonathan Kamens f38ed47773 DEV: List mccabe, pep8, pyflakes (used by flake8) in dev requirements 2013-02-26 11:11:23 -05:00
Jonathan Kamens cfd0fa507b MAINT: Upgrade dev requirements to flake8 2.0 2013-02-25 11:22:48 -05:00
Thomas Wiecki bea325f25a Merge pull request #95 from sender/delorean-fix
Add Delorean to dependency list in setup.py
2013-02-24 06:26:20 -08:00
Aidan 724fe60f20 adding delorean to dependency list 2013-02-24 18:10:19 +11:00
Eddie Hebert 4c761c6708 Prevents entire data panel being collapsed when a stock stops trading.
The call to `Panel.dropna` after the fillna was deleting all values,
if a stock stopped trading mid run and thus provided volume 0.

i.e. if any sid had 0 non-null values the entire panel of frames
would be truncated.

It's possible to avoid the collapse via by adding the `how='all'` flag
to `dropna`, however with the current tick based creation of the panel,
the `dropna` with `how='all'` should be functionally equivalent to
not dropping at all.

The dropna has been dropped in favor of leaving the drop to algorithm
code.
2013-02-21 11:32:20 -05:00
Jonathan Kamens 368a31587f Fix flake8 problem 2013-02-21 11:13:18 -05:00
Jonathan Kamens 8120fd1bf7 Disable test_{,lse_}calendar_vs_environment until issue #93 is addressed
These two tests are nonessential and the test failures reflect bugs in
the tests, not bugs in the code.
2013-02-21 11:03:55 -05:00
Jonathan Kamens 0de67d8096 Fix flake8 error 2013-02-19 23:28:18 -05:00
Jonathan Kamens 1a30bdf93a Upgrade msgpack-python to 0.3.0 2013-02-19 23:09:38 -05:00
fawce 866d45403b tradingcalendar was assuming eastern time when calculating its end date,
switched to use UTC and utcnow. Also factored the common code out of
the nyse and lse specific tests into a helper method.
2013-02-19 19:08:24 -05:00
fawce bf25e695ce Merge pull request #92 from quantopian/noop_env_fix_1470
added a decorator for applying an environment to a function context.
2013-02-19 10:17:58 -08:00
fawce 5587c1bc64 added functools.wraps as per @richafrank 2013-02-19 13:15:57 -05:00
fawce 9cc043f130 added a decorator for applying an environment to a function context. 2013-02-19 12:52:17 -05:00
Eddie Hebert 97cbea2514 Fixes crashes when using numpy log on a batch transform data panel.
The recent change to the creation of the data panel ended up with
a panel with the dtype of 'object', which was causing numpy ufuncs
like `log` to crash out on an `AttributeError`.

This forces all frames in the panel to use a dtype of 'float',
we may want to look at seeting a dtype on a frame by frame basis,
e.g. 'volume' may more accurately be 'int'.
2013-02-19 11:20:04 -05:00
fawce e6b9a355c1 Merge pull request #91 from quantopian/calendar_fix
changing the calendar test for lse to use the last available date
(confirmed this branch builds on jenkins before merging)
2013-02-18 21:18:56 -08:00
fawce 791328c5ad changing the calendar test for lse to use the last available date
rather than the end date.
2013-02-19 00:14:08 -05:00
fawce 4199b530b9 trying to fix broken jenkins build that seems to be due to the end time
of the trading calendar calculations and availability of data from yhoo.
2013-02-18 23:46:08 -05:00
fawce b8a885a2d6 Merge pull request #90 from quantopian/fake_environment
Fake environment
2013-02-18 20:37:37 -08:00