Skip to content

Commit

Permalink
Merge pull request #1662 from quantopian/remove-unused-future-methond…
Browse files Browse the repository at this point in the history
…s-from-asset-finder

MAINT: Remove unused futures related methods from asset finder.
  • Loading branch information
ehebert authored Jan 26, 2017
2 parents eb2e7d8 + 24f78a1 commit 0f18602
Showing 1 changed file with 1 addition and 82 deletions.
83 changes: 1 addition & 82 deletions zipline/assets/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
ASSET_DB_VERSION
)
from zipline.utils.control_flow import invert
from zipline.utils.memoize import lazyval, weak_lru_cache
from zipline.utils.memoize import lazyval
from zipline.utils.numpy_utils import as_column
from zipline.utils.preprocess import preprocess
from zipline.utils.sqlite_utils import group_into_chunks, coerce_string_to_eng
Expand Down Expand Up @@ -982,87 +982,6 @@ def get_supplementary_field(
# Could not find a value for this sid on the as_of_date.
raise NoValueForSid(field=field_name, sid=sid)

@weak_lru_cache(100)
def _get_future_sids_for_root_symbol(self, root_symbol, as_of_date_ns):
fc_cols = self.futures_contracts.c

return list(map(
itemgetter('sid'),
sa.select((fc_cols.sid,)).where(
(fc_cols.root_symbol == root_symbol) &

# Filter to contracts that are still valid. If both
# exist, use the one that comes first in time (i.e.
# the lower value). If either notice_date or
# expiration_date is NaT, use the other. If both are
# NaT, the contract cannot be included in any chain.
sa.case(
[
(
fc_cols.notice_date == pd.NaT.value,
fc_cols.expiration_date >= as_of_date_ns
),
(
fc_cols.expiration_date == pd.NaT.value,
fc_cols.notice_date >= as_of_date_ns
)
],
else_=(
sa.func.min(
fc_cols.notice_date,
fc_cols.expiration_date
) >= as_of_date_ns
)
)
).order_by(
# If both dates exist sort using minimum of
# expiration_date and notice_date
# else if one is NaT use the other.
sa.case(
[
(
fc_cols.expiration_date == pd.NaT.value,
fc_cols.notice_date
),
(
fc_cols.notice_date == pd.NaT.value,
fc_cols.expiration_date
)
],
else_=(
sa.func.min(
fc_cols.notice_date,
fc_cols.expiration_date
)
)
).asc()
).execute().fetchall()
))

def lookup_expired_futures(self, start, end):
if not isinstance(start, pd.Timestamp):
start = pd.Timestamp(start)
start = start.value
if not isinstance(end, pd.Timestamp):
end = pd.Timestamp(end)
end = end.value

fc_cols = self.futures_contracts.c

nd = sa.func.nullif(fc_cols.notice_date, pd.tslib.iNaT)
ed = sa.func.nullif(fc_cols.expiration_date, pd.tslib.iNaT)
date = sa.func.coalesce(sa.func.min(nd, ed), ed, nd)

sids = list(map(
itemgetter('sid'),
sa.select((fc_cols.sid,)).where(
(date >= start) & (date < end)).order_by(
sa.func.coalesce(ed, nd).asc()
).execute().fetchall()
))

return sids

def _get_contract_sids(self, root_symbol):
fc_cols = self.futures_contracts.c

Expand Down

0 comments on commit 0f18602

Please sign in to comment.