Skip to main content

Module terminal

Module terminal 

Source
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 a String, 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.
ReportTraitMethods
option chainChainReportrender_table, print_table
simulation statisticsSimulationReportrender_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ยง

ChainReport
Terminal tables for an option chain.
SimulationReport
Terminal tables for simulation statistics.