Commit Graph

2041 Commits

Author SHA1 Message Date
Eddie Hebert 8a22736f1e MAINT: Allow sim_params to provide data frequency for the algorithm.
In the case that data_frequency of the algorithm is None,
allow the sim_params to provide the data_frequency.

For less redundancy when setting up an algorithm.
2014-02-10 14:53:11 -05:00
Eddie Hebert b294d30af0 BLD: Update TA-Lib to latest version.
Keeping current with TA-Lib release.
Also, TA-Lib 0.4.7 has been removed from PyPI, so 0.4.8
is required for fresh PyPI based installs.
2014-02-07 22:03:06 -05:00
Eddie Hebert 7ecf544d15 BUG: Fix repr for cumulative risk metrics.
The __repr__ for RiskMetricsCumulative was referring to an older
structure of the class, causing an exception when printed.

Convert to printing the last values in the metrics DataFrame.
2014-02-07 21:34:01 -05:00
twiecki d91c18b1c2 BUG: Python 3 fix. 2014-01-30 18:48:46 -05:00
Michael Schatzow 59bcd097d5 ENH: Add hdf5 and csv source.
This creates a data source for csv and hdf5 files, a generator to create a sample csv, and a pytables generator to go from a list of dated gzipped csv's in a directory to a pytables data source.

This does not add a unittest yet which we should write for the future.
2014-01-30 16:47:27 -05:00
twiecki 07e25ae018 Merge branch to adjust benchmark times in minute mode. 2014-01-30 16:35:59 -05:00
twiecki 734abb2800 BUG: NoopAlgorithm requires initialize(). 2014-01-30 16:33:49 -05:00
Jamie Kirkpatrick 147242339d BUG: ensure perf stats are generated for all days
When running with minutely emissions the simulator would report to the
user that it simulated 'n - 1' days (where n is the number of days
specified in the simulation params).  Now the correct number of trading
days are reported as being simulated.
2014-01-30 16:04:29 -05:00
Jamie Kirkpatrick 45844bac31 BUG: adjust benchmark events to match market hours
Previously benchmark events were emitted at 0:00 on the day the
benchmark related to: in 'minute' emission mode this meant that
the benchmarks were emitted before any intra-day trades were
processed.

See: https://github.com/quantopian/zipline/issues/241
2014-01-30 16:01:58 -05:00
Eddie Hebert 9feed61748 MAINT: Use more exact boolean checks for pandas structures.
To prepare for being compatible with pandas==0.13.0, which is stricter
on boolean checks.
2014-01-29 17:13:13 -05:00
Eddie Hebert ff965060ff BUG: Fix typo in requirements file.
Fix incorrect number of '='
2014-01-21 10:51:53 -05:00
Eddie Hebert 47954755fa BLD: Add mock to requirements file.
mock was recently added as part of the testing of port of the script
API for algorithms.
2014-01-21 10:28:01 -05:00
Eddie Hebert 9573e28002 BLD: Update to latest tornado release.
Used by IPython notebook, update version from 3.1.1 to 3.2
2014-01-20 20:07:36 -05:00
Eddie Hebert aa4c67cd4d BLD: Update to latest Cython release.
0.19.2 -> 0.20
2014-01-20 20:05:02 -05:00
Moises Trovo 64b28d15f8 ENH: Add Brazilian calendar for BMF&Bovespa stock market
Add Brazilian Bovespa Stock Market calendar
2014-01-16 12:53:11 -05:00
Thomas Wiecki b69590a2f7 ENH: Factor out API methods. Add support for algo scripts.
This is a step towards the goal of uniting Quantopian scripts
and zipline.

To make the syntax of zipline identical to Quantopian
we break out the API methods (like order) and turn them into
functions. To access the algo object we add a thread local reference
to the current algorithm that is accessed in the API functions.

TradingAlgorithm now takes either a string or two functions
(initialize and handle_data) that it executes.

Use api method decorator for methods available in algoscript.

