Expand description
Terminal tables for chain and simulation reports: the explicit adapter that writes them to stdout (M6-05). Terminal tables for chain and simulation reports.
The computational crates return structured data and never write to
stdout: an OptionChain
is market data, and
SimulationStats
and
SimulationStatsResult
are run statistics. This module is the explicit adapter that turns them
into bordered terminal tables, so the terminal-table package is resolved
by the presentation crate alone (M6-05, #546).
Each report comes in two forms:
render_*returns the tables as aString, in plain text without ANSI escapes, ready to log, snapshot or write anywhere.print_*writes the same tables to stdout, coloured when stdout is a terminal. It is the only place in the library that writes to stdout, and it does so only when called.
| Report | Trait | Methods |
|---|---|---|
| option chain | ChainReport | render_table, print_table |
| simulation statistics | SimulationReport | render_summary, print_summary, render_individual_results, print_individual_results |
use optionstratlib_core::model::Positive;
use optionstratlib_market::chains::OptionChain;
use optionstratlib_visualization::visualization::terminal::ChainReport;
let chain = OptionChain::new("SPY", Positive::HUNDRED, "2030-01-18".to_string(), None, None);
let table = chain.render_table();
assert!(table.contains("Strike"));
assert!(!table.contains('\u{1b}'));Traitsยง
- Chain
Report - Terminal tables for an option chain.
- Simulation
Report - Terminal tables for simulation statistics.