Skip to content

client.optionsDF(ticker) throws KeyError #121

@satyan-g

Description

@satyan-g

Two issues:

  1. optionsDF throws obscure KeyError exception about 'tradeTimeInLong' when it has no options to return.
  2. IPV is an optionable ticker, but client.options('IPV') returns no options

c.optionsDF('IPV')

KeyError Traceback (most recent call last)
~/anaconda/envs/TDOptions/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2645 try:
-> 2646 return self._engine.get_loc(key)
2647 except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'tradeTimeInLong'

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)
in
----> 1 c.optionsDF('IPV')

~/anaconda/envs/TDOptions/lib/python3.7/site-packages/tdameritrade-0.1.0-py3.7.egg/tdameritrade/client.py in optionsDF(self, symbol, contractType, strikeCount, includeQuotes, strategy, interval, strike, range, fromDate, toDate, volatility, underlyingPrice, interestRate, daysToExpiration, expMonth, optionType)
414 for col in ('tradeTimeInLong', 'quoteTimeInLong',
415 'expirationDate', 'lastTradingDay'):
--> 416 df[col] = pd.to_datetime(df[col], unit='ms')
417
418 return df

~/anaconda/envs/TDOptions/lib/python3.7/site-packages/pandas/core/frame.py in getitem(self, key)
2798 if self.columns.nlevels > 1:
2799 return self._getitem_multilevel(key)
-> 2800 indexer = self.columns.get_loc(key)
2801 if is_integer(indexer):
2802 indexer = [indexer]

~/anaconda/envs/TDOptions/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2646 return self._engine.get_loc(key)
2647 except KeyError:
-> 2648 return self._engine.get_loc(self._maybe_cast_indexer(key))
2649 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2650 if indexer.ndim > 1 or indexer.size > 1:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'tradeTimeInLong'

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogIssues that haven't been categorized or are not yet ready for workbugConcrete, reproducible bugs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions