feat: Smart AI Trading Bot for XAUUSD with ML and SMC

- XGBoost ML model with 37 features for market direction prediction
- Smart Money Concepts (SMC): Order Blocks, FVG, BOS, CHoCH
- HMM market regime detection (trending/ranging/volatile)
- ATR-based stop loss with 1.5 ATR minimum distance
- Broker-level SL protection with fallback
- Time-based exit (max 6 hours per trade)
- Session-aware trading optimized for London/NY overlap
- Auto-retraining based on market conditions
- Telegram notifications and web dashboard
- Backtest results: 63.9% win rate, 2.64 profit factor, 4.83 Sharpe

Backtest period: Jan 2025 - Feb 2026, 654 trades, $4,189 net P/L

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
GifariKemal
2026-02-06 09:01:35 +07:00
co-authored by Claude Opus 4.5
commit 7af9183af3
121 changed files with 43387 additions and 0 deletions
@@ -0,0 +1,50 @@
"use client";
import { useState, useEffect, useCallback } from 'react';
import type { TradingStatus } from '@/types/trading';
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
export function useTradingData() {
const [data, setData] = useState<TradingStatus | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [lastFetch, setLastFetch] = useState<Date | null>(null);
const fetchData = useCallback(async () => {
try {
const res = await fetch(`${API_URL}/api/status`, {
cache: 'no-store',
});
if (!res.ok) {
throw new Error(`HTTP error: ${res.status}`);
}
const json = await res.json();
setData(json);
setError(null);
setLastFetch(new Date());
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to fetch');
} finally {
setLoading(false);
}
}, []);
useEffect(() => {
// Initial fetch
fetchData();
// Poll every second
const interval = setInterval(fetchData, 1000);
return () => clearInterval(interval);
}, [fetchData]);
const dataAge = lastFetch
? (Date.now() - lastFetch.getTime()) / 1000
: 999;
return { data, loading, error, dataAge, refetch: fetchData };
}