Commit Graph

2021 Commits

Author SHA1 Message Date
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
Eddie Hebert 457ac2630c BUG: Make BarData iterkeys method match dict iterkeys behavior.
Use a generator, instead of creating a list.
2013-12-20 12:41:51 -05:00
Eddie Hebert f2dc979fbc BUG: Make all iteration related methods fo BarData match __iter__
`for s in data` and methods like `for s in data.keys` were not producing
the same list of active sids

Make the other iteration methods match __iter__ by using the contains
method to check whether or not the sid is active.

For use of data outside of the algoscript context, which needs access
to all data fields use data._data
2013-12-20 00:05:53 -05:00
Thomas Wiecki 8524039580 REF: Moved trading-related methods from AlgoProxy. 2013-12-19 09:59:34 -05:00
David Stephens 108ffc6608 BLD: Add LD_LIBRARY_PATH to fix Travis CI failures. 2013-12-10 15:47:36 -05:00
Eddie Hebert 6f3a3dab04 TST: Defend against non-trading days as period start in commission test.
A bug in the create_random_simulation_parameters allows the period
start to be a non-trading day.

That bug was causing the commission tests to randomly fail, e.g.
when the period start was on Good Friday, because the commission was
created on hour three of Good Friday, instead of the next Monday.
When it hit that case, the test commission is never processed.

Defend against that bug by using the first open of the simulation
parameters which is more guaranteed to be during market hours,
when creating the test commission.

This is in place of fixing the bug in the random parameters function
or making the parameters non-random, which are other potential fixes.
2013-12-10 13:07:25 -05:00
Thomas Wiecki d52a7b6d8e DOC: Added doc string for instant_fill. 2013-12-04 07:16:18 -05:00
Thomas Wiecki 5f4d8817e8 ENH: Add len() functionality to BarData. 2013-12-03 16:29:17 -05:00
Eddie Hebert bbad5b386a MAINT: Removed unused test_utils.check functions.
The test_utils were the only references to the blist package,
removing so that blist can be removed as a dependency.
2013-12-02 13:19:00 -05:00
Thomas Wiecki 860a340e55 BUG: Erroneous call to log. 2013-11-25 19:52:05 -05:00
Thomas Wiecki 37ef8f6a93 STY: Removed unused import. 2013-11-25 18:07:36 -05:00
Thomas Wiecki c199a0d956 STY: Move order_value from blotter to TradingAlgorithm. 2013-11-25 17:38:30 -05:00
Thomas Wiecki 579cb56663 STY: Long line break for pep8. 2013-11-25 12:16:41 -05:00
Thomas Wiecki 9cb9831c08 STY: Prepend order_ to all target methods. 2013-11-25 11:28:27 -05:00
Eddie Hebert 571e07f89c MAINT: Add data_frequency to SimulationParameters repr. 2013-11-22 14:10:27 -05:00
Richard Frank a07c94665b BUG: Need to set portfolio_needs_update on the algorithm
not on the simulator
2013-11-19 16:56:09 -05:00
Eddie Hebert cfe6296a3e Merge lazy loading of portfolio and related values. 2013-11-19 14:42:36 -05:00
Eddie Hebert ccb7f493f7 PERF: Only update the portfolio once per dt.
So that each reference to `.portfolio` in the algoscript,
cache the value of the portfolio, and mark the need for a new
value at the end of each dt in the tradesimulation loop.
2013-11-19 14:39:19 -05:00
fawce 6d46eb71ea PERF: moved performance calculation out of inner loop
lazy loading for portfolio
less repeating in performance period updates
2013-11-19 10:39:57 -05:00
Eddie Hebert 50800a9863 BUG: Fix data cache filepath on Windows.
Prevent the ':' char, generated by converting a datetime to a string,
from creating on incompatible filepath for Windows.
2013-11-18 20:37:45 -05:00
Jonathan Kamens e9dbffbbaa MAINT: Upgrade Logbook to 0.6.0. 2013-11-18 16:16:51 -05:00