From 6a8d4c40126e93e84fbeca8a630086871da29db0 Mon Sep 17 00:00:00 2001 From: Azwan Zuharimi <55450377+azwanzuharimi@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:10:31 +0000 Subject: [PATCH] fixed a future warning appearing on get_quote_table and get_live_price --- yahoo_fin/stock_info.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yahoo_fin/stock_info.py b/yahoo_fin/stock_info.py index f75e9b0..10e5bf2 100644 --- a/yahoo_fin/stock_info.py +++ b/yahoo_fin/stock_info.py @@ -13,6 +13,7 @@ from Crypto.Util.Padding import unpad # For pretty print from pprint import pp +from io import StringIO try: @@ -300,7 +301,7 @@ def get_quote_table(ticker , dict_result = True, headers = {'User-agent': 'Mozil site = "https://finance.yahoo.com/quote/" + ticker + "?p=" + ticker - tables = pd.read_html(requests.get(site, headers=headers).text) + tables = pd.read_html(StringIO(requests.get(site, headers=headers).text)) data = pd.concat([tables[0], tables[1]]) @@ -656,7 +657,7 @@ def get_live_price(ticker): df = get_data(ticker, end_date = pd.Timestamp.today() + pd.DateOffset(10)) - return df.close[-1] + return df.close.iloc[-1] def get_live_prices(ticker_list): base_quotes_url = 'https://query1.finance.yahoo.com/v7/finance/quote?symbols='