Ported appropriate algorithm tests from internal code.
2014-01-16 12:07:33 -05:00
Eddie Hebert adcae79da3 BUG: Make itervalues in empty position test Python 3 compatible.
Use `six.itervalues` so that the call works in both Python 2 and 3.
2014-01-10 15:47:09 -05:00
Eddie Hebert 51e8b3244e ENH: Filter out empty positions from portfolio container.
To help prevent algorithms from operating on positions that are
not in the existing universe of stocks.

Formerly, iterating over positions would return positions for stocks
which had zero shares held. (Where an explicit check in algorithm
code for `pos.amount != 0` could prevent from using a non-existent
position.)
2014-01-10 14:30:29 -05:00
Richard Frank 15dd1f9c0e ENH: Always process new orders
Allows for updating of new_orders even when handle_data isn't called
2014-01-10 13:19:02 -05:00
Richard Frank dadf867cf4 MAINT: Updated requests requirement to 2.2.0 2014-01-10 10:01:42 -05:00
Eddie Hebert 770d8b4e29 MAINT: Use date range in example that that has 1 Month curves.
So that the 1-Month Sharpe ratio has a curve to use during calculation,
use data from 2002, since the Treasury returns 1 Month data starting
in July, 2001.
2014-01-09 13:38:16 -05:00
Eddie Hebert 7f943e94a3 DOC: Fix link to flake8 homepage. 2014-01-09 11:15:00 -05:00
Eddie Hebert 61ccce760e BLD: Remove unused requirement of iso8601 package. 2014-01-08 11:13:26 -05:00
Eddie Hebert 063039ea07 REL: Add Python 3 to PyPI classifiers. 2014-01-08 11:06:39 -05:00
Eddie Hebert 4c6b9b945d REL: Release v0.6.0
Highlights

- Reworked risk metrics, including verification against Excel spreadsheet
- Additional order methods
- Conversion of many data structures to use pandas
- Change to behavior of stop and limit orders (@pcawthron)
- Use pandas timezone handling throughout instead of Delorean
- New commission model (@stanh)
- Adds beginning of support for Toronto stock exchange. (@dstephens)
- Python 3 compatibility.
  Unit tests now pass when run with Python 3.3, and Python 3 should
  now be considered officially supported.
  If anything does not work under Python 3, please file as a bug.
2014-01-08 10:00:31 -05:00
Eddie Hebert c53196b5ea BUG: Make write of binary file compatible with Python 3.
Open the destination file with the byte flag to avoid error in
Python 3 with mismatch of str and byte.
2014-01-07 18:01:25 -05:00
Eddie Hebert 71cda461c5 BUG: Fix check for cached public data for Python 2.7
Python 2 and 3 throw different exception types when a file does
not exist.

Catch both exception types to trigger the download, so that the
loader works under both Python versions.
2014-01-07 17:19:16 -05:00
Eddie Hebert 7274748275 STY: Remove unused import.
Remove unused heapq from test perf tracking.

Mea culpa.
2014-01-07 16:42:21 -05:00
Eddie Hebert 94edd2baed Merge Python 3 compatibility branch.
This branch should make it so that the code base can be run
using both Python 2.7 and Python 3.3
2014-01-07 15:34:04 -05:00
Eddie Hebert 10bf5e3012 BLD: Use Python 3 on Travis.
To help prevent regressions when a changes are developed using
Python 2.7, also test Python 3 during continuous integration.
2014-01-07 12:07:49 -05:00
Eddie Hebert 46ab748dd2 MAINT: Use pandas for data cache file I/O
The compatibility between the two versions was made easier by
letting pandas handle the heavy lifting, so pass filenames to the
pandas serialization methods, instead of dealing doing the file
handling and reading/writing within the data module.
2014-01-07 12:01:08 -05:00
Eddie Hebert ccb05acf5c MAINT: Read text in Python 3 instead of bytes when fetching public data.
Account for byte/string compatibility when consuming response from
requests module.
2014-01-07 12:00:04 -05:00
Eddie Hebert 8481e2df49 MAINT: Use Python 3 compatible metaclass.
Use six's with_metaclass to have objects that use metaclasses, in
both Python 2 and 3.

