wsb_rs/
lib.rs

1//! ### About
2//! Calculates and prints a spread table of puts and calls,
3//! along with their updated valuations at different price points.
4//!
5//! ### Usage:
6//! ```ignore
7//! $ wbs-rs <STRIKE_PRICE> <CONTRACT_PRICE> <NUM_CONTRACTS = 1>
8//!
9//! Arguments:
10//!   <STRIKE_PRICE>        Stock strike price.
11//!   <CONTRACT_PRICE>      Price of contract.
12//!   <NUM_CONTRACTS>       Number of contracts.
13//! ```
14
15pub mod config;
16mod constants;
17mod utils;
18
19use config::Config;
20use constants::OptionType;
21
22pub fn run(config: Config) {
23    println!("");
24    println!("  Strike price: ${}", config.strike);
25    println!("  Price per contract: ${}", config.contract);
26    println!("  Number of contracts: {}", config.num);
27    println!("  Premium: ${:.2}", config.contract * 100.0 * config.num);
28
29    println!("");
30    println!("Price:\t\t Profit:");
31    println!("------------------------------------");
32
33    utils::print_table(OptionType::Put, &config);
34
35    println!("------------------------------------");
36    println!(" ${}", config.strike);
37    println!("------------------------------------");
38
39    utils::print_table(OptionType::Call, &config);
40}