import streamlit as st
import pandas as pd
from datetime import datetime
import random
# =====================================================================
# 1. PAGE INITIALIZATION & HIGH-FIDELITY RETRO STYLING
# =====================================================================
st.set_page_config(
page_title="Trading Office - Realtime Bot Command Center",
page_icon="☕",
layout="wide",
initial_sidebar_state="expanded"
)
# บังคับโครงสร้างและโทนสีให้ตรงตามรูปภาพหน้าจอของผู้ใช้
st.markdown("""
""", unsafe_allow_html=True)
# =====================================================================
# 2. APP STATE SIMULATION (ระบบจำลองค่าพลังในพอร์ต)
# =====================================================================
if "live_equity" not in st.session_state:
st.session_state.live_equity = 20882.27
if "spread_val" not in st.session_state:
st.session_state.spread_val = 3.502
# สุ่มขยับราคาเล็กน้อยทุกครั้งที่กด Refresh เพื่อให้หน้าจอไม่นิ่งค้าง
st.session_state.live_equity += random.uniform(-5.5, 7.5)
st.session_state.spread_val += random.uniform(-0.02, 0.02)
# =====================================================================
# 3. SIDEBAR IMPLEMENTATION (แถบเมนูควบคุมฝั่งซ้ายแบบในรูปภาพ)
# =====================================================================
with st.sidebar:
st.markdown('
', unsafe_allow_html=True)
st.markdown('', unsafe_allow_html=True)
st.markdown('', unsafe_allow_html=True)
st.markdown("🟢 **Spread Grid**
BRENTOIL / WTI", unsafe_allow_html=True)
st.markdown('', unsafe_allow_html=True)
st.markdown(f"""
""", unsafe_allow_html=True)
st.markdown('', unsafe_allow_html=True)
st.markdown("• 🛠️ **Trader:** `Order path only`
• 🗄️ **Recorder:** `Trade file connected`", unsafe_allow_html=True)
st.markdown('', unsafe_allow_html=True)
st.write("`XAUUSD.iux` | `BRENTOIL` | `WTI`")
# =====================================================================
# 4. TOP NAVIGATION BAR (แถบเมนูและควบคุมส่วนบน)
# =====================================================================
st.markdown("""
Dashboard
AI Agents
Trades
Analytics
Risk
● 2/2 Bots Running
""", unsafe_allow_html=True)
# =====================================================================
# 5. MAIN CAFE CANVAS WORKSPACE (โซนห้องกาแฟเอเจ้นท์สั่งการ)
# =====================================================================
# เริ่มต้นวาดกล่อง Canvas พื้นหลังร้านกาแฟสีอบอุ่นโทนไม้
st.markdown('', unsafe_allow_html=True)
# แปะหน้าต่างและชั้นวางของตกแต่งบรรยากาศตู้เกมส์
st.markdown('
🌳
', unsafe_allow_html=True)
st.markdown('
☕ 🏺 ☕ ☕
', unsafe_allow_html=True)
# วาดโต๊ะและกล่องสถานะของเอเจ้นท์แต่ละตัวนั่งทำงานแยกฝั่งกันแบบในรูปภาพ
st.markdown("""
RUNNING
Agent: Quant_3Zone_v2.6
Mid Spread: 3.485
Current / Target: 82.8% / 93.3%
Trade: WAIT / In Range
MONITOR
Agent: CRO_Firewall_v3.1
Risk Load: 1.15% (Max 2%)
Account Equity: Secure
Last Update: Realtime
🐈
""", unsafe_allow_html=True)
# ปิดกล่อง Cafe Container คุมพื้นที่ทั้งหมด
st.markdown('
', unsafe_allow_html=True)
# =====================================================================
# 6. QUICK CONTROLLER MANUAL (แผงควบคุมระบบแมนนวลด้านล่างสุด)
# =====================================================================
st.write("")
control_col1, control_col2, control_col3 = st.columns([1, 1, 2])
with control_col1:
if st.button("▶ START SYSTEM ALL BOTS"):
st.toast("ส่งวิทยุสั่งการให้เอเจ้นท์ทุกตัวเปิดคอมพิวเตอร์เริ่มทำงานรันไทม์!")
with control_col2:
if st.button("🛑 EMERGENCY SHUTDOWN"):
st.toast(" Risk Firewall ทำการตัดกระแสไฟและระเบิดสัญญาทั้งหมดเพื่อรักษาทุนหลัก!")
with control_col3:
st.caption("📟 *ระบบแดชบอร์ดดึงความละเอียดพิกเซลอัตโนมัติจากไฟล์ประมวลผลบอทหลัก v2.6 และ v3.1 รองรับการโฮสต์บน Hugging Face Spaces 24 ชม.*")