Skip to content

Commit 12be283

Browse files
Merge pull request #3 from that-github-user/feature/track-record-v2
Rewrite TrackRecord: points-denominated trade log with session context
2 parents df33698 + 5f6d955 commit 12be283

File tree

4 files changed

+325
-178
lines changed

4 files changed

+325
-178
lines changed

src/api/mock.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export function generateMockHistory(): HistoryResponse {
304304
realized_return: i > 0 ? ret : null,
305305
realized_direction: i > 0 ? (ret > 0 ? "UP" as const : "DOWN" as const) : null,
306306
realized_returns: null,
307+
regime: (["trending", "mean-reverting", "volatile", "quiet"] as const)[i % 4],
307308
});
308309
}
309310

@@ -312,5 +313,22 @@ export function generateMockHistory(): HistoryResponse {
312313
live_pf: grossLoss > 0 ? +(grossProfit / grossLoss).toFixed(2) : null,
313314
live_win_rate: total > 0 ? +(wins / total).toFixed(4) : null,
314315
live_num_trades: total,
316+
session_stats: {
317+
n_trades: total,
318+
n_wins: wins,
319+
n_losses: total - wins,
320+
n_flat: 31 - total,
321+
total_pnl_pts: +(cumPnl * BASE_PRICE).toFixed(2),
322+
best_trade_pts: +(grossProfit * BASE_PRICE / Math.max(wins, 1)).toFixed(2),
323+
worst_trade_pts: +(-grossLoss * BASE_PRICE / Math.max(total - wins, 1)).toFixed(2),
324+
current_streak: wins > total - wins ? 2 : 1,
325+
streak_type: wins > total - wins ? "W" as const : "L" as const,
326+
regime_breakdown: {
327+
trending: { n: 5, wins: 3, pnl_pts: 8.5 },
328+
"mean-reverting": { n: 4, wins: 2, pnl_pts: -2.0 },
329+
volatile: { n: 3, wins: 1, pnl_pts: -4.5 },
330+
quiet: { n: 2, wins: 2, pnl_pts: 6.0 },
331+
},
332+
},
315333
};
316334
}

src/api/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,28 @@ export interface HistoryEntry {
7777
realized_return: number | null;
7878
realized_direction: "UP" | "DOWN" | null;
7979
realized_returns: Record<string, number | null> | null;
80+
regime?: string | null;
81+
}
82+
83+
export interface SessionStats {
84+
n_trades: number;
85+
n_wins: number;
86+
n_losses: number;
87+
n_flat: number;
88+
total_pnl_pts: number;
89+
best_trade_pts: number;
90+
worst_trade_pts: number;
91+
current_streak: number;
92+
streak_type: "W" | "L" | "none";
93+
regime_breakdown?: Record<string, { n: number; wins: number; pnl_pts: number }> | null;
8094
}
8195

8296
export interface HistoryResponse {
8397
entries: HistoryEntry[];
8498
live_pf: number | null;
8599
live_win_rate: number | null;
86100
live_num_trades: number | null;
101+
session_stats?: SessionStats | null;
87102
}
88103

89104
export interface PathTrackingInfo {

0 commit comments

Comments
 (0)