clean up yfinance index commands for errors

This commit is contained in:
james
2022-03-15 11:15:33 -04:00
parent 54d067f40f
commit 56d86bdd56
2 changed files with 9 additions and 5 deletions

View File

@@ -71,14 +71,16 @@ def get_index(
)
if column not in index_data.columns:
return console.print(
console.print(
f"The chosen column is not available for {ticker}. Please choose "
f"between: {', '.join(index_data.columns)}"
f"between: {', '.join(index_data.columns)}\n"
)
return pd.Series()
if index_data.empty or len(index_data) < 2:
return console.print(
console.print(
f"The chosen index {ticker}, returns no data. Please check if "
f"there is any data available."
f"there is any data available.\n"
)
return pd.Series()
return index_data[column]

View File

@@ -66,7 +66,9 @@ def show_indices(
indices_data: pd.DataFrame = pd.DataFrame()
for index in indices:
indices_data[index] = get_index(index, interval, start_date, end_date, column)
index_data = get_index(index, interval, start_date, end_date, column)
if not index_data.empty:
indices_data[index] = index_data
if not store:
if external_axes is None: