fix: использовать total_capital для корректного расчёта PnL%
cfg.initial_capital * len(assets) = $16 * 7 = $112, но реальный депозит $114. Добавлен capital.total в конфиг. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -3,7 +3,8 @@
|
||||
mode: live # paper | live
|
||||
|
||||
capital:
|
||||
initial: 16.0 # per-asset ($114 / 7)
|
||||
initial: 16.0 # per-asset (new assets)
|
||||
total: 114.0 # actual total capital deposited
|
||||
currency: USDC
|
||||
|
||||
risk:
|
||||
|
||||
@@ -107,7 +107,7 @@ def status():
|
||||
click.echo("=" * 70)
|
||||
|
||||
total_equity = 0
|
||||
total_initial = 0
|
||||
total_initial = cfg.total_capital if cfg.total_capital > 0 else cfg.initial_capital * len(assets)
|
||||
|
||||
header = f" {'Asset':<10s} {'Equity':>10s} {'PnL':>10s} {'Trades':>7s} {'WR':>5s} {'Position':>12s} {'CB':>3s}"
|
||||
click.echo(header)
|
||||
@@ -128,7 +128,6 @@ def status():
|
||||
|
||||
cb = "ON" if a["cb_active"] else "—"
|
||||
total_equity += eq
|
||||
total_initial += cfg.initial_capital
|
||||
|
||||
click.echo(f" {a['ticker']:<10s} ${eq:>9,.2f} ${pnl:>+9,.2f} "
|
||||
f"{trades:>7d} {wr:>4.0f}% {pos_str:>12s} {cb:>3s}")
|
||||
|
||||
@@ -85,6 +85,7 @@ class TelegramConfig:
|
||||
class Config:
|
||||
mode: str = "paper"
|
||||
initial_capital: float = 100.0
|
||||
total_capital: float = 0.0 # actual total deposited; 0 = auto-compute
|
||||
currency: str = "USDT"
|
||||
timeframe: str = "1d"
|
||||
check_time: str = "22:00"
|
||||
@@ -138,6 +139,7 @@ def load_config(path: Path | None = None) -> Config:
|
||||
return Config(
|
||||
mode=raw.get("mode", "paper"),
|
||||
initial_capital=capital_raw.get("initial", 100.0),
|
||||
total_capital=capital_raw.get("total", 0.0),
|
||||
currency=capital_raw.get("currency", "USDT"),
|
||||
timeframe=schedule_raw.get("timeframe", "1d"),
|
||||
check_time=schedule_raw.get("check_time", "22:00"),
|
||||
|
||||
@@ -98,7 +98,7 @@ def format_status_report(cfg, conn) -> str:
|
||||
assets = [get_asset(conn, t) for t in active_tickers]
|
||||
assets = [a for a in assets if a is not None]
|
||||
|
||||
total_initial = cfg.initial_capital * len(assets) if assets else cfg.initial_capital
|
||||
total_initial = cfg.total_capital if cfg.total_capital > 0 else cfg.initial_capital * len(assets)
|
||||
|
||||
# Get real balance from exchange (mark-to-market)
|
||||
exchange_balance = _get_exchange_balance(cfg)
|
||||
|
||||
@@ -42,7 +42,7 @@ def create_app(cfg: Config) -> FastAPI:
|
||||
positions[a["ticker"]] = dict(pos)
|
||||
|
||||
total_equity = sum(a["equity"] for a in assets)
|
||||
total_initial = cfg.initial_capital * len(cfg.assets)
|
||||
total_initial = cfg.total_capital if cfg.total_capital > 0 else cfg.initial_capital * len(cfg.assets)
|
||||
total_pnl = total_equity - total_initial
|
||||
total_ret = (total_equity / total_initial - 1) * 100 if total_initial > 0 else 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user