Commit graph

69 commits

Author SHA1 Message Date
Tim Gates
25e2e039e3
Fix simple typo: unfortunatly -> unfortunately
Closes #2655
2020-02-16 19:09:13 +11:00
Scott Sanderson
09fb188c40 ENH: Add currency column to EquityPricing. 2020-01-10 12:55:45 -05:00
vikram-narayan
d708817e44 MAINT: use ISO 10383 codes for exchanges 2018-10-01 12:45:27 -04:00
Scott Sanderson
e491ebef53 ENH: Initial support for international pipelines.
This commit adds initial support for international markets in the Pipeline API
via addition of the concept of "domains".

Significant changes on this branch include:

- Added `zipline.pipeline.domain` and the `Domain` interface.
  - Added several canonical domain definitions:
    - GENERIC
    - US_EQUITIES
    - CA_EQUITIES
    - GB_EQUITIES

- Added `zipline.country` as a place to define canonical country code names.

- Made `PipelineLoader` an interface and added new `domain` parameter to
  signature of `load_adjusted_array`.

- Added a new system for "generic" and "specialized" DataSet and BoundColumn
  objects.

- Added a new system for inferring a domain from a pipeline that contains a mix
  of generic and non-generic terms.

- Reworked the built-in pricing dataset. USEquityPricing dataset is now a
  specialized version of a generic EquityPricing dataset, and most built-in
  factors are now implemented in terms of EquityPricing rather than
  USEquityPricing.

- Removed `zipline.data.us_equity_pricing`.
  - Moved BcolzDailyBar{Reader,Writer} to `zipline.data.bcolz_daily_bars`.
  - Moved SQLiteAdjustment{Reader,Writer} to `zipline.data.adjustments`.

New dependencies added as part of this work:

- iso3166 (for canonical country code definitions)
- python-interface (for strict interface definitions).

