Spaces:
Sleeping
Sleeping
Update utils/model_inference.py
Browse files- utils/model_inference.py +15 -4
utils/model_inference.py
CHANGED
|
@@ -1,9 +1,20 @@
|
|
| 1 |
import datetime
|
| 2 |
import numpy as np
|
| 3 |
-
from utils import fetch_forex_data
|
|
|
|
| 4 |
|
| 5 |
-
# Function to generate forex signals
|
| 6 |
def generate_forex_signals(trading_capital, market_risk, timezone):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Define the top 10 most popular currency pairs
|
| 8 |
currency_pairs = [
|
| 9 |
"EUR/USD", "GBP/USD", "USD/JPY", "AUD/USD", "USD/CAD",
|
|
@@ -16,14 +27,14 @@ def generate_forex_signals(trading_capital, market_risk, timezone):
|
|
| 16 |
# Fetch historical data for the currency pair
|
| 17 |
data = fetch_forex_data(pair, timeframe="15m")
|
| 18 |
|
| 19 |
-
# Calculate technical indicators
|
| 20 |
indicators = calculate_technical_indicators(data)
|
| 21 |
|
| 22 |
# Generate trade signal
|
| 23 |
entry_time = data.index[-1]
|
| 24 |
exit_time = entry_time + datetime.timedelta(minutes=15)
|
| 25 |
|
| 26 |
-
roi = np.random.uniform(10, 20) # Random ROI between 10% and 20%
|
| 27 |
signal_strength = np.random.uniform(80, 100) # Random signal strength (80%-100%)
|
| 28 |
|
| 29 |
# Calculate Stop-Loss and Take-Profit levels based on risk
|
|
|
|
| 1 |
import datetime
|
| 2 |
import numpy as np
|
| 3 |
+
from utils.fetch_forex_data import fetch_forex_data
|
| 4 |
+
from utils.calculate_technical_indicators import calculate_technical_indicators
|
| 5 |
|
|
|
|
| 6 |
def generate_forex_signals(trading_capital, market_risk, timezone):
|
| 7 |
+
"""
|
| 8 |
+
Generate forex trading signals based on technical indicators.
|
| 9 |
+
|
| 10 |
+
Args:
|
| 11 |
+
trading_capital (float): User's trading capital in USD.
|
| 12 |
+
market_risk (str): Risk level ("Low", "Medium", "High").
|
| 13 |
+
timezone (str): User's timezone (e.g., "UTC").
|
| 14 |
+
|
| 15 |
+
Returns:
|
| 16 |
+
dict: Dictionary containing the best signal and all generated signals.
|
| 17 |
+
"""
|
| 18 |
# Define the top 10 most popular currency pairs
|
| 19 |
currency_pairs = [
|
| 20 |
"EUR/USD", "GBP/USD", "USD/JPY", "AUD/USD", "USD/CAD",
|
|
|
|
| 27 |
# Fetch historical data for the currency pair
|
| 28 |
data = fetch_forex_data(pair, timeframe="15m")
|
| 29 |
|
| 30 |
+
# Calculate technical indicators
|
| 31 |
indicators = calculate_technical_indicators(data)
|
| 32 |
|
| 33 |
# Generate trade signal
|
| 34 |
entry_time = data.index[-1]
|
| 35 |
exit_time = entry_time + datetime.timedelta(minutes=15)
|
| 36 |
|
| 37 |
+
roi = np.random.uniform(10, 20) # Random ROI between 10% and 20%
|
| 38 |
signal_strength = np.random.uniform(80, 100) # Random signal strength (80%-100%)
|
| 39 |
|
| 40 |
# Calculate Stop-Loss and Take-Profit levels based on risk
|