trader.cli.tables module¶
One shared table-construction helper for every CLI table.
Six commands (positions, account, outcomes, history, strategies) used to hand-build column widths in f-strings, one format per command and silently drifting apart — outcomes’ own header once sat two characters out of step with its own row data because widening one :<N> and not the other is an easy, silent mistake. build_table is now the only place a column gets padded: every command supplies headers and already-formatted cell text, and prettytable.PrettyTable does the layout.
Cells reaching this module are strings (or values str() renders sanely). Rounding a Decimal or formatting a percentage is the caller’s job, not this module’s — a table helper that rounded money itself would be exactly the kind of incidental rounding the project’s Decimal/quantize rule forbids.
- trader.cli.tables.MISSING = '-'¶
What an unknown, never-fabricated value renders as — a dash, not a blank (which reads as “nothing was tried”) and not a 0 (which reads as a measured value). Days held with no round trip on record uses this; so does a percentage whose inputs cannot support one.
- trader.cli.tables.build_table(headers, rows)[source]¶
A table with its first column left-aligned and the rest right-aligned.
Every CLI table here has the same shape: one label column (SYMBOL, DATE, ID, STRATEGY) followed by several numeric or percentage columns. Right- aligning the numeric columns is what makes a column of numbers scannable; left-aligning only the label column keeps a table from looking staggered when that column’s values vary widely in length.
- Parameters:
headers (Sequence[str])
rows (Sequence[Sequence[object]])
- Return type:
PrettyTable