1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/******************************************************************************
Author: Joaquín Béjar García
Email: jb@taunais.com
Date: 1/8/24
******************************************************************************/
//! # Model Module
//!
//! The core data structures of financial options modeling: option contracts,
//! positions, legs, trades, payoffs at expiry and checked `Decimal` helpers.
//! Pricing models, Greeks, probabilities and risk metrics are built on these
//! types by the layers above; none of them lives here.
//!
//! ## Core Components
//!
//! * `option` - Implementation of the core Options structure and related functionality
//! * `position` - Management of financial positions and their properties
//! * `types` - Essential type definitions and enums
//! * `utils` - Utility functions for model operations and calculations
//! * `format` - Display and Debug implementations for model types
//!
//! ## Key Features
//!
//! ### Options
//!
//! Comprehensive implementation of financial options including:
//!
//! * Multiple option types (European, American, Asian, etc.)
//! * Contract validation, time to expiry and payoff at expiry
//! * Intrinsic value and moneyness
//!
//! ### Position Management
//!
//! Tools for managing financial positions:
//!
//! * Position tracking
//! * Cost basis calculations
//! * Profit/Loss analysis
//! * Break-even calculations
//! * Fee management
//!
//! ### Type System
//!
//! Robust type definitions ensuring type safety:
//!
//! * `Positive` for non-negative numbers
//! * `ExpirationDate` handling
//! * Option styles and types
//! * Side (Long/Short) definitions
//!
//! ### Formatting
//!
//! Comprehensive formatting support:
//!
//! * Display trait implementations for readable output
//! * Debug trait implementations for detailed inspection
//! * Consistent formatting across all types
//! * Custom format implementations for complex types
//!
//! ## Example Usage
//!
//! ```rust
//! use rust_decimal_macros::dec;
//! use tracing::info;
//! use optionstratlib_core::model::{ExpirationDate, Options};
//! use optionstratlib_core::model::types::{ OptionStyle, OptionType, Side};
//! use positive::pos_or_panic;
//! use positive::Positive;
//!
//! let option = Options::new(
//! OptionType::European,
//! Side::Long,
//! "AAPL".to_string(),
//! Positive::HUNDRED,
//! ExpirationDate::Days(pos_or_panic!(30.0)),
//! pos_or_panic!(0.2),
//! Positive::ONE,
//! pos_or_panic!(105.0),
//! dec!(0.05),
//! OptionStyle::Call,
//! pos_or_panic!(0.01),
//! None,
//! );
//!
//! info!("Option Details: {}", option);
//! info!("Debug View: {:?}", option);
//! ```
/// Core utilities for handling decimal numbers in financial calculations.
/// Formatting utilities for displaying financial data and calculations.
/// The option contract (`Options`): terms, validation, time to expiry and payoff.
/// Trading positions (`Position`): an option with its premium, fees, quantity and open date.
/// Payoff contracts at expiry: [`payoff::Payoff`], [`payoff::PayoffInfo`] and the
/// implementation for every [`OptionType`] variant.
/// Common type definitions used throughout the options strategy library.
/// Utility functions supporting various operations across the library.
/// Components for defining and working with chart axes in strategy visualizations.
/// Components for defining and working with expiration dates.
/// Components for different types of trading legs (spot, futures, perpetuals).
pub use BasicAxisTypes;
pub use *;
pub use ExpirationDate;
pub use ExpirationDateError;
pub use ;
pub use ;
pub use Options;
pub use Position;
pub use ;
pub use ;
/// `Positive`, the non-negative decimal newtype, its error and the
/// `is_positive::<T>()` type check. Defined by the
/// standalone `positive` crate and re-exported unchanged: a value obtained
/// through this path *is* a `positive::Positive` (see the crate-level
/// "Foundational types" table).
pub use ;