File size: 4,484 Bytes
07134fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336cdbe
07134fb
 
 
 
336cdbe
07134fb
 
 
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import json
from datetime import datetime, timedelta
from pathlib import Path

BASE_DIR = Path("/home/ramram/Desktop/SELF_LEARNING/Medical RAG/documents/Signal/Forex_MACD_Strategy")
SIGNALS_FILE = BASE_DIR / "forex_macd_signals.json"
HISTORY_FILE = BASE_DIR / "signal_history.json"

def create_mock_instrument(name, symbol, category, flag, status, signal_type=None):
    now = datetime.now()
    ltp = 1.0850 if "EUR" in symbol else (2350.0 if "GC" in symbol else (65000.0 if "BTC" in symbol else 24500.0))
    # Vary LTP slightly from entry price if it's an active signal
    entry_price = ltp
    if signal_type:
        if signal_type == "BUY":
            ltp = entry_price * 1.002 # LTP is higher for Buy
        else:
            ltp = entry_price * 0.998 # LTP is lower for Sell

    inst = {
        "instrument": name,
        "symbol": symbol,
        "flag": flag,
        "ltp": ltp,
        "category": category,
        "daily": {"macd_line": 0.001, "bias": "BULLISH", "label": "Daily"},
        "h4": {"histogram": 0.0005, "bias": "BULLISH", "label": "4H MOM"},
        "h1": {
            "histogram": 0.0002, 
            "status": "BUY_CROSS" if signal_type == "BUY" else "SELL_CROSS" if signal_type == "SELL" else "NEUTRAL",
            "close": ltp,
            "label": "15m Entry" if category == "Intraday IndianMarket" else "1H Entry",
            "ema_200": ltp * 0.99,
            "rsi": 65.0
        },
        "overall_status": status,
        "timestamp": now.isoformat()
    }
    
    if signal_type:
        inst["signal"] = {
            "type": signal_type,
            "entry_price": entry_price,
            "sl": entry_price * (0.99 if signal_type == "BUY" else 1.01),
            "current_sl": entry_price * (0.99 if signal_type == "BUY" else 1.01),
            "tp1": entry_price * (1.01 if signal_type == "BUY" else 0.99),
            "tp2": entry_price * (1.02 if signal_type == "BUY" else 0.98),
            "tp3": entry_price * (1.03 if signal_type == "BUY" else 0.97),
            "tp3": ltp * (1.03 if signal_type == "BUY" else 0.97),
            "tp_hits": [True, False, False] if name == "EUR/USD" else [False, False, False],
            "sl_hit": True if name == "GBP/USD" else False,
            "time": now.isoformat(),
            "category": category
        }
    else:
        inst["signal"] = None
        
    return inst

def inject_all_mock_data():
    # 1. Signals Data
    data = {
        "last_updated": datetime.now().isoformat(),
        "data": [
            # Active Forex
            create_mock_instrument("EUR/USD", "EURUSD=X", "Forex", "๐Ÿ‡ช๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ", "ACTIVE_BUY", "BUY"),
            create_mock_instrument("GBP/USD", "GBPUSD=X", "Forex", "๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡บ๐Ÿ‡ธ", "ACTIVE_SELL", "SELL"),
            # Pending Forex
            create_mock_instrument("USD/JPY", "USDJPY=X", "Forex", "๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡ฏ๐Ÿ‡ต", "LOOKING_FOR_BUY"),
            create_mock_instrument("AUD/USD", "AUDUSD=X", "Forex", "๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ", "WAITING"),
            
            # Active Metals/Energy
            create_mock_instrument("Gold", "GC=F", "Metals/Energy", "๐Ÿฅ‡", "ACTIVE_SELL", "SELL"),
            create_mock_instrument("US Oil (WTI)", "CL=F", "Metals/Energy", "๐Ÿ›ข๏ธ", "ACTIVE_BUY", "BUY"),
            # Pending Metals/Energy
            create_mock_instrument("Silver", "SI=F", "Metals/Energy", "๐Ÿฅˆ", "CONFLICT (Trend/MOM/Filter Mismatch)"),
            
            # Active Cryptos
            create_mock_instrument("Bitcoin", "BTC-USD", "Cryptos", "โ‚ฟ", "ACTIVE_BUY", "BUY"),
            # Pending Cryptos
            create_mock_instrument("Ethereum", "ETH-USD", "Cryptos", "ฮž", "LOOKING_FOR_SELL"),
            
            # Active Indian Market
            create_mock_instrument("Nifty 50", "^NSEI", "Intraday IndianMarket", "๐Ÿ‡ฎ๐Ÿ‡ณ", "ACTIVE_BUY", "BUY"),
            create_mock_instrument("Bank Nifty", "^NSEBANK", "Intraday IndianMarket", "๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿฆ", "ACTIVE_SELL", "SELL"),
            # Pending Indian Market
            create_mock_instrument("Sensex", "^BSESN", "Intraday IndianMarket", "๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ“ˆ", "WAITING")
        ]
    }
    
    with open(SIGNALS_FILE, 'w') as f:
        json.dump(data, f, indent=2)

    # 2. History Data (Cleared as requested)
    history = []
    with open(HISTORY_FILE, 'w') as f:
        json.dump(history, f, indent=2)
        
    print("Successfully injected mock data into all tabs and cleared history.")

if __name__ == "__main__":
    inject_all_mock_data()