Commit Graph

1461 Commits

Author SHA1 Message Date
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
fawce 2db01b3935 created a new generator-backed trading environment for testing.
other details:
    - also fixed grammatical errors in loader's status messages.
    - converting the treasury curves to an ordered dict.
    - moved to using a lambda for clarity as per @ehebert
    - initializing calendar end dates to be midnight of current date in
    - US/Eastern. Yahoo data isn't available until midnight eastern.
2013-02-18 23:35:38 -05:00
Jonathan Kamens 8eb92830c9 Don't capitalize delorean in requirements.txt 2013-02-18 14:20:58 -05:00
fawce 1a85781170 updated run method to use sim_params. 2013-02-18 10:24:32 -05:00
fawce d67e5d7a4b factory had a bug in the creation of trade history that traversed daylight savings time changes. added a fix and a test. 2013-02-18 10:24:32 -05:00
fawce a4a4d38a73 TradingEnvironment allows the specification of a benchmark index and a local timezone for the exchange. This commit adds tests to verify the TradingEnvironment properly handles London Stock Exchange index, FTSE.
- added LSE reference rrules calendar (thanks to Edward Johns)
    - added tests to verify LSE environment matches rrule calendar
    - added a test to verify global environment behavior can be set.
    - moved DailyReturn class to trading to eliminate circularity from
    risk <-> trading.
    - updated TradingEnvironment to be a context manager. This allows users
    to run algorithms in individually isolated environments in one python
    process. This is useful for managing multiple algorithms in a single
    ipython notebook.
    - added comments to explain behavior and useage of the global environment
2013-02-18 10:24:32 -05: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
Thomas Wiecki 8f37b794e5 Merge pull request #85 from twmeggs/master
A few clerical corrections to comments and notes within the code.
2013-02-16 11:44:07 -08:00
Tim d3f1e0ffa9 Small spelling change. 2013-02-16 17:43:38 +00:00