Skip to content

Commit

Permalink
Repaired Morningstar volume for indicies (#488)
Browse files Browse the repository at this point in the history
Repaired Morningstar volume for indicies
  • Loading branch information
addisonlynch authored and bashtage committed Feb 18, 2018
1 parent f3d754c commit 9acc0d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/source/whatsnew/v0.7.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Bug Fixes

- Added support for passing the API KEY to QuandlReader either directly or by
setting the environmental variable QUANDL_API_KEY (:issue:`485`).
- Handle Morningstar index volume data properly (:issue:`486`).
11 changes: 9 additions & 2 deletions pandas_datareader/mstar/daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import requests
from pandas import DataFrame
import numpy as np

from pandas_datareader._utils import SymbolWarning
from pandas_datareader.base import _BaseReader
Expand Down Expand Up @@ -161,7 +162,10 @@ def _restruct_json(self, symbol, jsondata):

pricedata = jsondata["PriceDataList"][0]["Datapoints"]
dateidx = jsondata["PriceDataList"][0]["DateIndexs"]
volumes = jsondata["VolumeList"]["Datapoints"]
if jsondata["VolumeList"]:
volumes = jsondata["VolumeList"]["Datapoints"]
else:
volumes = None

dates = self._convert_index2date(indexvals=dateidx)
barss = []
Expand Down Expand Up @@ -192,7 +196,10 @@ def _restruct_json(self, symbol, jsondata):
else:
pass
if self.incl_vol is True:
bardict.update({"Volume": int(volumes[p] * 1000000)})
if volumes is None:
bardict.update({"Volume": np.nan})
else:
bardict.update({"Volume": int(volumes[p] * 1000000)})
else:
pass

Expand Down

0 comments on commit 9acc0d0

Please sign in to comment.