Skip to content

Commit

Permalink
Merge pull request #1183 from quantopian/extract-fetcher-method
Browse files Browse the repository at this point in the history
DEV: extract fetcher method for easier downstream use
  • Loading branch information
jbredeche committed May 5, 2016
2 parents 402fb2a + 9c291cf commit 6997299
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions zipline/data/data_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,15 @@ def _is_extra_source(asset, field, map):

return not (field in BASE_FIELDS and isinstance(asset, Asset))

def _get_fetcher_value(self, asset, field, dt):
day = normalize_date(dt)

try:
return \
self._augmented_sources_map[field][asset].loc[day, field]
except KeyError:
return np.NaN

def get_spot_value(self, asset, field, dt, data_frequency):
"""
Public API method that returns a scalar value representing the value
Expand All @@ -707,13 +716,7 @@ def get_spot_value(self, asset, field, dt, data_frequency):
The value of the desired field at the desired time.
"""
if self._is_extra_source(asset, field, self._augmented_sources_map):
day = normalize_date(dt)

try:
return \
self._augmented_sources_map[field][asset].loc[day, field]
except KeyError:
return np.NaN
return self._get_fetcher_value(asset, field, dt)

if field not in BASE_FIELDS:
raise KeyError("Invalid column: " + str(field))
Expand Down

0 comments on commit 6997299

Please sign in to comment.