Working with isin, symbol and company name now
This commit is contained in:
parent
925b3ead62
commit
7af5aec49c
@ -276,14 +276,12 @@ def send_share_update(message):
|
|||||||
"""
|
"""
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
|
|
||||||
#Get Information for user with this id
|
bot.send_message(chat_id=user_id, text='Send Symbol/ISIN of share or name of company:')
|
||||||
bot.send_message(chat_id=user_id, text='Send symbol of share:')
|
|
||||||
#str_share_price = shares.wait_for_share.main_loop(bot)
|
|
||||||
bot.register_next_step_handler(message, send_share_price)
|
bot.register_next_step_handler(message, send_share_price)
|
||||||
|
|
||||||
def send_share_price(message):
|
def send_share_price(message):
|
||||||
str_share_price = share_fetcher.get_share_price(str(message.text))
|
str_share_price = share_fetcher.get_share_information(str(message.text))
|
||||||
bot.reply_to(message, str_share_price) # add dollar symbol etc.
|
bot.reply_to(message, str_share_price)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['allnews', 'Allnews']) # /allnews -> get all news
|
@bot.message_handler(commands=['allnews', 'Allnews']) # /allnews -> get all news
|
||||||
|
@ -7,3 +7,5 @@ requests~=2.27.1
|
|||||||
APScheduler~=3.9.1
|
APScheduler~=3.9.1
|
||||||
croniter~=1.3.4
|
croniter~=1.3.4
|
||||||
tzlocal==2.1
|
tzlocal==2.1
|
||||||
|
investpy~=1.0.8
|
||||||
|
pandas~=1.4.1
|
@ -7,20 +7,42 @@ __version__ = "0.0.2"
|
|||||||
__license__ = "None"
|
__license__ = "None"
|
||||||
|
|
||||||
import yfinance
|
import yfinance
|
||||||
|
import investpy
|
||||||
|
import pandas
|
||||||
|
|
||||||
def get_share_price(str_symbol):
|
def get_share_price(str_search_for):
|
||||||
|
"""_summary_
|
||||||
|
|
||||||
""" get current share price for a certain symbol
|
Args:
|
||||||
:type str_symbol: string
|
str_search_for (_type_): _description_
|
||||||
:param str_symbol: share symbol to get price for
|
|
||||||
|
|
||||||
:raises:
|
Returns:
|
||||||
|
_type_: _description_
|
||||||
:rtype:
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
my_share_info = yfinance.Ticker(str_symbol)
|
search_result = investpy.search_quotes(text=str_search_for, products=['stocks'],
|
||||||
my_share_data = my_share_info.info
|
countries=['germany'], n_results=1)
|
||||||
#my_return_string = f'{my_share_data["regularMarketPrice"]} {my_share_data["currency"]}'
|
|
||||||
my_return_string = f'{my_share_data["regularMarketPrice"]}'
|
currency = str(search_result.retrieve_currency())
|
||||||
return my_return_string
|
|
||||||
|
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"))
|
Loading…
Reference in New Issue
Block a user