Working with isin, symbol and company name now

This commit is contained in:
Florian Kellermann
2022-05-07 17:50:32 +02:00
parent 925b3ead62
commit 7af5aec49c
3 changed files with 40 additions and 18 deletions

View File

@@ -7,20 +7,42 @@ __version__ = "0.0.2"
__license__ = "None"
import yfinance
import investpy
import pandas
def get_share_price(str_symbol):
""" get current share price for a certain symbol
:type str_symbol: string
:param str_symbol: share symbol to get price for
def get_share_price(str_search_for):
"""_summary_
:raises:
Args:
str_search_for (_type_): _description_
:rtype:
Returns:
_type_: _description_
"""
my_share_info = yfinance.Ticker(str_symbol)
my_share_data = my_share_info.info
#my_return_string = f'{my_share_data["regularMarketPrice"]} {my_share_data["currency"]}'
my_return_string = f'{my_share_data["regularMarketPrice"]}'
return my_return_string
search_result = investpy.search_quotes(text=str_search_for, products=['stocks'],
countries=['germany'], n_results=1)
currency = str(search_result.retrieve_currency())
recent_data = pandas.DataFrame(search_result.retrieve_recent_data())
stock_price = recent_data.iloc[-1]["Close"]
str_return =str(stock_price) + " " + str(currency)
return str_return
def get_share_information(str_search_for):
search_result = investpy.search_quotes(text=str_search_for, products=['stocks'],
countries=['germany'], n_results=1)
str_return = "Company: " + search_result.name + "\nSymbol: " + search_result.symbol + "\nCurrent Price/Share: " + get_share_price(str_search_for)
return str_return
if __name__ == "__main__":
print(get_share_price("AAPL"))
print(get_share_information("AAPL"))