File size: 2,275 Bytes
71336f7
2e3ec69
c6a1f6c
 
71336f7
 
c6a1f6c
 
 
 
 
 
 
 
 
 
 
71336f7
 
 
 
 
 
 
 
475b9ba
71336f7
 
 
c6a1f6c
71336f7
 
 
28a8524
 
 
71336f7
c6a1f6c
71336f7
 
 
 
 
 
 
475b9ba
71336f7
 
 
 
 
 
 
 
475b9ba
71336f7
 
475b9ba
e4cbddb
475b9ba
71336f7
e4cbddb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import datetime
import numpy as np
from utils.fetch_forex_data import fetch_forex_data
from utils.calculate_technical_indicators import calculate_technical_indicators

def generate_forex_signals(trading_capital, market_risk, timezone):
    """
    Generate forex trading signals based on technical indicators.

    Args:
        trading_capital (float): User's trading capital in USD.
        market_risk (str): Risk level ("Low", "Medium", "High").
        timezone (str): User's timezone (e.g., "UTC").

    Returns:
        dict: Dictionary containing the best signal and all generated signals.
    """
    # Define the top 10 most popular currency pairs
    currency_pairs = [
        "EUR/USD", "GBP/USD", "USD/JPY", "AUD/USD", "USD/CAD",
        "USD/CHF", "NZD/USD", "EUR/JPY", "GBP/JPY", "AUD/JPY"
    ]

    all_signals = []

    for pair in currency_pairs:
        # Fetch historical data for the currency pair
        data = fetch_forex_data(pair, timeframe="15m")

        # Calculate technical indicators
        indicators = calculate_technical_indicators(data)

        # Generate trade signal
        current_time = datetime.datetime.now()  # Get current date and time
        entry_time = current_time
        exit_time = current_time + datetime.timedelta(minutes=15)

        roi = np.random.uniform(10, 20)  # Random ROI between 10% and 20%
        signal_strength = np.random.uniform(80, 100)  # Random signal strength (80%-100%)

        # Calculate Stop-Loss and Take-Profit levels based on risk
        stop_loss = trading_capital * 0.01  # 1% of capital
        take_profit = trading_capital * (roi / 100)  # ROI percentage of capital

        signal = {
            "currency_pair": pair,
            "entry_time": entry_time.strftime("%Y-%m-%d %H:%M:%S"),
            "exit_time": exit_time.strftime("%Y-%m-%d %H:%M:%S"),
            "roi": round(roi, 2),
            "signal_strength": round(signal_strength, 2),
            "stop_loss": round(stop_loss, 2),
            "take_profit": round(take_profit, 2),
        }
        all_signals.append(signal)

    # Select the best signal (highest ROI)
    best_signal = max(all_signals, key=lambda x: x["roi"])

    return {
        "best_signal": best_signal,
        "all_signals": all_signals
    }