fix: tighten max-hold session countdown
This commit is contained in:
@@ -25,16 +25,19 @@ function pnlColor(v: number): string {
|
||||
function maxHoldText(trade: PaperTrade, compact = false): string | null {
|
||||
const remaining = trade.sessions_remaining;
|
||||
if (remaining == null) return null;
|
||||
if (remaining <= 0) return 'exits today';
|
||||
if (compact) return `${remaining} ${remaining === 1 ? 'session' : 'sessions'} left`;
|
||||
const held = trade.sessions_held ?? 0;
|
||||
if (remaining < 0) return compact ? 'past max hold' : `${held} held · past max hold`;
|
||||
if (remaining === 0) return compact ? 'max hold reached' : `${held} held · max hold reached`;
|
||||
if (compact) return `${remaining} ${remaining === 1 ? 'session' : 'sessions'} left`;
|
||||
return `${held} held · ${remaining} remaining`;
|
||||
}
|
||||
|
||||
function maxHoldColor(trade: PaperTrade): string {
|
||||
return trade.sessions_remaining != null && trade.sessions_remaining <= 5
|
||||
? 'text-amber-300'
|
||||
: 'text-gray-400';
|
||||
const remaining = trade.sessions_remaining;
|
||||
if (remaining == null) return 'text-gray-400';
|
||||
const holdDays = Math.max(1, (trade.sessions_held ?? 0) + remaining);
|
||||
const warningAt = Math.max(1, Math.ceil(holdDays * 0.2));
|
||||
return remaining <= warningAt ? 'text-amber-300' : 'text-gray-400';
|
||||
}
|
||||
|
||||
function DirTag({ direction }: { direction: string }) {
|
||||
|
||||
Reference in New Issue
Block a user