Vela, our next-generation charting platform, is live at vela.luxalgo.com.
LuxAlgo

Journal

API reference for @luxalgo/vela-pro-journal, including the journal controller, store port, widgets, and analytics.

View as Markdown

This page documents @luxalgo/vela-pro-journal, including the journal() plugin factory, JournalController, the journal storage port, panel and full-screen journal widgets, and trade reconstruction and analytics functions.

Import symbols on this page from @luxalgo/vela-pro-journal. Related guides: Journal, Standalone widgets.

Functions

breakdown

function breakdown(trades: readonly JournalTrade[], timeZone: string): Breakdown

See also: Breakdown, JournalTrade.

buildTrades

Group the effective fills by account and symbol and walk them in time: same-side fills add to the position, opposite fills close it (lots matched FIFO, LIFO or at the average), and a fill that goes past flat closes the trade and opens the next one the other way.

function buildTrades(
    fills: readonly JournalFill[],
    methodOf?: (accountId: string) => ProfitMethod,
    annotations?: Record<string, TradeAnnotation>,
): JournalTrade[]

Default: methodOf = () => 'fifo'.

See also: JournalFill, JournalTrade, ProfitMethod, TradeAnnotation.

calendarMonth

function calendarMonth(year: number, month: number, days: readonly DayStats[]): CalendarMonth

See also: CalendarMonth, DayStats.

computeMetrics

function computeMetrics(
    trades: readonly JournalTrade[],
    timeZone: string,
    initialBalance?: number | null,
): JournalMetrics

Default: initialBalance = null.

See also: JournalMetrics, JournalTrade.

createJournalPanel

The journal panel as a widget: { el, tools, update, destroy }.

function createJournalPanel(props: JournalPanelProps): JournalPanelWidget

See also: JournalPanelProps, JournalPanelWidget.

createJournalView

The full journal as a widget: { el, open, update, destroy }.

function createJournalView(props: JournalViewProps): JournalViewWidget

See also: JournalViewProps, JournalViewWidget.

dayKey

YYYY-MM-DD of an instant in timeZone.

function dayKey(ms: number, timeZone: string): string

daysBetween

function daysBetween(from: string, to: string): number

dayStats

function dayStats(trades: readonly JournalTrade[], timeZone: string): DayStats[]

See also: DayStats, JournalTrade.

drawdownSeries

How far below its running peak the equity is at each point (0 or less; the peak starts at 0). With a starting balance, a fraction of the equity at the peak: the balance plus the peak P&L.

function drawdownSeries(equity: readonly number[], balance?: number | null): number[]

Default: balance = null.

edgeScore

Six components from 0 to 100 and their weighted mean (null below five closed trades).

function edgeScore(m: JournalMetrics): EdgeScore

See also: EdgeScore, JournalMetrics.

emptyJournal

function emptyJournal(): JournalData

See also: JournalData.

enableJournal

