Commit Graph

2009 Commits

Author SHA1 Message Date
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
stanh 1f1be35734 ENH: Added commission model PerDollar
Commissions will be calculated based on total dollar traded.
2013-11-15 11:49:58 -05:00
fawce 395ce67c53 PERF: using comparison operation instead of tolerant_equals 2013-11-13 21:08:13 -05:00
fawce 923d3e4cbc PERF: re-ordered if statements, made into exclusive checks 2013-11-13 20:47:49 -05:00
Eddie Hebert 9b22b86703 BLD: Peg pytz to latest.
2013b -> 2013.8
2013-11-13 10:37:41 -05:00
Eddie Hebert 4a317762d1 BLD: Peg tornado to latest version.
3.1 -> 3.1.1
2013-11-13 10:35:20 -05:00
fawce f33193069c PERF: Remove in operator from inner loop.
Ask forgiveness via exception handling instead.
2013-11-12 22:32:30 -05:00
Eddie Hebert f8755a5602 STY: Remove unused imports. 2013-11-12 13:26:08 -05:00
Eddie Hebert b555af157b PERF: Use stored values for open and close.
The market_open_and_close method was a performance bottleneck,
since it was creating new dates on each query for open and close.

Instead use the pre-rendered frame of open and closes values
from the trading environment.
2013-11-12 13:12:12 -05:00
Eddie Hebert a2a56f7c63 MAINT: Remove noop_environment.
The code that was consuming noop_environment now uses a
real trading environment.

As more behavior relies on an accurate trading calendar, maintaining
the noop environment was a constraint that was more overhead than it
is worth.
2013-11-12 13:11:52 -05:00
Eddie Hebert 102cfcbe5b BUG: Fix bad dates from test factory.
Passing the exchange time timestamp to is_market_hours was ending
up with odd behavior due to conversion back to UTC when checking
the is_trading_day boolean.
2013-11-12 12:45:05 -05:00
Eddie Hebert 20e0ad191b TST: Disable test covering London stock exchange.
Changes to trading calendar and environments for supporting market
minutes, etc. have made the non-NYSE stock exchange support lag.

Disabling the test, with the intent of bringing support back up to
parity with NYSE.
2013-11-12 12:12:35 -05:00
Eddie Hebert aff8311f2f MAINT: Change name of column in open and close frame.
Use more natural sounding 'market_open' and 'market_close'.
2013-11-11 16:05:10 -05:00