Commit Graph

3685 Commits

Author SHA1 Message Date
Eddie Hebert 9e2c5d9505 Merge pull request #1130 from quantopian/expiring-cache
ENH: Add expiring cache.
2016-04-14 22:17:25 -04:00
Eddie Hebert ee26b57517 DOC: Add whatsnew entry for ExpiringCache. 2016-04-14 16:10:32 -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
Jean Bredeche 86667685d7 Merge pull request #1129 from quantopian/empty-lists
BUG: support passing an empty list to `data` methods.
2016-04-14 11:35:42 -04:00
Jean Bredeche 63bd7589b7 BUG: support passing an empty list to data methods.
Our type checking code was a bit too aggressive.
2016-04-14 11:11:08 -04:00
Eddie Hebert 25c6d6ea55 Merge pull request #1128 from quantopian/remove-extra-parameter-to-position-of-minute
Fix regression on retrieval of minute positions.
2016-04-14 10:23:18 -04:00
Eddie Hebert e78f4f0729 PERF: Remove memoization from minute bar position.
Instead of using the `remember_last` memoization on all calls to
`_find_position_of_minute`, add an instance local cache which is only
used by the `get_value` call. The `get_value` call is very hot, so any
extra overhead (e.g. creating the WeakArgs on every invocation) becomes
costly. The current usage `get_value` also has the property that it is
called with monotonically increasing, but with a high repeat count on
each value. (A further improvement could making a `get_value` which
supports being used by many sids, for use by the update portfolio
positions.)

The caching is not done at the `_find_position_of_minute_level` because
`unadjusted_window` always uses two positions on the tape (start and end
of range) which would cause the entries and removal into the cache which
would be invalidated both between the calls of start and end, and next
call of the function.
2016-04-14 10:08:35 -04:00
Eddie Hebert 0a3c9c8448 MAINT: Remove adjusted arg to position of minute.
The argument was only needed for mapping the positions which need to be
removed on adjusted windows. The start and end position of each range
can be derived from the early closes' positions and the market open,
respectively.

Remove to reduce moving parts.
2016-04-14 09:56:48 -04:00
Jean Bredeche 3a1bcdbc39 Merge pull request #1117 from quantopian/error_messages2
FIX: Check types of args passed to api methods on data
2016-04-13 20:38:41 -04:00
Jean Bredeche bd36e92556 DEV: minor perf boosts
likely doesn’t move the needle that much
2016-04-13 16:34:04 -04:00
Jean Bredeche d94b7bb9e4 DEV: Don't need to pass method name in. 2016-04-13 16:09:18 -04:00
Jean Bredeche d597a3caaa DEV: combined the decorators
This way the type decorator could have access to the argument
decorator’s keyword list.
2016-04-13 16:01:00 -04:00
Eddie Hebert 08c859aadb Merge pull request #1127 from quantopian/remove-daily-bar-loader-cache
PERF: Remove extra daily history caching.
2016-04-13 12:30:20 -04:00
Eddie Hebert 5ea0bd2f87 PERF: Remove extra daily history caching.
The cache in data portal was added before the change to using a
CachedObject to wrap the window_blocks in the USEquityHistoryLoader.

Removing this extra layer saves some cycles.

Does not fix current memory investigaton (since only one sids/dts pair
per column was cached in `_equity_daily_reader_array_data` at a time),
but removing should make it more clear where needed references are being
held.
2016-04-13 11:11:00 -04:00
Andrew Liang 2775cc7ca4 FIX: Remove support for passing in sid int in place of Asset 2016-04-13 09:47:07 -04:00
Andrew Liang 8dc3ed73ab FIX: Check types of args passed to api methods on data 2016-04-13 09:47:07 -04:00
Jean Bredeche fac5905c10 Merge pull request #1114 from quantopian/handle-data-optional
ENH: make handle_data optional
2016-04-13 09:31:41 -04:00
Eddie Hebert 8b3bf34344 Merge pull request #1126 from quantopian/remove-minute-bar-loader-cache
BUG/PERF: Remove extra minute bar loader cache.
2016-04-12 22:18:37 -04:00
Eddie Hebert d659a1d78c BUG/PERF: Remove extra minute bar loader cache.
The minute history loader caching was incorrectly mimicking the daily
history loader caching.

Where caching the adjusted array on the last dt helps an access pattern
of repeated calling history windows on the same day (which has an end_dt
of the previous day), with minute windows the end dt is always moving
forward, so the cached values are seldom used. (Would only be used if
`history` was called with same parameters twice on the same simulation time.)
2016-04-12 21:27:34 -04:00
Richard Frank 4a1dd9967a Merge pull request #1115 from quantopian/lazy_windows
Fix windows/conda builds
2016-04-12 19:41:44 -04:00
Richard Frank 5bfa433cd1 BLD: bcolz 1.0.0 slowing us down 2016-04-12 19:33:22 -04:00
Richard Frank 3fdefea1b0 BLD: Updated bcolz recipe customizations
to be more accurate of reqs
2016-04-12 19:33:22 -04:00
Richard Frank 35085c6040 MAINT: Removed unused method 2016-04-12 19:33:22 -04:00
Richard Frank 70befd490b MAINT: Don't store data portal everywhere
Removed lots of data portal references that participated in ref cycles
and prevented deterministic cleanup of dbs.
2016-04-12 19:33:22 -04:00
Richard Frank 8b610a2ab7 TST: Cleaned up test references to adjustments db
If we don't clean them up, then windows can delete
the temp dir with the db.
2016-04-12 19:33:22 -04:00
Richard Frank 5254b273b2 PERF: Reimplemented remember_last with a weak_lru_cache
which won't leak instances whose methods have been decorated

