MCPcopy
hub / github.com/quantopian/zipline / _lookup_generic_scalar_helper

Method _lookup_generic_scalar_helper

zipline/assets/assets.py:1321–1348  ·  view source on GitHub ↗
(self, obj, as_of_date, country_code)

Source from the content-addressed store, hash-verified

1319 missing.append(obj)
1320
1321 def _lookup_generic_scalar_helper(self, obj, as_of_date, country_code):
1322
1323 if isinstance(obj, (Asset, ContinuousFuture)):
1324 return obj
1325
1326 if isinstance(obj, Integral):
1327 try:
1328 return self.retrieve_asset(int(obj))
1329 except SidsNotFound:
1330 return None
1331
1332 if isinstance(obj, string_types):
1333 # Try to look up as an equity first.
1334 try:
1335 return self.lookup_symbol(
1336 symbol=obj,
1337 as_of_date=as_of_date,
1338 country_code=country_code
1339 )
1340 except SymbolNotFound:
1341 # Fall back to lookup as a Future
1342 try:
1343 # TODO: Support country_code for future_symbols?
1344 return self.lookup_future_symbol(obj)
1345 except SymbolNotFound:
1346 return None
1347
1348 raise NotAssetConvertible("Input was %s, not AssetConvertible." % obj)
1349
1350 def lookup_generic(self, obj, as_of_date, country_code):
1351 """

Callers 1

Calls 4

retrieve_assetMethod · 0.95
lookup_symbolMethod · 0.95
lookup_future_symbolMethod · 0.95
NotAssetConvertibleClass · 0.85

Tested by

no test coverage detected