Commit Graph

2709 Commits

Author SHA1 Message Date
Richard Frank dcc0a31782 PERF: Re-use the faster get_open_and_closes from tradingcalendar 2015-09-08 09:21:42 -04:00
Jonathan Kamens 510dc2ae7b TST: test_finance.py can't handle being parallelized 2015-09-08 08:49:11 -04:00
jfkirk cf41373f8f BUG: Symbol look-up now uses the sim_params.period_end as a look-up date 2015-09-01 12:39:03 -04:00
Warren O'Neill de09433fd4 MAINT: allows contract_multiplier to be non-integer 2015-09-01 11:54:09 -04:00
Scott Sanderson 6e8a4b8144 ENH: Improvements to rank().
- Add an `ascending=True` keyword to `rank()`.

- Add `top(N)` and `bottom(N)` methods to Factor.  These return Filters
  that pass the top and bottom N elements each day.

- Add a slightly faster path for rank(method='ordinal').  I had
  originally thought the fast path was 2-3x faster because I had my
  benchmark data axes flipped.  The actual speedup is only 5-10%, which
  means it probably wasn't worth the effort to Cythonize...but we have a
  slightly faster version now so we might as well use it.

- Refactor test_filter and test_factor to make it easier to implement
  and test transformations on factors.  These tests now subclass
  BaseFFCTestCase, which provides facilities for passing a dict of terms
  and an "initial_workspace", the values for which are used by
  SimpleFFCEngine rather than needing to manually manage the inputs and
  outputs of each term.
2015-08-31 00:32:33 -04:00
Scott Sanderson a04dcfa6b8 TEST: Rename test. 2015-08-29 23:55:59 -04:00
Scott Sanderson 90e81d0df0 MAINT: Add TermGraph class.
Use a subclass of networkx.DiGraph to encapsulate the state of our
dependency graph.
2015-08-29 23:55:59 -04:00
Scott Sanderson 7eae44fff7 STY: _add_to_graph fits on one line. 2015-08-29 23:55:59 -04:00
Scott Sanderson 6c2d7ff395 STY: Use same names in subclass. 2015-08-29 23:55:59 -04:00
Scott Sanderson dd1f9221f9 Merge pull request #691 from quantopian/500-errors
Add SidNotFound exception case
2015-08-28 18:51:24 -04:00
dmichalowicz 14ab02bfaa Remove comment 2015-08-28 15:16:04 -04:00
dmichalowicz b7cf84e4ec Add SidNotFound exception case 2015-08-28 13:27:22 -04:00
Scott Sanderson 83f160dca0 Merge pull request #689 from quantopian/assets-from-ffc-matrix
ENH: Return asset-indexed DataFrame for data.factors.
2015-08-26 19:04:46 -04:00
Scott Sanderson 780263da06 ENH: Return asset-indexed DataFrame for data.factors.
This makes ordering with the returned assets much easier, and there's no
performance degradation for non-broadcasting operations on the Index.