Enable the JOURNAL on every shell built afterwards: its side panel (the account, the range's P&L, the trades and the notes) and the full journal it maximizes into. Returns the page's JournalController. Call ONCE, before constructing shells. Idempotent.

function enableJournal(opts?: EnableJournalOptions): JournalController

See also: EnableJournalOptions, JournalController.

equityCurve

Cumulative net P&L at each closed trade (t its close time).

function equityCurve(trades: readonly JournalTrade[]): Array<{ t: number; cum: number }>

See also: JournalTrade.

headToHead

Two performances over the same metrics. An endless profit factor has no value to compare.

function headToHead(a: JournalMetrics, b: JournalMetrics): HeadToHeadRow[]

See also: HeadToHeadRow, JournalMetrics.

journal

The journal as a Vela Pro plugin: it journals the trading plugin's fills.

function journal(opts?: EnableJournalOptions): VelaProPlugin<JournalController>

See also: EnableJournalOptions, JournalController, VelaProPlugin.

journalController

The page's journal, once enableJournal ran.

function journalController(): JournalController | null

See also: JournalController.

metricDeltas

The dashboard's figures against the previous period. A profit factor without a loss on either side is endless, so it has no change.

function metricDeltas(current: JournalMetrics, previous: JournalMetrics | null): MetricDeltas

See also: JournalMetrics, MetricDeltas.

parseList

Comma-separated words (also full-width and Arabic commas), trimmed and de-duplicated.

function parseList(text: string, maxLen?: number): string[]

Default: maxLen = 40.

previousPeriod

The window of the same length right before range, summarized (null for all time).

function previousPeriod(
    trades: readonly JournalTrade[],
    range: { from: string; to: string } | null,
    timeZone: string,
    today: string,
    initialBalance?: number | null,
): PeriodSummary | null

Default: initialBalance = null.

See also: JournalTrade, PeriodSummary.

previousRange

The window of the same length ending the day before (none for all).

function previousRange(r: { from: string; to: string } | null): { from: string; to: string } | null

relativeChange

(current − previous) / |previous|; null without a baseline (no previous value, or zero).

function relativeChange(
    current: number | null | undefined,
    previous: number | null | undefined,
): number | null

resolveRange

The days a range covers, ending today; null for all.

function resolveRange(range: JournalRange, today: string): { from: string; to: string } | null

See also: JournalRange.

riskBehavior

function riskBehavior(m: JournalMetrics): RiskBehavior

See also: JournalMetrics, RiskBehavior.

shiftDay

function shiftDay(key: string, days: number): string

startingBalance

What a set of accounts started with: the sum of the balances they know (null when none does).

function startingBalance(accounts: readonly JournalAccount[]): number | null

See also: JournalAccount.

summarize

function summarize(
    trades: readonly JournalTrade[],
    timeZone: string,
    initialBalance?: number | null,
): PeriodSummary

Default: initialBalance = null.

See also: JournalTrade, PeriodSummary.

tradesInRange

Trades closed within the range (by close day); open ones when the range reaches today.

function tradesInRange(
    trades: readonly JournalTrade[],
    r: { from: string; to: string } | null,
    timeZone: string,
    today: string,
): JournalTrade[]

See also: JournalTrade.

Classes

JournalController class

class JournalController {
    constructor(opts?: JournalControllerOptions);
    readonly timeZone: string;
    readonly selectedAccount: string | null;
    readonly range: JournalRange;
    readonly custom: { from: string; to: string } | null;
    ready(): Promise<void>;
    accounts(): readonly JournalAccount[];
    account(id?: string | null): JournalAccount | null;
    today(): string;
    days(): { from: string; to: string } | null;
    allTrades(): JournalTrade[];
    accountTrades(accountId: string | null): JournalTrade[];
    trades(r?: { from: string; to: string } | null): JournalTrade[];
    trade(key: string): JournalTrade | null;
    fill(id: string): JournalFill | null;
    fillsOf(trade: JournalTrade): JournalFill[];
    hiddenFillsOf(trade: JournalTrade): JournalFill[];
    notes(): readonly JournalNote[];
    initialBalance(accountId?: string | null): number | null;
    currency(): string | null;
    selectAccount(id: string | null): void;
    setRange(range: JournalRange): void;
    setCustomRange(from: string, to: string): void;
    addAccount(a: { name: string; broker?: string; kind?: JournalAccount['kind']; currency?: string; initialBalance?: number | null; profitMethod?: JournalAccount['profitMethod'] }): JournalAccount;
    updateAccount(
        id: string,
        patch: Partial<Pick<JournalAccount, 'name' | 'initialBalance' | 'profitMethod' | 'currency'>>,
    ): void;
    removeAccount(id: string): void;
    addFills(
        accountId: string,
        fills: ReadonlyArray<Omit<JournalFill, 'id' | 'accountId' | 'source'> & { id?: string }>,
    ): { inserted: number; duplicates: number };
    updateFill(id: string, patch: Partial<FillValues>): void;
    resetFill(id: string): void;
    removeFill(id: string): void;
    restoreFill(id: string): void;
    annotate(key: string, patch: TradeAnnotation): void;
    addNote(body: string, date?: string): JournalNote | null;
    editNote(id: string, body: string): void;
    deleteNote(id: string): void;
    syncBroker(broker: Broker): () => void;
    onChange(cb: (what: JournalChange) => void): () => void;
    destroy(): void;
}
MemberTypeDescription
constructor(opts?: JournalControllerOptions)
timeZonestring
selectedAccountstring | nullThe selected account, or null for all of them.
rangeJournalRange
custom{ from: string; to: string } | null
ready()() => Promise<void>Resolves once the store's data is in.
accounts()() => readonly JournalAccount[]
account()(id?: string | null) => JournalAccount | null
today()() => string
days()() => { from: string; to: string } | nullThe selected days (null: all time).
allTrades()() => JournalTrade[]Every trade of the selected account(s), newest first.
accountTrades()(accountId: string | null) => JournalTrade[]Every trade of one account (null: of all of them), whichever is selected.
trades()(r?: { from: string; to: string } | null) => JournalTrade[]The trades of the selected range.
trade()(key: string) => JournalTrade | null
fill()(id: string) => JournalFill | null
fillsOf()(trade: JournalTrade) => JournalFill[]
hiddenFillsOf()(trade: JournalTrade) => JournalFill[]
notes()() => readonly JournalNote[]
initialBalance()(accountId?: string | null) => number | nullStarting balance for drawdown in percent: one account's (default: the selected one), or with none selected, the sum of every account's that has one.
currency()() => string | null
selectAccount()(id: string | null) => void
setRange()(range: JournalRange) => void
setCustomRange()(from: string, to: string) => void
addAccount()(a: { name: string; broker?: string; kind?: JournalAccount['kind']; … (truncated; see declaration)
updateAccount()(id: string, patch: Partial<Pick<JournalAccount, 'name' | 'initialBalance' … (truncated; see declaration)
removeAccount()(id: string) => void
addFills()(accountId: string, fills: ReadonlyArray<Omit<JournalFill, 'id' | 'accountId' … (truncated; see declaration)Log fills into an account; a fill already there (same id) is skipped.
updateFill()(id: string, patch: Partial<FillValues>) => voidCorrect a fill; the source's values are kept to reset to.
resetFill()(id: string) => void
removeFill()(id: string) => voidA manual fill is deleted; a broker's or a file's is hidden (it would come back on the next sync).
restoreFill()(id: string) => void
annotate()(key: string, patch: TradeAnnotation) => void
addNote()(body: string, date?: string) => JournalNote | null
editNote()(id: string, body: string) => void
deleteNote()(id: string) => void
syncBroker()(broker: Broker) => () => voidMirror a broker's fills into a synced account (created on first use): every fill it reports is journaled once, as it arrives.
onChange()(cb: (what: JournalChange) => void) => () => void
destroy()() => void

See also: Broker, FillValues, JournalAccount, JournalChange, JournalControllerOptions, JournalFill, JournalNote, JournalRange, JournalTrade, TradeAnnotation.

JournalPanelWidget

class JournalPanelWidget {
    constructor(props: JournalPanelProps);
    readonly el: HTMLElement;
    readonly tools: HTMLElement;
    update(next: Partial<Omit<JournalPanelProps, 'controller'>>): void;
    destroy(): void;
}
MemberTypeDescription
constructor(props: JournalPanelProps)
elHTMLElement
toolsHTMLElementThe account picker, Add trade and Maximize: in the widget's top row until a host lifts them into a header of its own.
update()(next: Partial<Omit<JournalPanelProps, 'controller'>>) => void
destroy()() => void

See also: JournalPanelProps.

JournalViewWidget

class JournalViewWidget {
    constructor(props: JournalViewProps);
    readonly el: HTMLElement;
    update(next: Partial<Omit<JournalViewProps, 'controller'>>): void;
    open(target?: { trade?: string; date?: string; page?: Page }): void;
    destroy(): void;
}

// Unexported supporting type referenced above
type Page = 'dashboard' | 'breakdown' | 'trades' | 'notes' | 'compare';
MemberTypeDescription
constructor(props: JournalViewProps)
elHTMLElement
update()(next: Partial<Omit<JournalViewProps, 'controller'>>) => void
open()(target?: { trade?: string; date?: string; page?: Page }) => voidShow a trade's review, a day's review, or a page.
destroy()() => void

See also: JournalViewProps.

LocalJournalStore

The journal in the browser's localStorage (memory only when storage is unavailable).

class LocalJournalStore implements JournalStore {
    constructor(key?: string);
    load(): Promise<JournalData | null>;
    save(data: JournalData): Promise<void>;
}

Default: constructor(key = KEY).

See also: JournalData, JournalStore.

Interfaces and types

AccountKind

type AccountKind = 'manual' | 'import' | 'sync';

Breakdown interface

interface Breakdown {
    weekday: BreakdownGroup[];
    timeOfDay: BreakdownGroup[];
    holdTime: BreakdownGroup[];
    symbol: BreakdownGroup[];
    side: BreakdownGroup[];
    tag: BreakdownGroup[];
    rating: BreakdownGroup[];
}

See also: BreakdownGroup.

BreakdownGroup

interface BreakdownGroup {
    key: string;
    trades: number;
    wins: number;
    losses: number;
    netPnl: number;
    winRate: number | null;
}
MemberTypeDescription
keystring
tradesnumber
winsnumber
lossesnumber
netPnlnumber
winRatenumber | nullwins / (wins + losses), 0–1.

CalendarMonth interface

interface CalendarMonth {
    year: number;
    month: number;
    weeks: Array<{ days: Array<{ date: string; stats: DayStats | null } | null>; netPnl: number; trades: number }>;
    netPnl: number;
    trades: number;
    tradingDays: number;
    winningDays: number;
}
MemberTypeDescription
yearnumber
monthnumber
weeksArray<{ days: Array<{ date: string; stats: DayStats | null } | null>; netPnl: number; trades: number }>Sunday first; null outside the month.
netPnlnumber
tradesnumber
tradingDaysnumber
winningDaysnumber

See also: DayStats.

DayStats interface

interface DayStats {
    date: string;
    netPnl: number;
    grossPnl: number;
    fees: number;
    trades: number;
    wins: number;
    losses: number;
    breakevens: number;
    volume: number;
}

EdgeScore interface

interface EdgeScore {
    score: number | null;
    components: { winRate: number; profitFactor: number; avgWinLoss: number; drawdown: number; recovery: number; consistency: number };
    closedTrades: number;
}

EnableJournalOptions

Options for enableJournal.

interface EnableJournalOptions {
    store?: JournalStore;
    timeZone?: string;
    syncTrading?: boolean;
    width?: number;
    order?: number;
}
MemberTypeDescription
store?JournalStoreWhere the journal lives (default: the browser's storage).
timeZone?stringThe journal's day boundaries (default: the browser's time zone).
syncTrading?booleanJournal the trading broker's fills as they happen (default true, when trading is on).
width?number
order?numberPlace among the panel buttons (default 4).

See also: JournalStore.

FillValues

interface FillValues {
    side: 'buy' | 'sell';
    quantity: number;
    price: number;
    fee: number;
    executedAt: number;
}

HeadToHeadMetric

type HeadToHeadMetric =
    | 'netPnl'
    | 'winRate'
    | 'profitFactor'
    | 'avgWinLoss'
    | 'expectancy'
    | 'maxDrawdown'
    | 'closedTrades';

HeadToHeadRow

interface HeadToHeadRow {
    id: HeadToHeadMetric;
    a: number | null;
    b: number | null;
    lowerIsBetter: boolean;
    winner: 'a' | 'b' | null;
    shareA: number;
    shareB: number;
    delta: number | null;
    ahead: boolean | null;
    deltaShare: number;
}
MemberTypeDescription
idHeadToHeadMetric
anumber | null
bnumber | null
lowerIsBetterbooleanThe smaller value wins (the drawdown).
winner'a' | 'b' | nullNull on a tie, or when neither side has a value.
shareAnumberEach side's bar: its magnitude over the row's larger one.
shareBnumber
deltanumber | nullA minus B; null unless both sides have a value.
aheadboolean | nullA ahead of B (in the row's better direction), behind, or level (null).
deltaSharenumberThe delta's bar: its magnitude over the row's larger value, at most 1.

See also: HeadToHeadMetric.

JournalAccount

interface JournalAccount {
    id: string;
    name: string;
    broker: string;
    kind: AccountKind;
    currency: string;
    initialBalance: number | null;
    profitMethod: ProfitMethod;
    createdAt: number;
}
MemberTypeDescription
idstring
namestring
brokerstringWhere its fills come from (Paper, a broker's name, Manual).
kindAccountKind
currencystring
initialBalancenumber | nullUnlocks drawdown in percent.
profitMethodProfitMethod
createdAtnumber

See also: AccountKind, ProfitMethod.

JournalChange

type JournalChange = 'data' | 'selection';

JournalControllerOptions

interface JournalControllerOptions {
    store?: JournalStore;
    timeZone?: string;
    now?: () => number;
}
MemberTypeDescription
store?JournalStore
timeZone?stringThe journal's day boundaries (default: the browser's time zone).
now?() => number

See also: JournalStore.

JournalData

interface JournalData {
    accounts: JournalAccount[];
    fills: JournalFill[];
    annotations: Record<string, TradeAnnotation>;
    notes: JournalNote[];
}

See also: JournalAccount, JournalFill, JournalNote, TradeAnnotation.

JournalFill

interface JournalFill extends FillValues {
    id: string;
    accountId: string;
    symbol: string;
    source: AccountKind;
    reported?: FillValues | null;
    excluded?: boolean;
}
MemberTypeDescription
idstring
accountIdstring
symbolstring
sourceAccountKind
reported?FillValues | nullWhat the source said, when the user corrected it (the top-level values are the effective ones).
excluded?booleanHidden by the user (a broker's or a file's fill is hidden rather than deleted).

See also: AccountKind, FillValues.

JournalMetrics

interface JournalMetrics {
    totalTrades: number;
    closedTrades: number;
    openTrades: number;
    wins: number;
    losses: number;
    breakevens: number;
    netPnl: number;
    grossPnl: number;
    fees: number;
    winRate: number | null;
    dayWinRate: number | null;
    tradingDays: number;
    winningDays: number;
    losingDays: number;
    profitFactor: number | null;
    profitFactorIsInfinite: boolean;
    avgWin: number | null;
    avgLoss: number | null;
    avgWinLossRatio: number | null;
    expectancy: number | null;
    largestWin: number | null;
    largestLoss: number | null;
    maxWinStreak: number;
    maxLossStreak: number;
    currentStreak: number;
    totalVolume: number;
    avgDurationMs: number | null;
    maxDrawdown: number;
    maxDrawdownPct: number | null;
    recoveryFactor: number | null;
    profitConcentration: number | null;
    avgRealizedR: number | null;
    tradesWithRisk: number;
    bestDay: DayStats | null;
    worstDay: DayStats | null;
}
MemberTypeDescription
totalTradesnumber
closedTradesnumber
openTradesnumber
winsnumber
lossesnumber
breakevensnumber
netPnlnumber
grossPnlnumber
feesnumber
winRatenumber | null0–1.
dayWinRatenumber | null
tradingDaysnumber
winningDaysnumber
losingDaysnumber
profitFactornumber | null
profitFactorIsInfiniteboolean
avgWinnumber | null
avgLossnumber | null
avgWinLossRationumber | null
expectancynumber | null
largestWinnumber | null
largestLossnumber | null
maxWinStreaknumber
maxLossStreaknumber
currentStreaknumberPositive: a winning streak; negative: a losing one.
totalVolumenumber
avgDurationMsnumber | null
maxDrawdownnumber
maxDrawdownPctnumber | null
recoveryFactornumber | null
profitConcentrationnumber | null
avgRealizedRnumber | null
tradesWithRisknumberClosed trades with a stop loss, the ones avgRealizedR averages.
bestDayDayStats | null
worstDayDayStats | null

See also: DayStats.

JournalNote

A note on a day (not on an account).

interface JournalNote {
    id: string;
    date: string;
    body: string;
    createdAt: number;
    updatedAt: number;
}
MemberTypeDescription
idstring
datestringYYYY-MM-DD.
bodystring
createdAtnumber
updatedAtnumber

JournalPanelProps

The journal panel's props. controller is read once; the others can change through update.

interface JournalPanelProps {
    controller: JournalController;
    symbol?: string;
    host?: HTMLElement;
    icons?: () => SymbolIcons | null;
    onMaximize?: (target?: { trade?: string; date?: string }) => void;
    onShowTrade?: (trade: JournalTrade) => void;
    onNotify?: (message: string, kind: 'info' | 'success' | 'error') => void;
}
MemberTypeDescription
controllerJournalControllerThe journal: accounts, fills, trades, notes.
symbol?stringThe symbol a new fill starts on.
host?HTMLElementWhere menus and dialogs mount (default: the widget's own element).
icons?() => SymbolIcons | nullSymbol logos (the chart's data, or anything that answers symbolIcon).
onMaximize?(target?: { trade?: string; date?: string }) => voidOpen the full journal (on a trade, a day, or as it was). Maximize shows only with it.
onShowTrade?(trade: JournalTrade) => voidA trade's chart button: frame it on a chart. The button shows only with it.
onNotify?(message: string, kind: 'info' | 'success' | 'error') => voidTell the user something (a fill added).

See also: JournalController, JournalTrade, SymbolIcons.

JournalRange

type JournalRange = 'today' | '7d' | '30d' | '365d' | 'ytd' | 'all';

JournalStore

Where the journal lives: the host's port (a server, a database). Pro ships a browser one.

interface JournalStore {
    load(): Promise<JournalData | null>;
    save(data: JournalData): Promise<void>;
}

See also: JournalData.

JournalSurface

Where the journal's dialogs mount and how they tell the user, with the symbol a new fill starts on: a shell, or a widget's host and its notices.

interface JournalSurface {
    readonly host: HTMLElement;
    readonly symbol: string;
    toast(message: string, kind?: 'info' | 'success' | 'error'): void;
}

JournalTrade

interface JournalTrade {
    key: string;
    accountId: string;
    symbol: string;
    direction: 'long' | 'short';
    status: TradeStatus;
    openedAt: number;
    closedAt: number | null;
    quantity: number;
    openQuantity: number;
    avgEntry: number;
    avgExit: number | null;
    grossPnl: number;
    fees: number;
    netPnl: number;
    fillIds: string[];
    exits: TradeExit[];
    durationMs: number | null;
    realizedR: number | null;
    annotation: TradeAnnotation;
}
MemberTypeDescription
keystring
accountIdstring
symbolstring
direction'long' | 'short'
statusTradeStatus
openedAtnumber
closedAtnumber | null
quantitynumberThe entry size.
openQuantitynumber
avgEntrynumber
avgExitnumber | null
grossPnlnumber
feesnumber
netPnlnumber
fillIdsstring[]
exitsTradeExit[]
durationMsnumber | null
realizedRnumber | null
annotationTradeAnnotation

See also: TradeAnnotation, TradeExit, TradeStatus.

JournalViewProps

The full journal's props. controller is read once; the others can change through update.

interface JournalViewProps {
    controller: JournalController;
    symbol?: string;
    host?: HTMLElement;
    icons?: () => SymbolIcons | null;
    onMinimize?: () => void;
    onClose?: () => void;
    onShowTrade?: (trade: JournalTrade) => void;
    onNotify?: (message: string, kind: 'info' | 'success' | 'error') => void;
}
MemberTypeDescription
controllerJournalControllerThe journal: accounts, fills, trades, notes.
symbol?stringThe symbol a new fill starts on.
host?HTMLElementWhere menus and dialogs mount (default: the widget's own element).
icons?() => SymbolIcons | nullSymbol logos (the chart's data, or anything that answers symbolIcon).
onMinimize?() => voidBack to the chart (its button, Escape, Show on chart first). The button shows only with it.
onClose?() => voidClose the journal altogether. The button shows only with it.
onShowTrade?(trade: JournalTrade) => voidFrame a trade on a chart. Its buttons show only with it.
onNotify?(message: string, kind: 'info' | 'success' | 'error') => voidTell the user something (a fill added).

See also: JournalController, JournalTrade, SymbolIcons.

MetricDeltas interface

interface MetricDeltas {
    netPnl: number | null;
    winRate: number | null;
    profitFactor: number | null;
    avgWinLoss: number | null;
    dayWinRate: number | null;
}

PeriodSummary

A stretch of trading: its metrics, its trading days, the equity after each, its Edge Score.

interface PeriodSummary {
    metrics: JournalMetrics;
    days: DayStats[];
    equity: number[];
    edge: EdgeScore;
}
MemberTypeDescription
metricsJournalMetrics
daysDayStats[]
equitynumber[]Cumulative net P&L at the end of each trading day.
edgeEdgeScore

See also: DayStats, EdgeScore, JournalMetrics.

ProfitMethod

type ProfitMethod = 'fifo' | 'lifo' | 'wavg';

RiskBehavior interface

interface RiskBehavior {
    maxDrawdown: { amount: number; fraction: number | null; recovery: number | null };
    expectancy: { amount: number | null; avgR: number | null };
    avgDurationMs: number | null;
    streak: { current: number; best: number; worst: number };
    days: { best: DayStats | null; worst: DayStats | null };
}
MemberTypeDescription
maxDrawdown{ amount: number; fraction: number | null; recovery: number | null }The deepest fall from a peak; its fraction and the recovery factor need a starting balance.
expectancy{ amount: number | null; avgR: number | null }Net P&L per closed trade; the average R once closed trades carry a stop.
avgDurationMsnumber | null
streak{ current: number; best: number; worst: number }current: positive for wins in a row, negative for losses.
days{ best: DayStats | null; worst: DayStats | null }

See also: DayStats.

TradeAnnotation

What the user writes about a trade.

interface TradeAnnotation {
    notes?: string;
    tags?: string[];
    mistakes?: string[];
    rating?: number | null;
    stopLoss?: number | null;
    profitTarget?: number | null;
    reviewedAt?: number | null;
}
MemberTypeDescription
notes?string
tags?string[]
mistakes?string[]
rating?number | null1–5.
stopLoss?number | null
profitTarget?number | null
reviewedAt?number | null

TradeExit

interface TradeExit {
    fillId: string;
    quantity: number;
    grossPnl: number;
    time: number;
}

TradeStatus

type TradeStatus = 'open' | 'win' | 'loss' | 'breakeven';

Constants

EDGE_MIN_TRADES

const EDGE_MIN_TRADES: 5;

JOURNAL_PANEL_ID

const JOURNAL_PANEL_ID: 'vela-pro.journal';

On this page