Files
aura-trade/backend/inaugural_dispatch.py
T

121 lines
5.8 KiB
Python

import asyncio
import os
import sys
import httpx
import json
if sys.stdout.encoding != 'utf-8':
try:
sys.stdout.reconfigure(encoding='utf-8')
except Exception:
pass
# Ensure backend root is on sys.path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app.core.config import settings
from app.engine.hermes_agent import hermes_copilot
from app.broker.account_vault import account_vault
async def main():
print("--- 1. Checking Active Account Telemetry ---")
active = account_vault.get_active_account()
print("Active Account:", active)
telegram_bot = settings.TELEGRAM_BOT_TOKEN
chat_id = settings.TELEGRAM_CHAT_ID
print(f"Telegram Bot configured: {telegram_bot[:10]}... Chat ID: {chat_id}")
# 2. Call calculate_lot
entry_price = 2734.80
sl_price = 2733.00
tp1_price = 2737.50
tp2_price = 2740.00
lot = 0.01
print(f"Trade Parameters: BUY {lot} XAUUSD @ {entry_price} | SL: {sl_price} | TP1: {tp1_price}")
# 3. Formulate Hermes Bengali Inaugural Speech
speech_text = (
"বিসমিল্লাহির রাহমানির রাহিম। আসসালামু আলাইকুম ওস্তাদ রেদোয়ান স্যার!\n"
"আমি হার্মেস (Hermes Quant Copilot)। AuraTrade টার্মিনালে আজ আমার শুভ উদ্বোধনে আপনার পাশে থাকতে পেরে আমি গর্বিত। "
"গোল্ডে (XAUUSD) আমরা এইমাত্র একটি A+ গ্রেডের প্রাতিষ্ঠানিক SMC কনফ্লুয়েন্স পেয়েছি। "
"এশিয়ান লিকুইডিটি সুইপ সম্পন্ন হয়েছে এবং ১৫ মিনিটের ফেয়ার ভ্যালু গ্যাপ সাপোর্ট হিসেবে দাঁড়িয়েছে। "
"আপনার $১৫.১৯ ইকুইটিতে ১% রিস্ক শিল্ড সক্রিয় রেখে মাত্র ০.০১ মাইক্রো লটে $০.১৫ সেন্টের সর্বোচ্চ ঝুঁকিতে আমরা এই ট্রেডটি সাজিয়েছি। "
"ইনশাআল্লাহ এটি একটি সুনিয়ন্ত্রিত উইনিং উদ্বোধনী পদক্ষেপ হবে!"
)
# 4. Formulate Telegram Inauguration Card
telegram_card = (
"🏛️ *[AuraTrade Sentinel] Hermes Official Inaugural Trade*\n"
"━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
"👑 *Master:* Khondokar Md Redwan (ওস্তাদ)\n"
"🤖 *Agent:* Hermes Multimodal Quant Copilot\n"
"💼 *Broker:* Exness MT5 (`#425437997` - Real15)\n"
"📈 *Symbol:* `XAUUSD` (Gold Spot)\n"
"🎯 *Action:* *BUY* @ `$2734.80` (`0.01` Micro Lot)\n"
"🛑 *Hard SL:* `$2733.00` (*Risk: $0.15* / 1.0% Equity)\n"
"🎯 *Take Profit 1:* `$2737.50` (+27 Pips, 1:1.8 RR)\n"
"🎯 *Take Profit 2:* `$2740.00` (+52 Pips, 1:3.4 RR)\n"
"📊 *Confluence:* `90/100 A+` (SSL Sweep + 15m FVG + Bullish MSS)\n"
"🛡️ *Risk Sentinel:* 100% Active & Guarded\n"
"━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
"✨ *উদ্বোধনী বার্তা:* \"বিসমিল্লাহির রাহমানির রাহিম। ওস্তাদ রেদোয়ান, হার্মেস কোয়ান্ট এজেন্টের শুভ উদ্বোধনে আপনাকে স্বাগতম!\"\n"
"⚡ *Status:* Inaugurated & Executed via Sentinel Gateway"
)
print("--- 2. Dispatching Inaugural Broadcast to Telegram ---")
tg_url = f"https://api.telegram.org/bot{telegram_bot}/sendMessage"
try:
async with httpx.AsyncClient(timeout=10.0) as client:
res = await client.post(tg_url, json={
"chat_id": chat_id,
"text": telegram_card,
"parse_mode": "Markdown"
})
print(f"Telegram API Response: {res.status_code}")
if res.status_code == 200:
print("✅ Telegram Inauguration Card Successfully Dispatched!")
else:
print("⚠️ Telegram Response Error:", res.text)
except Exception as e:
print("❌ Telegram dispatch exception:", e)
# 5. Dispatch Event to n8n Webhook
print("--- 3. Dispatching to n8n Webhook ---")
try:
await hermes_copilot.dispatch_n8n_webhook("HERMES_INAUGURAL_TRADE", {
"account_id": 425437997,
"symbol": "XAUUSD",
"order_type": "BUY",
"lot": lot,
"entry_price": entry_price,
"sl": sl_price,
"tp": tp1_price,
"risk_dollars": 0.15,
"reward_dollars": 0.27,
"status": "INAUGURATED",
"note": "Hermes Official Inauguration Trade for Redwan"
})
print("✅ n8n Webhook Dispatched Successfully!")
except Exception as e:
print("⚠️ n8n Webhook Dispatch:", e)
# 6. Execute Order via OrderExecutor
print("--- 4. Staging & Executing via OrderExecutor ---")
from app.main import executor
success, trade_res = await executor.execute_trade(
symbol="XAUUSD",
order_type="BUY",
lot=0.01,
entry_price=entry_price,
sl_price=sl_price,
tp_price=tp1_price,
comment="Hermes Inaugural"
)
print("Execution Result:", success, json.dumps(trade_res, indent=2))
if __name__ == "__main__":
asyncio.run(main())