Initial Commit

This commit is contained in:
socks 2021-02-12 18:46:33 +00:00
commit dcb1e5d1e9
3 changed files with 51 additions and 0 deletions

11
Pipfile Normal file
View file

@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.8"

5
main.py Normal file
View file

@ -0,0 +1,5 @@
import discord
from discord.ext import commands

35
table.py Normal file
View file

@ -0,0 +1,35 @@
from tabulate import tabulate
import yfinance as yf
def get_current_price(ticker):
yf_obj = yf.Ticker(ticker)
todays_data = yf_obj.history(period='1d')
return round(todays_data['Close'][0], 2)
stonks = {
'MSFT': 4.3,
'AAPL': 13,
'GME' : 212
}
def generate_table(stonks):
table_data = []
total = 0
for ticker in stonks.keys():
price = get_current_price(ticker)
table_data.append([ticker, price * stonks[ticker]])
total += (price * stonks[ticker])
table_data.append(['Total', total])
return table_data
print( tabulate(
generate_table(stonks),
['Ticker', 'Value'],
tablefmt="fancy_grid"
))