mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 16:26:57 +08:00
fix: dashboard metrics — real drawdown baseline, realized/unrealized split, risk radar fields
- Max drawdown was double-broken: the backend built the equity curve on a hardcoded $10k baseline (understating a small account's drawdown ~20x) and the frontend multiplied the already-percent value by 100 again (0.87% shown as -86.9%). The curve now starts from the trader's real initial balance (10k fallback when unknown) and the UI renders the percent once; the demo engine and type docs are aligned to percent semantics. - Header now separates equity-based 'Total P/L (incl. unrealized)' from 'Realized P/L (closed trades)' so it no longer contradicts profit factor / win rate, and the stats strip shows the fee-drag chain (gross - fees = net) plus a per-trade-labelled sharpe. - Risk radar read a non-existent account field (total_unrealized_profit) so unrealized PnL always showed $0; small PnLs also render with cents now. - Nav 'Connect Hyperliquid' turns into a green connected chip when the server already holds a fully-authorized exchange, instead of nagging forever from a browser without the localStorage flow state.
This commit is contained in:
@@ -612,6 +612,12 @@ func (at *AutoTrader) GetID() string {
|
||||
return at.id
|
||||
}
|
||||
|
||||
// GetInitialBalance returns the account baseline used for performance metrics
|
||||
// (e.g. the drawdown equity curve).
|
||||
func (at *AutoTrader) GetInitialBalance() float64 {
|
||||
return at.initialBalance
|
||||
}
|
||||
|
||||
// GetUnderlyingTrader returns the underlying Trader interface implementation
|
||||
// This is used by grid trading and other components that need direct exchange access
|
||||
func (at *AutoTrader) GetUnderlyingTrader() Trader {
|
||||
|
||||
@@ -652,7 +652,7 @@ func (at *AutoTrader) buildTradingContext() (*kernel.Context, error) {
|
||||
}
|
||||
}
|
||||
// Get trading statistics for AI context
|
||||
stats, err := at.store.Position().GetFullStats(at.id)
|
||||
stats, err := at.store.Position().GetFullStats(at.id, at.initialBalance)
|
||||
if err != nil {
|
||||
at.logWarnf("⚠️ Failed to get trading stats: %v", err)
|
||||
} else if stats == nil {
|
||||
|
||||
Reference in New Issue
Block a user