WillKoehrsen / Data-Analysis

Data Science Using Python
https://medium.com/@williamkoehrsen/
MIT License
5.16k stars 3.64k forks source link

Cannot load stocks from ASX #14

Closed leowhitehead closed 5 years ago

leowhitehead commented 6 years ago

Followed all examples listed and they seemed to work well, however when following the quandl page on api usage, I cannot load information from the Australian Securities Exchange.

s = Stocker(ticker="A2M", exchange="ASX/IBX2019")

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.5/site-packages/pandas/core/indexes/base.py", line 3078, in get_loc
    return self._engine.get_loc(key)
  File "pandas/_libs/index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Close'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/d/Users/Leo/Documents/MEGA/python/stocker/stocker.py", line 47, in __init__
    stock['Adj. Close'] = stock['Close']
  File "/home/user/.local/lib/python3.5/site-packages/pandas/core/frame.py", line 2688, in __getitem__
    return self._getitem_column(key)
  File "/home/user/.local/lib/python3.5/site-packages/pandas/core/frame.py", line 2695, in _getitem_column
    return self._get_item_cache(key)
  File "/home/user/.local/lib/python3.5/site-packages/pandas/core/generic.py", line 2489, in _get_item_cache
    values = self._data.get(item)
  File "/home/user/.local/lib/python3.5/site-packages/pandas/core/internals.py", line 4115, in get
    loc = self.items.get_loc(item)
  File "/home/user/.local/lib/python3.5/site-packages/pandas/core/indexes/base.py", line 3080, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Close'

This works for any asx stock I try.

WillKoehrsen commented 5 years ago

I don't think quandl supports that exchange. You need to make sure you are using an exchange available on quandl. You can take a look at the Quandl Python documentation to try and figure out which exchanges are still supported. I know the WIKI exchange has been deprecated so I'll have to update that.