-
Notifications
You must be signed in to change notification settings - Fork 2
/
show.py
76 lines (64 loc) · 2.43 KB
/
show.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from utils import select_one_ranom_stock, select_list_of_ranom_stock
import configurations as config
import os.path
import time
def show_exchange(st, components, exchange):
if os.path.isfile(config.stock_exchanges[exchange].get("data")):
show_random_stocks(st, components, exchange)
else:
show_coming_soon(st, exchange)
def show_random_stocks(st, components, exchange):
if config.show_single_stock:
random_result = select_one_ranom_stock(config.stock_exchanges[exchange]["data"])
st.metric(
label=f'{random_result["name"]}',
value=random_result["symbol"],
delta=config.stock_exchanges[exchange]["display"],
delta_color="off",
)
else:
random_list_result = select_list_of_ranom_stock(
config.stock_exchanges[exchange]["data"]
)
temp = st.empty()
for random_result in random_list_result:
time.sleep(config.sleep_time_for_sample_role)
temp.metric(
label=f'{random_result["name"]}',
value=random_result["symbol"],
delta=config.stock_exchanges[exchange]["display"],
delta_color="off",
)
with st.expander(f"More details about the {random_result['symbol']} stock:"):
try:
for fnc in config.stock_exchanges[exchange]["information_display"]:
fnc(st, components, exchange, symbol=random_result["symbol"])
except Exception as exp:
st.error(
"""
Too many people are using, cannot fetch the results
"""
)
st.info(
f"""
OOPs something isn't right..
Here are more details if you are a nerd:
{exp}
See the source code at:
https://github.com/singhsidhukuldeep/random-stock-picker
"""
)
def show_coming_soon(st, exchange):
with st.expander(f"{config.stock_exchanges[exchange]['display']} coming soon..."):
st.info(
f"""
Want to contribute?
If you want you can add functionality directly to the code!
"""
)
st.success(
f"""
See the source code at:
https://github.com/singhsidhukuldeep/random-stock-picker
"""
)