Devendra21 commited on
Commit
f0e19c3
·
verified ·
1 Parent(s): 6b5569a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -1,6 +1,7 @@
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"))
@@ -30,8 +31,22 @@ trading_capital = st.sidebar.number_input("Enter Trading Capital (USD)", min_val
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}")
@@ -42,7 +57,7 @@ st.write(f"**Timezone**: {user_timezone}")
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")
@@ -54,3 +69,4 @@ if st.sidebar.button("Get Trading Signals"):
54
 
55
  except Exception as e:
56
  st.error(f"Error: {str(e)}")
 
 
1
  import streamlit as st
2
  import os
3
  import sys
4
+ import requests
5
 
6
  # Add the 'utils' directory to sys.path so Python can find modules within it
7
  sys.path.append(os.path.join(os.path.dirname(__file__), "utils"))
 
31
  # Get user market risk level (Low, Medium, High)
32
  market_risk = st.sidebar.selectbox("Select Market Risk Level", options=["Low", "Medium", "High"])
33
 
34
+ # Function to get user's timezone based on their IP address
35
+ def get_user_timezone():
36
+ try:
37
+ # Get the public IP address of the user
38
+ response = requests.get(f'https://ipinfo.io?token=37b621e95809fa')
39
+ data = response.json()
40
+
41
+ # Extract the timezone information from the response
42
+ user_timezone = data['timezone']
43
+ return user_timezone
44
+ except Exception as e:
45
+ print(f"Error fetching timezone: {e}")
46
+ return 'UTC' # Fallback to UTC if there's an error
47
+
48
+ # Get user's timezone automatically using IP address
49
+ user_timezone = get_user_timezone()
50
 
51
  # Display the inputs
52
  st.write(f"**Trading Capital**: ${trading_capital}")
 
57
  if st.sidebar.button("Get Trading Signals"):
58
  # Call the function to generate forex signals from model_inference.py
59
  try:
60
+ signals = generate_forex_signals(trading_capital, market_risk)
61
 
62
  # Display the results in the main area
63
  st.subheader("Recommended Forex Trade")
 
69
 
70
  except Exception as e:
71
  st.error(f"Error: {str(e)}")
72
+