update function now getting share data from json and updating on all shares
This commit is contained in:
@@ -7,50 +7,21 @@ __version__ = "0.0.2"
|
||||
__license__ = "None"
|
||||
|
||||
import yfinance
|
||||
import json
|
||||
|
||||
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
|
||||
|
||||
class Share_Handler:
|
||||
def __init__(self):
|
||||
return
|
||||
|
||||
def all_share_prices_for_user(self, int_user_id):
|
||||
|
||||
""" Get all share prices for a certain user with his id
|
||||
:type int_user_id: integer
|
||||
:param int_user_id: user_id to get all share prices for
|
||||
|
||||
:raises: none
|
||||
|
||||
:rtype: ###tbd### (maybe dictonary)
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
def get_share_price(self, str_symbol):
|
||||
|
||||
""" get current share price for a certain symbol
|
||||
:type str_symbol: string
|
||||
:param str_symbol: share symbol to get price for
|
||||
|
||||
:raises:
|
||||
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
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"]}'
|
||||
return my_return_string
|
||||
|
||||
|
||||
:raises:
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
""" test object and get share price
|
||||
:raises: none
|
||||
|
||||
:rtype: none
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
new_handler = Share_Handler()
|
||||
print(new_handler.get_share_price("TL0.DE"))
|
||||
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
|
16
telegram_bot/shares/shares_example.json
Normal file
16
telegram_bot/shares/shares_example.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"user": "NormalParameter",
|
||||
"share_count": 2,
|
||||
"shares": [
|
||||
{
|
||||
"symbol": "APC.DE",
|
||||
"price_bought": "50.06",
|
||||
"amount_bought": "5.1"
|
||||
},
|
||||
{
|
||||
"symbol": "TL0.DE",
|
||||
"price_bought": "450.06",
|
||||
"amount_bought": "5.13"
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user