Devendra21 commited on
Commit
4d6d28b
·
verified ·
1 Parent(s): 31d1b0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -48
app.py CHANGED
@@ -10,64 +10,79 @@ sys.path.append(os.path.join(os.path.dirname(__file__), "utils"))
10
  from model_inference import generate_forex_signals
11
  from config import RISK_LEVELS # Assuming config.py defines risk levels if needed
12
 
 
 
 
13
  # Streamlit page configuration
14
  st.set_page_config(page_title="AI Forex Bot", page_icon=":guardsman:", layout="wide")
15
 
16
- # Title of the application
17
- st.title("AI Forex Trading Bot")
18
-
19
- # Description
20
- st.markdown("""
21
- This tool is for informational purposes only and does not provide financial advice. Forex trading involves significant risk, including potential loss of capital.
22
- Users should exercise caution, conduct their own research, and consult a licensed financial advisor. Use at your own risk..
23
- """)
24
 
25
- # Automatically fetch the user's timezone using IPInfo API
26
- access_token = "37b621e95809fa" # Replace with your actual IPInfo API token
27
- try:
28
- response = requests.get(f"https://ipinfo.io/json?token={access_token}")
29
- response.raise_for_status()
30
- user_timezone = response.json().get("timezone", "UTC")
31
- except requests.exceptions.RequestException:
32
- user_timezone = "UTC" # Default to UTC if the API call fails
 
 
 
 
33
 
34
- # Sidebar for user inputs
35
- st.sidebar.header("User Input")
 
 
 
36
 
37
- # Get user trading capital
38
- trading_capital = st.sidebar.number_input("Enter Trading Capital (USD)", min_value=1, max_value=10000, value=1000)
 
 
 
 
 
 
39
 
40
- # Get user market risk level
41
- market_risk = st.sidebar.selectbox("Select Market Risk Level", options=["Low", "Medium", "High"])
42
 
43
- # Display the detected timezone
44
- st.sidebar.write(f"**Detected Timezone**: {user_timezone}")
45
 
46
- # When the user presses the button, generate trading signals
47
- if st.sidebar.button("Get Trading Signals"):
48
- try:
49
- # Generate signals
50
- signals = generate_forex_signals(trading_capital, market_risk, user_timezone)
51
 
52
- # Display the best signal
53
- best_signal = signals["best_signal"]
54
- st.subheader("Best Recommended Forex Trade")
55
- st.write(f"**Currency Pair**: {best_signal['currency_pair']}")
56
- st.write(f"**Entry Time**: {best_signal['entry_time']}")
57
- st.write(f"**Exit Time**: {best_signal['exit_time']}")
58
- st.write(f"**ROI**: {best_signal['roi']}%")
59
- st.write(f"**Signal Strength**: {best_signal['signal_strength']}")
60
 
61
- # Display all signals
62
- st.subheader("All Generated Signals")
63
- for signal in signals["all_signals"]:
64
- st.write(f"**Currency Pair**: {signal['currency_pair']}")
65
- st.write(f"**Entry Time**: {signal['entry_time']}")
66
- st.write(f"**Exit Time**: {signal['exit_time']}")
67
- st.write(f"**ROI**: {signal['roi']}%")
68
- st.write(f"**Signal Strength**: {signal['signal_strength']}")
69
- st.markdown("---")
70
- except Exception as e:
71
- st.error(f"Error: {str(e)}")
72
 
 
 
 
 
 
 
 
 
73
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  from model_inference import generate_forex_signals
11
  from config import RISK_LEVELS # Assuming config.py defines risk levels if needed
12
 
13
+ # List of allowed usernames
14
+ ALLOWED_USERNAMES = ["ddilloud", "ved", "aditya", "karlmax", "bento"]
15
+
16
  # Streamlit page configuration
17
  st.set_page_config(page_title="AI Forex Bot", page_icon=":guardsman:", layout="wide")
18
 
19
+ # Authentication logic
20
+ if "authenticated" not in st.session_state:
21
+ st.session_state.authenticated = False
 
 
 
 
 
22
 
23
+ if not st.session_state.authenticated:
24
+ st.title("Authentication Required")
25
+ username = st.text_input("Enter your username", "")
26
+ if st.button("Login"):
27
+ if username in ALLOWED_USERNAMES:
28
+ st.session_state.authenticated = True
29
+ st.success("Login successful! Welcome!")
30
+ else:
31
+ st.error("Invalid username. Access denied.")
32
+ else:
33
+ # Title of the application
34
+ st.title("AI Forex Trading Bot")
35
 
36
+ # Description
37
+ st.markdown("""
38
+ This tool is for informational purposes only and does not provide financial advice. Forex trading involves significant risk, including potential loss of capital.
39
+ Users should exercise caution, conduct their own research, and consult a licensed financial advisor. Use at your own risk.
40
+ """)
41
 
42
+ # Automatically fetch the user's timezone using IPInfo API
43
+ access_token = "37b621e95809fa" # Replace with your actual IPInfo API token
44
+ try:
45
+ response = requests.get(f"https://ipinfo.io/json?token={access_token}")
46
+ response.raise_for_status()
47
+ user_timezone = response.json().get("timezone", "UTC")
48
+ except requests.exceptions.RequestException:
49
+ user_timezone = "UTC" # Default to UTC if the API call fails
50
 
51
+ # Sidebar for user inputs
52
+ st.sidebar.header("User Input")
53
 
54
+ # Get user trading capital
55
+ trading_capital = st.sidebar.number_input("Enter Trading Capital (USD)", min_value=1, max_value=10000, value=1000)
56
 
57
+ # Get user market risk level
58
+ market_risk = st.sidebar.selectbox("Select Market Risk Level", options=["Low", "Medium", "High"])
 
 
 
59
 
60
+ # Display the detected timezone
61
+ st.sidebar.write(f"**Detected Timezone**: {user_timezone}")
 
 
 
 
 
 
62
 
63
+ # When the user presses the button, generate trading signals
64
+ if st.sidebar.button("Get Trading Signals"):
65
+ try:
66
+ # Generate signals
67
+ signals = generate_forex_signals(trading_capital, market_risk, user_timezone)
 
 
 
 
 
 
68
 
69
+ # Display the best signal
70
+ best_signal = signals["best_signal"]
71
+ st.subheader("Best Recommended Forex Trade")
72
+ st.write(f"**Currency Pair**: {best_signal['currency_pair']}")
73
+ st.write(f"**Entry Time**: {best_signal['entry_time']}")
74
+ st.write(f"**Exit Time**: {best_signal['exit_time']}")
75
+ st.write(f"**ROI**: {best_signal['roi']}%")
76
+ st.write(f"**Signal Strength**: {best_signal['signal_strength']}")
77
 
78
+ # Display all signals
79
+ st.subheader("All Generated Signals")
80
+ for signal in signals["all_signals"]:
81
+ st.write(f"**Currency Pair**: {signal['currency_pair']}")
82
+ st.write(f"**Entry Time**: {signal['entry_time']}")
83
+ st.write(f"**Exit Time**: {signal['exit_time']}")
84
+ st.write(f"**ROI**: {signal['roi']}%")
85
+ st.write(f"**Signal Strength**: {signal['signal_strength']}")
86
+ st.markdown("---")
87
+ except Exception as e:
88
+ st.error(f"Error: {str(e)}")