Devendra21 commited on
Commit
79384a6
·
verified ·
1 Parent(s): 2674d8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -37
app.py CHANGED
@@ -1,42 +1,56 @@
1
  import streamlit as st
2
- import datetime
 
 
 
 
 
 
3
  from model_inference import generate_forex_signals
4
- from config import RISK_LEVELS
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- # Streamlit app setup
7
- st.title("AI Forex Bot")
8
  st.sidebar.header("User Input")
9
 
10
- # Input: Trading Capital
11
- trading_capital = st.sidebar.number_input(
12
- "Trading Capital (USD)",
13
- min_value=1.0,
14
- max_value=10000.0,
15
- step=1.0
16
- )
17
-
18
- # Input: Risk Level
19
- risk_level = st.sidebar.selectbox("Market Risk Level", options=list(RISK_LEVELS.keys()))
20
-
21
- # Input: User's current time
22
- user_timezone_time = st.sidebar.time_input(
23
- "Enter Current Time (Your Time Zone)",
24
- value=datetime.datetime.now().time()
25
- )
26
-
27
- # Generate signals button
28
- if st.sidebar.button("Generate Signals"):
29
- # Call backend logic
30
- forex_signals = generate_forex_signals(trading_capital, risk_level)
31
-
32
- # Adjust entry and exit times based on user's time
33
- entry_time = datetime.datetime.combine(datetime.date.today(), user_timezone_time)
34
- exit_time = entry_time + datetime.timedelta(hours=2)
35
-
36
- # Display results
37
- st.write("### Results")
38
- st.write(f"**Profitable Currency Pair**: {forex_signals['currency_pair']}")
39
- st.write(f"**Entry Time**: {entry_time.strftime('%Y-%m-%d %H:%M:%S')}")
40
- st.write(f"**Exit Time**: {exit_time.strftime('%Y-%m-%d %H:%M:%S')}")
41
- st.write(f"**ROI**: {forex_signals['roi']}%")
42
- st.write(f"**Signal Strength**: {forex_signals['signal_strength']}")
 
1
  import streamlit as st
2
+ import os
3
+ import sys
4
+
5
+ # Add the 'utils' directory to sys.path so Python can find modules within it
6
+ sys.path.append(os.path.join(os.path.dirname(__file__), "utils"))
7
+
8
+ # Importing the necessary function from model_inference.py
9
  from model_inference import generate_forex_signals
10
+ from config import RISK_LEVELS # Assuming config.py is in the root directory
11
+
12
+ # Streamlit page configuration
13
+ st.set_page_config(page_title="AI Forex Bot", page_icon=":guardsman:", layout="wide")
14
+
15
+ # Title of the application
16
+ st.title("AI Forex Trading Bot")
17
+
18
+ # Description of how the bot works
19
+ st.markdown("""
20
+ This AI-powered Forex Bot provides real-time trading signals using a combination of historical data, sentiment analysis, and macroeconomic factors.
21
+ You can enter your trading capital and select a risk level to get personalized trading recommendations.
22
+ """)
23
 
24
+ # Sidebar for user inputs
 
25
  st.sidebar.header("User Input")
26
 
27
+ # Get user trading capital (1 USD to 10,000 USD)
28
+ trading_capital = st.sidebar.number_input("Enter Trading Capital (USD)", min_value=1, max_value=10000, value=1000)
29
+
30
+ # Get user market risk level (Low, Medium, High)
31
+ market_risk = st.sidebar.selectbox("Select Market Risk Level", options=["Low", "Medium", "High"])
32
+
33
+ # Get user's preferred timezone (this can be used to adjust entry/exit time)
34
+ user_timezone = st.sidebar.text_input("Enter Your Timezone (e.g., UTC, EST, PST)", "UTC")
35
+
36
+ # Display the inputs
37
+ st.write(f"**Trading Capital**: ${trading_capital}")
38
+ st.write(f"**Market Risk Level**: {market_risk}")
39
+ st.write(f"**Timezone**: {user_timezone}")
40
+
41
+ # When user presses the "Get Trading Signals" button, run the model inference
42
+ if st.sidebar.button("Get Trading Signals"):
43
+ # Call the function to generate forex signals from model_inference.py
44
+ try:
45
+ signals = generate_forex_signals(trading_capital, market_risk, user_timezone)
46
+
47
+ # Display the results in the main area
48
+ st.subheader("Recommended Forex Trade")
49
+ st.write(f"**Currency Pair**: {signals['currency_pair']}")
50
+ st.write(f"**Entry Time**: {signals['entry_time']}")
51
+ st.write(f"**Exit Time**: {signals['exit_time']}")
52
+ st.write(f"**ROI**: {signals['roi']}%")
53
+ st.write(f"**Signal Strength**: {signals['signal_strength']}")
54
+
55
+ except Exception as e:
56
+ st.error(f"Error: {str(e)}")