See https://github.com/quantopian/zipline/issues/2265 for a full description of
the design for domains.
2018-09-10 10:05:39 -05:00
Richard Frank
61e472477b TST: Skip pipeline categorical tests under new pandas
Categoricals changed in 0.19
2018-07-10 11:19:02 -04:00
vikram-narayan
d4ba48709d MAINT: use trading_calendars in zipline
- remove zipline.utils.calendars
- update imports
- add trading-calendars to requirements
2018-07-02 11:10:49 -04:00
Joe Jevnik
423c7b7142 ENH: make sentinel track the created at location to debug conflicts 2018-02-26 17:48:14 -05:00
Scott Sanderson
74d00bd6cd MAINT: Add CachedObject.expired().
We often want the initial state of a CachedObject to be lazily computed,
which means we want a "pre-expired" CachedObject.
2017-07-26 15:35:28 -04:00
Ana Ruelas
69d1269fc4 ENH: Include sharedoc function 2017-06-02 16:48:26 -04:00
Ana Ruelas
a88df2be0d ENH: Add run_chunked_pipeline method to PipelineEngine 2017-06-02 16:48:09 -04:00
Ana Ruelas
bdd1f158a3 ENH: Add function for running pipelines in chunks 2017-06-02 16:47:55 -04:00
Ana Ruelas
897de69a2c ENH: Add function to concatenate list of dataframes with categoricals
STY: Alphabetized import list
2017-06-02 16:47:37 -04:00
dmichalowicz
41aa212617 BUG: Some futures prices need more precision when rounding 2017-05-24 08:18:52 -04:00
Eddie Hebert
9f60524e14 STY: Use def statements instead of lambda assignment. (#1639)
From pep-0008:

```
Always use a def statement instead of an assignment statement that binds a
lambda expression directly to an identifier.

Yes:

def f(x): return 2*x
No:

f = lambda x: 2*x

The first form means that the name of the resulting function object is
specifically 'f' instead of the generic '<lambda>'. This is more useful for
tracebacks and string representations in general. The use of the assignment
statement eliminates the sole benefit a lambda expression can offer over an
explicit def statement (i.e. that it can be embedded inside a larger expression)
```
2017-01-06 13:39:07 -05:00
Scott Sanderson
053206327b ENH: Name overrides in preprocessor factories.
Allows ``__funcname`` to be passed to preprocessors like expect_types
and expect_dtypes to override the name displayed in error messages.
This is useful for providing clearer errors for ``__init__`` and
``__new__`` methods in classes.
2016-10-12 15:50:10 -04:00
Jean Bredeche
7b83cbe820
ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Scott Sanderson
8cc8814b5f BUG: Fix nondeterministic failure from sorting. 2016-08-17 19:48:33 -04:00
Scott Sanderson
19963f5b02 MAINT: Clean up downsampling boilerplate.
Consolidate docs and mixin applications into one place.
2016-08-17 16:52:09 -04:00
Scott Sanderson
6ac8046498 MAINT: Add nearest_unequal_elements.. 2016-08-17 16:52:09 -04:00
Jean Bredeche
6fb4923cc7 Re-implemented the Calendar API.
Instead of having separate ExchangeCalendar and TradingSchedule objects, we
now just have TradingCalendar.  The TradingCalendar keeps track of each
session (defined as a contiguous set of minutes between an open and a close).
It's also responsible for handling the grouping logic of any given minute
to its containing session, or the next/previous session if it's not a market
minute for the given calendar.
2016-07-12 13:13:50 -04:00
Andrew Liang
1643bd1db6 BUG: get_first_trading_day_of_month needs to return normalized dt 2016-06-21 12:26:40 -04:00
jfkirk
d9fc514fa8 TST: Adds TradingSchedule test fixture 2016-06-08 13:34:20 -04:00
jfkirk
31f9f06c9a MAINT: Removes static calendar from schedule_function rules 2016-06-08 13:34:19 -04:00
jfkirk
241abda2a5 STY: Flake8 2016-06-08 13:34:19 -04:00
jfkirk
4b7390ac81 WIP: Refactors tests to use TradingSchedule 2016-06-08 13:34:19 -04:00
jfkirk
c8304e8601 ENH: Adds ExchangeCalendar, TradingSchedule, and implementations
Conflicts:
	tests/data/test_minute_bars.py
	tests/data/test_us_equity_pricing.py
	tests/finance/test_slippage.py
	tests/pipeline/test_engine.py
	tests/pipeline/test_us_equity_pricing_loader.py
	tests/serialization_cases.py
	tests/test_algorithm.py
	tests/test_assets.py
	tests/test_bar_data.py
	tests/test_benchmark.py
	tests/test_exception_handling.py
	tests/test_fetcher.py
	tests/test_finance.py
	tests/test_history.py
	tests/test_perf_tracking.py
	tests/test_security_list.py
	tests/utils/test_events.py
	zipline/algorithm.py
	zipline/data/data_portal.py
	zipline/data/us_equity_loader.py
	zipline/errors.py
	zipline/finance/trading.py
	zipline/testing/core.py
	zipline/utils/events.py
2016-06-08 13:34:18 -04:00
Joe Jevnik
9b76731143 ENH: adds with_metaclasses and tests for metautils 2016-05-12 15:58:19 -04:00
Andrew Liang
8aac0ab19f BUG: Week rule plus time rule doesn't work
The next trigger for the week rule get recalculated every time
the rule is triggered
2016-04-18 17:05:43 -04:00
Joe Jevnik
bc0b117dc9 MAINT: make the data loading apis more consistent.
Changes BcolzDailyBarWriter to not be an abc, data is passed as an
iterator of (sid, dataframe) pairs to the write method.

Changes the AssetsDBWriter to be a single class which accepts an engine
at construction time and has a `write` method for writing dataframes for
the various tables. We no longer support writing the various other data
types, callers should coerce their data into a dataframe themselves. See
zipline.assets.synthetic for some helpers to do this.

Adds many new fixtures and updates some existing fixtures to use the new
ones:

WithDefaultDateBounds
  A fixture that provides the suite a START_DATE and END_DATE. This is
  meant to make it easy for other fixtures to synchronize their date
  ranges without depending on eachother in strange ways. For example,
  WithBcolzMinuteBarReader and WithBcolzDailyBarReader by default should
  both have data for the same dates, so they may use depend on
  WithDefaultDates without forcing a dependency between them.

WithTmpDir, WithInstanceTmpDir
  Provides the suite or individual test case a temporary directory.

WithBcolzDailyBarReader
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzDailyBarWriter.write

WithBcolzDailyBarReaderFromCSVs
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from a
  collection of CSV files and then converted into the bcolz data through
  BcolzDailyBarWriter.write_csvs

WithBcolzMinuteBarReader
  Provides the suite a BcolzMinuteBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzMinuteBarWriter.write

WithAdjustmentReader
  Provides the suite a SQLiteAdjustmentReader which reads from an in
  memory sqlite database. The data will be read from dataframes and then
  converted into sqlite with SQLiteAdjustmentWriter.write

WithDataPortal
  Provides each test case a DataPortal object with data from temporary
  resources.
2016-04-15 23:46:10 -04:00
Andrew Liang
6d6cd58c3b BUG: Recalculate trigger for week rule if we miss the first one
If we start the simulation on a day so that we miss the trigger
(the first for the sim) for that week, recalculate the trigger
for next week
2016-04-15 15:09:08 -04:00
Andrew Liang
1ee3c5f049 BUG: week_end rule with offset=0 skips every other week 2016-04-15 10:17:18 -04:00
Eddie Hebert
76e14eda2f ENH: Add expiring cache.
Add a cache interface which supports expirable entries with a changeable
backend for the cache into which they are entered.

The default cache is a `dict` but could swapped for
`cachetools.LRUCache` or any other cache which supports `__get__`,
`__set__`, and `__del__`.

So that consumers can change the use of `CachedObjects` stored in a
cache from:

```
self._cache = {}

...

try:
    obj = self._cache[key]
    try:
        return obj.unwrap(dt)
    except Expired:
        pass
except KeyError:
    pass

...

self._cache[key] = CachedObject(value, new_expiration)
```

to:

```
self._cache = ExpiringCache(LRUCache(maxsize=6))

...

try:
    return self._cache.get(key, dt)
except KeyError:
    # Get fresh value
    ...

    self._cache.set(key, value, new_expiration)
```
2016-04-14 16:10:32 -04:00
Richard Frank
32a400a9fb BUG: Fixing bitness issues on 32-bit systems
by being explicit with sizes
2016-04-12 17:07:50 -04:00
Andrew Liang
a8491879ce FIX: time_rules should trigger only at dt specified
Previously, time_rules triggered when the dt specified has passed
2016-04-05 17:51:10 -04:00
Eddie Hebert
16fd6681a6 ENH: Rewrite of Zipline to use lazy access pattern
More documentation to follow in release notes.

Based on lazy-mainline branch, see for more details.

Also-By: Jean Bredeche <jean@quantopian.com>
Also-By: Andrew Liang <aliang@quantopian.com>
Also-By: Abhijeet Kalyan <akalyan@quantopian.com>
2016-04-04 16:12:58 -04:00
Scott Sanderson
1245552340 DEV: Add expect_dimensions preprocessor. 2016-03-25 15:11:18 -04:00
Richard Frank
d873038a7e BUG: Specify int64 instead of system int
to handle 32bit python
2016-03-23 15:26:52 -04:00
Joe Jevnik
721dd36116 TST: move test_utils and adds test fixture classes
Renames zipline.utils.test_utils to zipline.testing

Adds zipline.testing.fixtures.ZiplineTestCase to manage setup and
teardown and adds mixins to define fixtures like an asset finder or
trading calendar.
2016-03-10 15:39:52 -05:00
Scott Sanderson
e810f26097 ENH: Add utilities for checking types generically. 2016-03-07 16:18:33 -05:00
Joe Jevnik
e33cc25265 TST: fix redundant partial 2016-02-11 18:46:42 -05:00
Joe Jevnik
5351b60a4c ENH: adds optionally for preprocessors 2016-01-13 15:26:37 -05:00
Joe Jevnik
5a235bdaef ENH: allows users to specify the cutoff time for data query in blaze
loaders

This allows people to set their cutoff time to the time they will
actually execute 'before_trading_start'. Currently this is just passed
to the constructor of the loader; however, I would like to make this
managed by the algorithm simulation runner. This would help keep all of
the loaders in sync and lock 'before_trading_start's execution to the
time the data is queried for.
2016-01-13 15:26:13 -05:00
llllllllll
f8ab8a5159 TST: py3 compat qualname in preprocess tests 2015-12-09 12:49:59 -05:00
Scott Sanderson
8220d1ee86 ENH: Adds support for different typed adjusted arrays and adds an
EarningsCalendar loader.

- Moves most of AdjustedArray back into Python. The window iterator is
  the only part that's performance-intensive.

- Adds a bootleg templating system for creating specialized versions of
  AdjustedArrayWindow for each concrete type we care about.

- Adds support for differently dtyped terms in pipeline. This allows us
  to use datetime64s which are needed in the EarningsCalendar.

- Adds EarningsCalendar dataset for the next and previous earnings
  announcements in pipeline.

- Adds in memory loader for EarningsCalendar.

- Adds blaze loader for EarningsCalendar.
2015-12-08 20:24:06 -05:00
llllllllll
c62ac9ba74 ENH: cannot create two sentinels with same name and different doc 2015-11-24 16:45:52 -05:00
llllllllll
0cf85dec98 BUG: fix issues with sentinel 2015-11-24 15:07:27 -05:00
Scott Sanderson
aef38c4a74 MAINT: Remove unused import. 2015-11-17 11:22:08 -05:00
Scott Sanderson
0f349fc3ed MAINT: Fix type coercion warnings with numpy 1.10.
Numpy warns about adding Python integers to uint32s and converting date
objects to datetime64.
2015-11-15 22:42:36 -05:00
llllllllll
0f5cf78492 MAINT: use subtest to quiet the output from test_events 2015-11-11 19:23:20 -05:00
llllllllll
1e05a1c4ae TST: fix py2 compat for test 2015-10-19 16:35:03 -04:00