mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-28 22:42:52 +08:00
feat: cream terminal redesign, English-only UI, autopilot launch fixes
- Redesign dashboard into a cream-paper + vermilion IBM Plex Mono terminal (live L2 order book, cost/liq map, WS K-line, signal matrix, orchestration topology, risk radar, execution log, current positions, equity curve) - Convert all user-facing UI and backend strings/prompts from Chinese to English (multi-language retained, default English) - Add /api/statistics/full endpoint + full-stats frontend wiring - Fix Autopilot launch: reuse the existing trader instead of creating duplicates (eliminates repeat ~35s create cost and stale-trader 404s); launch sends 5m scan interval - Fix unreadable toasts: cream theme with high-contrast text + per-type accent - Silence background dashboard polls (getTraderConfig) to stop error-toast spam
This commit is contained in:
@@ -19,122 +19,122 @@ export const METRIC_DEFINITIONS: Record<string, MetricDefinition> = {
|
||||
total_return: {
|
||||
key: 'total_return',
|
||||
nameEn: 'Total Return',
|
||||
nameZh: '总收益率',
|
||||
nameZh: 'Total Return',
|
||||
formula: 'R_{total} = \\frac{V_{end} - V_{start}}{V_{start}} \\times 100\\%',
|
||||
descriptionEn: 'Measures overall portfolio performance from start to end',
|
||||
descriptionZh: '衡量投资组合从开始到结束的整体收益表现',
|
||||
descriptionZh: 'Measures overall portfolio performance from start to end',
|
||||
},
|
||||
annualized_return: {
|
||||
key: 'annualized_return',
|
||||
nameEn: 'Annualized Return',
|
||||
nameZh: '年化收益率',
|
||||
nameZh: 'Annualized Return',
|
||||
formula: 'R_{ann} = \\left(1 + R_{total}\\right)^{\\frac{252}{n}} - 1',
|
||||
descriptionEn: 'Standardized yearly return rate (252 trading days)',
|
||||
descriptionZh: '标准化年度收益率(按252个交易日计算)',
|
||||
descriptionZh: 'Standardized yearly return rate (252 trading days)',
|
||||
},
|
||||
max_drawdown: {
|
||||
key: 'max_drawdown',
|
||||
nameEn: 'Maximum Drawdown',
|
||||
nameZh: '最大回撤',
|
||||
nameZh: 'Maximum Drawdown',
|
||||
formula: 'MDD = \\max_{t} \\left( \\frac{Peak_t - Trough_t}{Peak_t} \\right)',
|
||||
descriptionEn: 'Largest peak-to-trough decline during the period',
|
||||
descriptionZh: '期间内从峰值到谷底的最大跌幅',
|
||||
descriptionZh: 'Largest peak-to-trough decline during the period',
|
||||
},
|
||||
sharpe_ratio: {
|
||||
key: 'sharpe_ratio',
|
||||
nameEn: 'Sharpe Ratio',
|
||||
nameZh: '夏普比率',
|
||||
nameZh: 'Sharpe Ratio',
|
||||
formula: 'SR = \\frac{\\bar{r} - r_f}{\\sigma}',
|
||||
descriptionEn: 'Risk-adjusted return per unit of volatility (r̄=avg return, rf=risk-free rate, σ=std dev)',
|
||||
descriptionZh: '单位波动风险下的超额收益(r̄=平均收益,rf=无风险利率,σ=标准差)',
|
||||
descriptionZh: 'Risk-adjusted return per unit of volatility (r̄=avg return, rf=risk-free rate, σ=std dev)',
|
||||
},
|
||||
sortino_ratio: {
|
||||
key: 'sortino_ratio',
|
||||
nameEn: 'Sortino Ratio',
|
||||
nameZh: '索提诺比率',
|
||||
nameZh: 'Sortino Ratio',
|
||||
formula: 'Sortino = \\frac{\\bar{r} - r_f}{\\sigma_d}',
|
||||
descriptionEn: 'Return per unit of downside risk (σd=downside deviation)',
|
||||
descriptionZh: '单位下行风险的收益(σd=下行标准差)',
|
||||
descriptionZh: 'Return per unit of downside risk (σd=downside deviation)',
|
||||
},
|
||||
calmar_ratio: {
|
||||
key: 'calmar_ratio',
|
||||
nameEn: 'Calmar Ratio',
|
||||
nameZh: '卡玛比率',
|
||||
nameZh: 'Calmar Ratio',
|
||||
formula: 'Calmar = \\frac{R_{ann}}{|MDD|}',
|
||||
descriptionEn: 'Annualized return divided by maximum drawdown',
|
||||
descriptionZh: '年化收益率与最大回撤的比值',
|
||||
descriptionZh: 'Annualized return divided by maximum drawdown',
|
||||
},
|
||||
win_rate: {
|
||||
key: 'win_rate',
|
||||
nameEn: 'Win Rate',
|
||||
nameZh: '胜率',
|
||||
nameZh: 'Win Rate',
|
||||
formula: 'WinRate = \\frac{N_{win}}{N_{total}} \\times 100\\%',
|
||||
descriptionEn: 'Percentage of profitable trades',
|
||||
descriptionZh: '盈利交易占总交易数的百分比',
|
||||
descriptionZh: 'Percentage of profitable trades',
|
||||
},
|
||||
profit_factor: {
|
||||
key: 'profit_factor',
|
||||
nameEn: 'Profit Factor',
|
||||
nameZh: '盈亏比',
|
||||
nameZh: 'Profit Factor',
|
||||
formula: 'PF = \\frac{\\sum Profits}{|\\sum Losses|}',
|
||||
descriptionEn: 'Ratio of gross profit to gross loss',
|
||||
descriptionZh: '总盈利与总亏损的比值',
|
||||
descriptionZh: 'Ratio of gross profit to gross loss',
|
||||
},
|
||||
volatility: {
|
||||
key: 'volatility',
|
||||
nameEn: 'Volatility',
|
||||
nameZh: '波动率',
|
||||
nameZh: 'Volatility',
|
||||
formula: '\\sigma = \\sqrt{\\frac{1}{n}\\sum_{i=1}^{n}(r_i - \\bar{r})^2}',
|
||||
descriptionEn: 'Standard deviation of returns',
|
||||
descriptionZh: '收益率的标准差',
|
||||
descriptionZh: 'Standard deviation of returns',
|
||||
},
|
||||
var_95: {
|
||||
key: 'var_95',
|
||||
nameEn: 'VaR (95%)',
|
||||
nameZh: '风险价值',
|
||||
nameZh: 'VaR (95%)',
|
||||
formula: 'P(R < VaR_{95\\%}) = 5\\%',
|
||||
descriptionEn: '95% confidence level maximum expected loss',
|
||||
descriptionZh: '95%置信水平下的最大预期损失',
|
||||
descriptionZh: '95% confidence level maximum expected loss',
|
||||
},
|
||||
alpha: {
|
||||
key: 'alpha',
|
||||
nameEn: 'Alpha',
|
||||
nameZh: '超额收益',
|
||||
nameZh: 'Alpha',
|
||||
formula: '\\alpha = R_{portfolio} - R_{benchmark}',
|
||||
descriptionEn: 'Excess return over benchmark',
|
||||
descriptionZh: '相对于基准的超额收益',
|
||||
descriptionZh: 'Excess return over benchmark',
|
||||
},
|
||||
beta: {
|
||||
key: 'beta',
|
||||
nameEn: 'Beta',
|
||||
nameZh: '贝塔系数',
|
||||
nameZh: 'Beta',
|
||||
formula: '\\beta = \\frac{Cov(R_p, R_m)}{Var(R_m)}',
|
||||
descriptionEn: 'Portfolio sensitivity to market movements',
|
||||
descriptionZh: '投资组合对市场波动的敏感度',
|
||||
descriptionZh: 'Portfolio sensitivity to market movements',
|
||||
},
|
||||
information_ratio: {
|
||||
key: 'information_ratio',
|
||||
nameEn: 'Information Ratio',
|
||||
nameZh: '信息比率',
|
||||
nameZh: 'Information Ratio',
|
||||
formula: 'IR = \\frac{\\alpha}{\\sigma_{tracking}}',
|
||||
descriptionEn: 'Alpha per unit of tracking error',
|
||||
descriptionZh: '单位跟踪误差的超额收益',
|
||||
descriptionZh: 'Alpha per unit of tracking error',
|
||||
},
|
||||
avg_trade_pnl: {
|
||||
key: 'avg_trade_pnl',
|
||||
nameEn: 'Avg Trade PnL',
|
||||
nameZh: '平均盈亏',
|
||||
nameZh: 'Avg Trade PnL',
|
||||
formula: '\\bar{PnL} = \\frac{\\sum PnL_i}{N}',
|
||||
descriptionEn: 'Average profit/loss per trade',
|
||||
descriptionZh: '每笔交易的平均盈亏',
|
||||
descriptionZh: 'Average profit/loss per trade',
|
||||
},
|
||||
expectancy: {
|
||||
key: 'expectancy',
|
||||
nameEn: 'Expectancy',
|
||||
nameZh: '期望收益',
|
||||
nameZh: 'Expectancy',
|
||||
formula: 'E = (WinRate \\times \\bar{W}) - (LossRate \\times \\bar{L})',
|
||||
descriptionEn: 'Expected return per trade',
|
||||
descriptionZh: '每笔交易的期望收益',
|
||||
descriptionZh: 'Expected return per trade',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -259,11 +259,11 @@ export function MetricTooltip({
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
background: 'linear-gradient(145deg, #1E2329 0%, #2B3139 100%)',
|
||||
border: '1px solid #3B4149',
|
||||
background: '#F7F4EC',
|
||||
border: '1px solid rgba(26,24,19,0.14)',
|
||||
borderRadius: '12px',
|
||||
padding: '16px',
|
||||
boxShadow: '0 25px 50px -12px rgba(0, 0, 0, 0.8)',
|
||||
boxShadow: '0 25px 50px -12px rgba(26, 24, 19, 0.18)',
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
@@ -273,27 +273,27 @@ export function MetricTooltip({
|
||||
gap: '8px',
|
||||
marginBottom: '12px',
|
||||
paddingBottom: '8px',
|
||||
borderBottom: '1px solid #3B4149'
|
||||
borderBottom: '1px solid rgba(26,24,19,0.14)'
|
||||
}}>
|
||||
<div style={{
|
||||
width: '8px',
|
||||
height: '8px',
|
||||
borderRadius: '50%',
|
||||
background: '#F0B90B'
|
||||
background: '#E0483B'
|
||||
}} />
|
||||
<span style={{ fontWeight: 'bold', fontSize: '14px', color: '#EAECEF' }}>
|
||||
<span style={{ fontWeight: 'bold', fontSize: '14px', color: '#1A1813' }}>
|
||||
{name}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Formula */}
|
||||
<div style={{
|
||||
background: 'rgba(0,0,0,0.3)',
|
||||
background: '#E8E2D5',
|
||||
borderRadius: '8px',
|
||||
padding: '12px',
|
||||
marginBottom: '12px'
|
||||
}}>
|
||||
<div style={{ fontSize: '12px', color: '#848E9C', marginBottom: '8px' }}>
|
||||
<div style={{ fontSize: '12px', color: '#8A8478', marginBottom: '8px' }}>
|
||||
{formulaLabel}
|
||||
</div>
|
||||
<div style={{
|
||||
@@ -301,7 +301,7 @@ export function MetricTooltip({
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
padding: '8px 4px',
|
||||
color: '#EAECEF',
|
||||
color: '#1A1813',
|
||||
overflowX: 'auto',
|
||||
overflowY: 'hidden',
|
||||
maxWidth: '100%',
|
||||
@@ -312,7 +312,7 @@ export function MetricTooltip({
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<p style={{ fontSize: '12px', lineHeight: '1.5', color: '#B7BDC6', margin: 0 }}>
|
||||
<p style={{ fontSize: '12px', lineHeight: '1.5', color: '#8A8478', margin: 0 }}>
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
@@ -333,8 +333,8 @@ export function MetricTooltip({
|
||||
}
|
||||
setShow(!show)
|
||||
}}
|
||||
className={`p-0.5 rounded-full transition-colors hover:bg-white/10 ${className}`}
|
||||
style={{ color: '#848E9C' }}
|
||||
className={`p-0.5 rounded-full transition-colors hover:bg-[rgba(26,24,19,0.06)] ${className}`}
|
||||
style={{ color: '#8A8478' }}
|
||||
aria-label={`Info about ${name}`}
|
||||
>
|
||||
<HelpCircle size={size} />
|
||||
|
||||
Reference in New Issue
Block a user