Otherwise, in Python 3 the objects were being treated as if they
did not have a metaclass, when the Python 2 syntax is used, leading
to errors because of missing attributes, etc.
2014-01-07 11:58:01 -05:00
Eddie Hebert f093b2fb59 MAINT: Adjust for comparison changes in Python 3.
Use date sorted sources instead, instead of sorting with second
argument of Event, etc. since the `heapq.merge` behavior is using
the second part of the tuple, thus requiring a richer set of comparison
methods, which would only be used in the test context.

Use `date_sorted_sources` instead, so that sorting is done on algo time
and source id.
2014-01-07 11:57:52 -05:00
Eddie Hebert 9326a732a4 MAINT: Make exception handling tests compatible between Python 2 and 3
Python 3 removes the `.message` attribute, so use `str` instead.

Also, the divide by zero message has changed slightly between versions,
so just check for the exception type, instead of also checking the message.
2014-01-07 11:57:49 -05:00
Eddie Hebert d06f35623a MAINT: Make walk usage in example tests compatible with Python 3
The rename of walk is not provided by six, so check the import error
via an exception.

Also, callback behavior slightly changes between the two versions,
so instead iterate over the walked files and call what was formerly
a callback, directly as a function.
2014-01-07 11:57:45 -05:00
Eddie Hebert 36f8b77290 MAINT: Support both Python 2 and 3 next interfaces.
Python 3 uses the `__next__` method instead of `next`,
and uses the syntax of `next(foo)` accordingly.

Add `__next__` and `next` side-by-side so both Python 2 and 3 have
a method that can be used during iteration.
2014-01-07 11:46:57 -05:00
Eddie Hebert 045e2975b7 MAINT: Remove type checking which trip up Python 3 compatibility.
Instead of porting these cases of type checking, remove them instead.
Slightly more Python-ic to be more generous in what is allowed, and
the conversion to make these compatible with Python 3 are more trouble
than they are worth.
2014-01-07 11:44:25 -05:00
Eddie Hebert 68b78a6914 MAINT: Explicitly convert map to list when converting answer key values.
For compatibility with iterator version of map in Python 3.

Also always use iterator version of map,
so that code path is exercised in Python 2.
2014-01-07 11:43:38 -05:00
Eddie Hebert 98956f19ed MAINT: Make answer key reading compatible with Python 3.
Ensure reading of bytes and checking against byte type, when
parsing the Excel spreadsheet which contains the answers.
2014-01-07 11:42:12 -05:00
Eddie Hebert e458e8c3c5 MAINT: Use explicit relative pathing for Python 3 compatibility.
Python 3 requires submodules to have more explicit pathing, so use
the dot syntax to declare submodules which are in the same directory
as another module.
2014-01-07 11:36:41 -05: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
Richard Frank 40c8c38257 MAINT: Updated libraries
iso8601, pytz, numpy, python-dateutil, six, Cython, requests,

nose-parameterized, nose-ignore-docstring, scipy, matplotlib,
patsy

Note that patsy must install before statsmodels.
2014-01-06 14:46:26 -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 df8464308d MAINT: Update URL for free benchmark data.
Keep pace with Yahoo!'s change from ichart.yahoo.com to
ichart.finance.yahoo.com
2014-01-02 19:22:19 -05:00
David Stephens e45528458f ENH: Added functionality to download Canadian treasury curves.
Added automatic switching of treasury curves based on index sent to environment.
2013-12-27 13:27:43 -05:00
David Stephens e5786b2593 ENH: Add calendar and test for Toronto stock exchange.
Note that the calendar test is decorated with @nottest (as per the other calendar test functions).  I've run the test to confirm the calendar works.  The differences between the env (Yahoo Finance of GSPTSE) and the calendar are illustrated in the tradingcalendar_tse file and are confirmed to be errors on Yahoo Finance's part.
2013-12-27 13:27:14 -05:00
Richard Frank 2cc9cab17f MAINT: Initialize Portfolio object with default values for attributes
instead of no attributes at all
2013-12-20 17:11:53 -05:00
Richard Frank adb4de740e MAINT: Removed unused parameter 2013-12-20 15:46:49 -05:00
Richard Frank f70ae02694 PERF: Speed up get_open_and_closes by assigning entire columns
to DataFrame, instead of row by row
2013-12-20 15:46:49 -05:00