Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions finquant/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def _yfinance_request(
# unlike quandl, yfinance does not have a prefix in front of the ticker
# thus we do not need to correct them
try:
resp: pd.DataFrame = yfinance.download(names, start=start_date, end=end_date)
resp: pd.DataFrame = yfinance.download(names, start=start_date, end=end_date, auto_adjust=False)
if not isinstance(resp.columns, pd.MultiIndex) and len(names) > 0:
# for single stock must make the dataframe multiindex
stock_tuples = [(col, names[0]) for col in list(resp.columns)]
Expand Down Expand Up @@ -982,11 +982,11 @@ def _get_stocks_data_columns(
reqnames: List[str] = _correct_quandl_request_stock_name(names)
# get current column labels and replacement labels
reqcolnames: List[str] = []
colname: str
# if dataframe is of type multiindex, also get first level colname
firstlevel_colnames: List[str] = []
for idx, name in enumerate(names):
for col in cols:
colname: str
# differ between dataframe directly from quandl and
# possibly previously processed dataframe, e.g.
# read in from disk with slightly modified column labels
Expand All @@ -1013,6 +1013,10 @@ def _get_stocks_data_columns(
raise ValueError(
"Could not find column labels in the second level of MultiIndex pd.DataFrame"
)
else:
raise ValueError(
"Could not find column labels in the MultiIndex pd.DataFrame"
)
# else, error
else:
raise ValueError("Could not find column labels in the given dataframe.")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_quants.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_sharpe_ratio():


def test_sortino_ratio():
assert sortino_ratio(0.5, 0.0, 0.02) is np.NaN
assert sortino_ratio(0.5, 0.0, 0.02) is np.nan
assert sortino_ratio(0.005, 8.5, 0.005) == 0.0


Expand Down