Show stage-aware + consistency-adjusted profit target on dashboards
State API now returns effectiveProfitTarget = max(stage profit target, maxDay/consistency). When a big day forces the consistency rule, this reflects the actual amount needed to complete the stage — not just the base profit target. Main dashboard and account detail page now display this instead of the raw cfg.profitTarget. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9928f1cabd
commit
8204cd138b
@@ -38,6 +38,7 @@ export async function GET() {
|
||||
: allFundTxns;
|
||||
let targetHit = false;
|
||||
let dailyTarget: { amount: number; path: 'first_day' | 'normal_day' | 'reduced_day' } | null = null;
|
||||
let effectiveProfitTarget: number | null = null;
|
||||
if (cfg && !isDead) {
|
||||
const withdrawalStages: { profit: number; consistency: number; minTradingDays: number }[] = (() => { try { return JSON.parse(cfg.withdrawal_stages ?? '[]'); } catch { return []; } })();
|
||||
const effective = resolveEffectiveConfig(
|
||||
@@ -52,6 +53,15 @@ export async function GET() {
|
||||
const equityProfit = cash.amount - cfg.account_size;
|
||||
const target = computeDailyTarget(effective.profitTarget, effective.consistency, dailyPnL, cfg.min_day_pnl, effective.minTradingDays, equityProfit);
|
||||
dailyTarget = target;
|
||||
|
||||
// Effective profit target = max(stage target, consistency realTarget).
|
||||
// If a big day forces the consistency rule, the account must reach maxDay/consistency
|
||||
// in total trading profit for the stage, not just profitTarget.
|
||||
const qualifying = cfg.min_day_pnl === 0 ? dailyPnL : dailyPnL.filter((d) => d.pnl >= cfg.min_day_pnl);
|
||||
const maxDay = qualifying.length > 0 ? Math.max(...qualifying.map((d) => d.pnl)) : 0;
|
||||
const consistencyReal = (effective.consistency > 0 && effective.consistency < 1 && maxDay > 0)
|
||||
? maxDay / effective.consistency : 0;
|
||||
effectiveProfitTarget = Math.max(effective.profitTarget, consistencyReal);
|
||||
// Condition 1: profit target already exceeded (target=0), still need days → any activity counts
|
||||
// Condition 2: target > 0 → must have made at least the computed daily target
|
||||
if (target) {
|
||||
@@ -75,6 +85,7 @@ export async function GET() {
|
||||
totalProfit,
|
||||
targetHit,
|
||||
dailyTarget,
|
||||
effectiveProfitTarget,
|
||||
dailyPnL,
|
||||
fullDailyPnL: client.fullDailyPnL?.[acc.id] ?? loadDailyPnL(acc.id),
|
||||
fundTransactions: displayFundTxns,
|
||||
|
||||
Reference in New Issue
Block a user