Timings
-------

    from random import sample
    finder = AssetFinder(create_table=False, assets.db')
    assets = load_8000_assets(finder)
    AAPL = finder.retrieve_asset(24)
    RANDOM_ASSETS = sample(assets, 500)
    df = DataFrame(
        index=assets,
        data=np.random.randn(len(assets), 4),
        columns=['a', 'b', 'c', 'd'],
    )
    df_int = DataFrame(
        index=map(int, assets),
        data=np.random.randn(len(assets), 4),
        columns=['a', 'b', 'c', 'd'],
    )

    %timeit df.loc[24]
    %timeit df_int.loc[24]

    10000 loops, best of 3: 45.3 µs per loop
    10000 loops, best of 3: 44.7 µs per loop

    %timeit df.loc[AAPL]
    %timeit df_int.loc[AAPL]

    10000 loops, best of 3: 45.1 µs per loop
    10000 loops, best of 3: 44.8 µs per loop

    %timeit df.loc[RANDOM_ASSETS]
    %timeit df_int.loc[RANDOM_ASSETS]

    1000 loops, best of 3: 1.53 ms per loop
    100 loops, best of 3: 2.18 ms per loop

    %timeit df.sum()
    %timeit df_int.sum()

    10000 loops, best of 3: 56 µs per loop
    10000 loops, best of 3: 55.7 µs per loop

    %timeit df.index == 3
    %timeit df_int.index == 3

    1000 loops, best of 3: 253 µs per loop
    100000 loops, best of 3: 6.76 µs per loop

    %timeit df.iloc[:50]
    %timeit df_int.iloc[:50]

    10000 loops, best of 3: 44.3 µs per loop
    10000 loops, best of 3: 44 µs per loop
2015-08-26 18:33:54 -04:00
Scott Sanderson c6aa36e5c1 Merge pull request #684 from quantopian/apparently-windows-doesnt-have-nan
BUG: Use NAN from numpy.
2015-08-25 13:10:50 -04:00
Jonathan Kamens 2521263c06 TST: Prevent some test cases from being split 2015-08-25 11:56:36 -04:00
Scott Sanderson 39321c2868 Merge pull request #685 from quantopian/data-in-before-trading-start
ENH: Make data available in before_trading_start.
2015-08-25 10:49:59 -04:00
Scott Sanderson f7039d6f52 ENH: Make data available in before_trading_start. 2015-08-21 12:37:17 -04:00
Scott Sanderson 41d4133c74 BUG: Use NAN from numpy.
MSVC doesn't define NAN in math.h because they only implement C89.

See http://tdistler.com/2011/03/24/how-to-define-nan-not-a-number-on-windows.
2015-08-21 11:33:20 -04:00
Thomas Wiecki 8dc0276d99 Merge pull request #682 from quantopian/fix_ipython_call
BUG Regression caused by adding print_algo to args parser.
2015-08-20 11:16:31 +02:00
Thomas Wiecki 0c44ebe2ad BUG Regression caused by adding print_algo to args parser. Remove default print_algo kwarg when called from IPython interface. 2015-08-20 10:58:16 +02:00
Joe Jevnik cfce3a7c77 Merge pull request #681 from quantopian/sanest-setup
Sanest setup
2015-08-19 15:19:02 -04:00
Scott Sanderson d444f593cd BLD: Take advantage of pip download caching. 2015-08-19 10:39:20 -04:00
Scott Sanderson d7635fb75c BLD: Install coverage during builds. 2015-08-19 10:39:20 -04:00
Scott Sanderson de4446425f BLD: Build on travis' container infrastructure.
It's supposedly faster.
2015-08-19 10:39:20 -04:00
Jonathan Kamens ee47ec1d3d BLD: Package all zipline.* modules when building eggs.
Rather than specifying only the package "zipline" in setup.py, use
`find_packages` to find all the subpackages as well, so they (or, most
specifically, their `__init__.py` files) are properly packaged in the
egg file.
2015-08-19 10:38:11 -04:00
Jonathan Kamens f2d5f42a6b BLD: Lazy-load Cython and numpy when installing package.
Modify setup.py to defer the use of Cython and numpy until
`setup_requires` has already been processed, so that Cython and numpy
are available when they are needed.
2015-08-19 10:37:25 -04:00
Richard Frank 30847a10a7 BUG: Interface of load_adjusted_array is to return a list of arrays
but MultiColumnLoader was returning a list of lists of arrays in some
cases.
2015-08-19 10:12:19 -04:00
Scott Sanderson a801547122 BLD: Read requirements from setup.py
- Parse our requirements.txt to keep install_requires up to date.
- Create extras builds for talib and dev.
- Use pip install -e .[dev] on Travis to install Zipline before testing.
2015-08-19 03:31:29 -04:00
Scott Sanderson 8528556970 Merge pull request #677 from quantopian/clarify-assets-test
TEST: Clarify test in asset finder.
2015-08-16 14:31:47 -04:00
Scott Sanderson 4b7cef8703 TEST: Clarify test in asset finder.
Fix comment copypasta and add a check for the third sid that should be
found.
2015-08-13 11:46:19 -04:00
Jean Bredeche fcda943e7d Merge pull request #671 from quantopian/no-more-threadbound
BUG: Let logbook figure out how to bind the context manager.
2015-08-06 14:58:06 -04:00
Jean Bredeche ff87fd32e3 BUG: Let logbook figure out how to bind the context manager. 2015-08-06 13:52:58 -04:00
Scott Sanderson 6897536317 DEV: Raise useful error if we get dupe assets. 2015-08-06 11:11:54 -04:00
Scott Sanderson e0bd25cb18 MAINT: Remove temporary nullctx alias. 2015-08-05 18:36:37 -04:00
Andrew Daniels 48c609debc BUG: Improves lookup_future_chain to handle NaT date args
If lookup_future_chain was provided with an as_of_date or knowledge date that was pandas.NaT, the query we were forming wasn't what we want. Instead, as_of_date, if not NaT, is used for knowledge_date, and if both are NaT, no date filtering is done in the query.
2015-08-05 10:50:14 -04:00
Andrea D'Amore 65448cc8d1 ENH Add command line option for printing algo on stdout, default is false. 2015-08-05 10:29:56 +02:00
Joe Jevnik 85d53dcce8 Merge pull request #588 from jlowin/patch-2
Fix code block formatting in release notes
2015-08-05 03:12:18 -04:00
Scott Sanderson 3f45494771 MAINT: Encapsulate engine initialization.
Required for internal override.
2015-08-04 19:26:56 -04:00
Scott Sanderson 223c8d02f9 MAINT: Don't alias bounds in engine loop. 2015-08-04 19:24:55 -04:00
Scott Sanderson 7f374f2ba3 MAINT: Bump bcolz version to latest. 2015-08-04 18:16:09 -04:00
Scott Sanderson b89fc0c028 BUG: Fix error from RequiredWindowLengthMixin.
WindowLengthNotSpecified expects an argument.
2015-08-04 01:41:03 -04:00
Scott Sanderson e91b1c56b2 MAINT: Remove unused import. 2015-08-04 01:40:16 -04:00
Scott Sanderson 0cc84e7a15 BUG: Use normed last_close instead of period_end.
`period_end` can be outside the range of data for which we have dates.
`last_close` properly gets pulled back to the last date for which we
actually have data.

We should consider whether or not we need to be storing period_end at
all.
2015-08-03 12:09:26 -04:00
Scott Sanderson 69d5aed7f6 BUG: Pop ffc_loader kwarg in TradingAlgorithm.
Prevents us from forwarding it as an initialize_kwarg.
2015-08-03 12:09:00 -04:00
Scott Sanderson 45d829cda0 BUG: Use a "real" index in NoOpFFCEngine.
This makes us return an empty DataFrame in data.factors instead of
barfing.
2015-08-03 12:08:08 -04:00
Scott Sanderson 7bb20eb297 MAINT: Check dates before computing factor_matrix.
In SimpleFFCEngine.factor_matrix barf with a useful error if end_date <=
start_date.
2015-08-03 12:06:24 -04:00
Scott Sanderson 5da03d2df5 BUG: Make NumExprFilter return ndarray.
- Previously it was returning a DataFrame because of how we applied an &
  with a DataFrame mask.  The error was masked by the fact that
  `np.assert_array_equal` coerces inputs to arrays before comparing.

- Added `zp.utils.test_utils.check_arrays`, which checks type equality
  before calling `np.assert_array_equal`.
2015-08-03 11:59:11 -04:00
jfkirk 67c56f768b ENH: Adds auto-closing feature and implements for Futures 2015-07-31 10:38:44 -04:00
Scott Sanderson f13e9fd125 TEST: Add test asserting dynamic api_methods. 2015-07-29 12:30:46 -04:00