058ef57d8f
- Restore XAU/USD (Pro plan), drop USD/CAD, raise rate limit to 55/min - Reduce signal engine to 4 uncorrelated pillars (EMA, RSI, BB, Candlestick) with regime-adaptive weights (trending boosts EMA, ranging boosts RSI+BB) - Add structure-based S/R (swing highs/lows) for trade setup targeting - Fix confidence death spiral: all adjustments now additive, not multiplicative - Dynamic R:R trade setup: SL behind swing level, TP at next structure level, reject if R:R < 1.5 - Fix news engine for all 4 pairs (was hardcoded to USDJPY) - Add WebSocket monitor: streams live ticks, triggers M15 scan on level breach with 5-min cooldown per pair — catches breakouts between candle boundaries - Add correlation filter (EUR/USD+GBP/USD, XAU/USD+USD/JPY exposure warnings)
56 lines
1.6 KiB
Python
Executable File
56 lines
1.6 KiB
Python
Executable File
"""Live tick stream from Twelve Data WebSocket API."""
|
|
|
|
import json
|
|
import asyncio
|
|
import websockets
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
API_KEY = "f563b22ffdfd4924955decbe1a8c8701"
|
|
WS_URL = f"wss://ws.twelvedata.com/v1/quotes/price?apikey={API_KEY}"
|
|
SYMBOLS = ["EUR/USD", "GBP/USD", "USD/JPY", "XAU/USD"]
|
|
|
|
|
|
async def stream_ticks():
|
|
async with websockets.connect(WS_URL) as ws:
|
|
subscribe = {
|
|
"action": "subscribe",
|
|
"params": {
|
|
"symbols": ",".join(SYMBOLS),
|
|
},
|
|
}
|
|
await ws.send(json.dumps(subscribe))
|
|
print(f"Subscribed to: {', '.join(SYMBOLS)}")
|
|
print("-" * 60)
|
|
|
|
async for raw in ws:
|
|
msg = json.loads(raw)
|
|
|
|
if msg.get("event") == "subscribe-status":
|
|
print(f"Status: {msg.get('status')} — {msg.get('message', '')}")
|
|
continue
|
|
|
|
if msg.get("event") == "heartbeat":
|
|
continue
|
|
|
|
if msg.get("event") == "price":
|
|
ts = datetime.fromtimestamp(msg["timestamp"], tz=timezone.utc)
|
|
symbol = msg["symbol"]
|
|
price = msg["price"]
|
|
print(f"{ts:%H:%M:%S} | {symbol:<8} | {price}")
|
|
|
|
|
|
async def main():
|
|
print(f"Connecting to Twelve Data WebSocket...")
|
|
print(f"API key: ...{API_KEY[-6:]}")
|
|
try:
|
|
await stream_ticks()
|
|
except KeyboardInterrupt:
|
|
print("\nStopped.")
|
|
except websockets.exceptions.ConnectionClosed as e:
|
|
print(f"\nConnection closed: {e}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|