Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
180 lines (137 loc) · 5.74 KB
/
Copy pathapp.py
File metadata and controls
180 lines (137 loc) · 5.74 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
"""
Front end of the application
Date : 2023-07-26
Author: Zetra
"""
import base64
import streamlit as st
import streamlit.components.v1 as components
import time
from pathlib import Path
from streamlit_option_menu import option_menu
st.set_page_config(page_title="Zetralerts", page_icon="frontend/static/favicon.ico", layout="wide")
if "visibility" not in st.session_state:
st.session_state.visibility = "visible"
st.session_state.disabled = False
# Add css
with open( "frontend/static/css/style.css" ) as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
# Get images
def img_to_bytes(img_path: str) -> str:
"""
Convert image to bytes
:params img_path is path to the image
:type :str
:return: (str)
"""
img_bytes = Path(img_path).read_bytes()
encoded = base64.b64encode(img_bytes).decode()
return encoded
def img_to_html(img_path: str) -> str:
"""
Take image path and create an image html tag
:params img_path is path to the image
:type :str
:return: (str)
"""
img_html = "<img src='data:image/png;base64,{}' style='height:70%!important ;width:100%; background-color:#D3DCD9'>".format(
img_to_bytes(img_path)
)
return img_html
# Utility functions
def display_card(img_src: str, title:str, desc: str) -> str:
"""
Display the html card
:params img_src is the image source
:type :str
:params title is the card title
:type :str
:params desc is the body description
:type :str
:return: (str)
"""
image = img_to_html(img_src)
card = f"""<div class='card'>
{image}
<div class='container'>
<h4>
<b>{title}</b>
</h4>
<p>{desc}</p>
<button class='activate'> Activate </button>
</div>
</div>"""
return card
selected = option_menu(
menu_title=None,
options=["Home", "Register", "Alerts", "Settings","Contact"],
orientation="horizontal",
icons=['house', 'list-task', "alarm", 'gear', "envelope"],
styles={
"container": {"padding": "0!important", "background-color": "#F4F4F4"},
"icon": {"color": "#F4F4F4", "font-size": "25px"},
"nav-link": {"font-size": "25px", "text-align": "left", "margin":"0px", "--hover-color": "#eee"},
"nav-link-selected": {"background-color": "#47595D"},
}
)
if selected == "Home":
st.title("Get alerts when it matters.")
st.write("Send notifications to your Telegram bot when high probability setups are in play.")
st.write("##")
# -- First row
container = st.container()
col1, col2, col3, col4 = container.columns(4)
col1.markdown(display_card('frontend/static/images/triple-tops.png', 'Triple Tops', 'This is a chart pattern'), unsafe_allow_html=True)
col2.markdown(display_card('frontend/static/images/inv-hs.png', 'Inverse Head and Shoulders', 'This is a chart pattern'), unsafe_allow_html=True)
col3.markdown(display_card('frontend/static/images/hs.png', 'Head and Shoulders', 'This is a chart pattern'), unsafe_allow_html=True)
col4.markdown(display_card('frontend/static/images/triangle.png', 'Triangle', 'This is a chart pattern'), unsafe_allow_html=True)
if selected == "Register":
with st.form("register_form"):
st.title("Register Your Telegram Bot")
bot_name = st.text_input("Bot Name", "")
token = st.text_input("Bot Token", "")
submit = st.form_submit_button("Test")
if submit:
if not bot_name or not token:
st.error("Fill in the necessary information")
else:
with st.spinner('Wait for it...'):
time.sleep(5)
st.success('Done!')
if selected == "Alerts":
st.write("Alerts")
if selected == "Settings":
with st.form("settings_form"):
st.title("Settings")
alert_interval = st.number_input("Alert Interval")
trigger_interval = st.number_input("Trigger Interval")
currency_pair = st.selectbox(
"Select currency pair",
("EUR/USD", "USD/CAD", "GBP/USD"),
label_visibility=st.session_state.visibility,
disabled=st.session_state.disabled,
)
timeframe = st.selectbox(
"Select trading timeframe",
("15min", "30min", "1H", "4H", "1D"),
label_visibility=st.session_state.visibility,
disabled=st.session_state.disabled,
)
submit = st.form_submit_button("Save")
if submit:
if not alert_interval or not trigger_interval or not currency_pair or not timeframe:
st.error("Fill in the necessary information")
else:
with st.spinner('Wait for it...'):
time.sleep(5)
st.success('Done!')
if selected == "Contact":
st.title("How to reach us.")
st.write("##")
container = st.container()
col1, col2, col3, col4, col5 = container.columns(5)
col1.markdown("<a href='https://www.youtube.com/channel/UC87AaqcveNqlkodJrr5zUsw' target='_blank'>Youtube</a>", unsafe_allow_html=True)
col2.markdown("<a href='https://github.com/zeta-zetra/code' target='_blank'>Github</a>", unsafe_allow_html=True)
col3.markdown("<a href='https://www.instagram.com/zetratrading/' target='_blank'>Instagram</a>", unsafe_allow_html=True)
col4.markdown("<a href='https://www.facebook.com/people/Zetra-Trading/100090523216602/' target='_blank'>Facebook</a>", unsafe_allow_html=True)
col5.markdown("<a href='https://zeta-zetra.github.io/docs-forex-strategies-python/' target='_blank'>Online Book</a>", unsafe_allow_html=True)