FT1 / utils /model_inference.py
Devendra21's picture
Update utils/model_inference.py
475b9ba verified
raw
history blame
1.73 kB
import numpy as np
from datetime import datetime, timedelta
import pytz
# Function to generate signals for multiple currency pairs
def generate_forex_signals(trading_capital, market_risk, user_timezone):
# Ensure the user timezone is valid
try:
user_tz = pytz.timezone(user_timezone)
except pytz.UnknownTimeZoneError:
raise ValueError("Invalid timezone entered. Please check the format.")
# Define market risk levels and their corresponding risk percentages
risk_level = {'Low': 0.01, 'Medium': 0.03, 'High': 0.05}
if market_risk not in risk_level:
raise ValueError("Invalid risk level. Choose from Low, Medium, or High.")
risk_percentage = risk_level[market_risk]
# Currency pairs to evaluate
currency_pairs = ["EUR/USD", "GBP/USD", "USD/JPY"]
# Generate dummy signals for each currency pair (replace this with your model's predictions)
signals = []
for pair in currency_pairs:
entry_time = datetime.now(user_tz).strftime("%Y-%m-%d %I:%M:%S %p")
exit_time = (datetime.now(user_tz) + timedelta(hours=2)).strftime("%Y-%m-%d %I:%M:%S %p")
roi = np.random.uniform(5, 20) # Random ROI between 5% and 20%
signal_strength = np.random.uniform(0.7, 1.0) # Random signal strength
signals.append({
"currency_pair": pair,
"entry_time": entry_time,
"exit_time": exit_time,
"roi": roi,
"signal_strength": signal_strength
})
# Find the signal with the highest ROI
best_signal = max(signals, key=lambda x: x["roi"])
# Return the best signal and all signals
return {
"best_signal": best_signal,
"all_signals": signals
}