(specifically DataPortal instances)

MAINT: Not using functools32 anymore
2016-04-12 19:33:21 -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
Eddie Hebert 8313c8c36c Merge pull request #1125 from quantopian/enforce-sorted-on-minute-bars
BUG: Enforce sorted order on minutes to delete.
2016-04-12 15:18:30 -04:00
Jean Bredeche 1d2fa555dc Merge pull request #1124 from quantopian/properly-report-partially-filled-sells
BUG: Properly log partially filled sell orders.
2016-04-12 14:31:20 -04:00
Eddie Hebert d27f85e16b BUG: Enforce sorted order on minutes to delete.
The intervals are returned as a set, so order is not guaranteed,
which becomes exposed when reading windows which span multiple years.

The deletion of values from the regular sized minute array assumes that
intervals can be reversed to delete the array from the back.
2016-04-12 14:16:10 -04:00
Jean Bredeche bd5e2b183d BUG: Properly log partially filled sell orders. 2016-04-12 13:57:50 -04:00
David Michalowicz d2ab5ed46e Merge pull request #1123 from quantopian/masked-factor-docs
DOC: Docstring and whatsnew for masked custom factors.
2016-04-12 12:40:22 -04:00
dmichalowicz b94cc73d26 DOC: Docstring and whatsnew for masked custom factors. 2016-04-12 11:59:17 -04:00
Jean Bredeche 3f2a5746f8 Merge pull request #1121 from quantopian/pass-iterable-to-dataportal
BUG: bar_data.history too limiting on iterable types
2016-04-11 14:56:09 -04:00
Jean Bredeche f6902f0368 BUG: bar_data.history too limiting on iterable types
In before_trading_start, history needs to call
DataPortal.get_adjustments, and that method wasn’t correctly checking
for iterables.
2016-04-11 14:02:27 -04:00
Eddie Hebert 9561073c9d Merge pull request #1122 from quantopian/remove-unused-bts
MAINT: Remove unused member.
2016-04-11 13:55:36 -04:00
Eddie Hebert ccef816e7e MAINT: Remove unused member.
The "in before trading start logic" is now all handled inside of
`BarData`.
2016-04-11 13:47:17 -04:00
Scott Sanderson 675eff4f6d Merge pull request #1095 from quantopian/factor-mask
Pass a mask (filter) to custom factors
2016-04-07 20:34:10 -04:00
Scott Sanderson 4449f289c2 TEST: Test that the mask is what we expect. 2016-04-07 17:29:47 -04:00
dmichalowicz 8db59b387b TST: Overhaul test case 2016-04-07 17:29:47 -04:00
Scott Sanderson 88eeb3689d MAINT: Make dependencies a dict. 2016-04-07 17:29:47 -04:00
dmichalowicz 5bae74adda ENH: Allow passing a mask when creating a factor 2016-04-07 17:29:47 -04:00
Eddie Hebert c5e15f2e8e Merge pull request #1116 from quantopian/ensure-matched-write-col-input
BUG: Ensure matched input length to minute writer.
2016-04-07 14:02:02 -04:00
Eddie Hebert 0a3a2f3653 BUG: Ensure matched input length to minute writer.
When the dts and length of cols are mismatched the writer behaves in
unintended ways. e.g. in a case where a consumer passed dts which had
minutes with no trades removed, but regular (market minute for day)
sized arrays for the data with `0`'s on minutes without trades, the non
trade minutes from cols are written to slots in the output where a trade
is intended.

Protect against this misuse by checking that all lengths are equal when
using the `write_cols` method.

Make a separate `_write_cols` method for use by both `write_cols` and
`write`, since the `write` method which takes a DataFrame has the
matched input length enforced by the DataFrame.
2016-04-07 13:53:59 -04:00
Jean Bredeche 4203c54417 ENH: make handle_data optional 2016-04-07 09:50:09 -04:00
Maya Tydykov 005299e7e4 MAINT: update blaze version 2016-04-06 13:49:32 -04:00
Richard Frank 6e7c66b158 BLD: ordered_pip is unforgiving 2016-04-06 09:33:33 -04:00
Andrew Liang 2454454b07 Merge pull request #1112 from quantopian/schedule_func_midday
FIX: time_rules should trigger only at dt specified
2016-04-06 09:16:43 -04:00
Richard Frank 4cc60480fa Merge pull request #1110 from quantopian/env-markers
Env markers
2016-04-05 23:46:48 -04:00
Richard Frank c9a7b936ed MAINT: Fix pip install -e . 2016-04-05 23:07:00 -04:00