optionstratlib 0.9.0

OptionStratLib is a comprehensive Rust library for options trading and strategy development across multiple asset classes.
Documentation
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
<div style="text-align: center;">
<img src="https://raw.githubusercontent.com/joaquinbejar/OptionStratLib/refs/heads/main/doc/images/logo.png" alt="OptionStratLib" style="width: 100%; height: 100%;">
</div>

[![Dual License](https://img.shields.io/badge/license-MIT%20and%20Apache%202.0-blue)](./LICENSE)
[![Crates.io](https://img.shields.io/crates/v/optionstratlib.svg)](https://crates.io/crates/optionstratlib)
[![Downloads](https://img.shields.io/crates/d/optionstratlib.svg)](https://crates.io/crates/optionstratlib)
[![Stars](https://img.shields.io/github/stars/joaquinbejar/OptionStratLib.svg)](https://github.com/joaquinbejar/OptionStratLib/stargazers)
[![Issues](https://img.shields.io/github/issues/joaquinbejar/OptionStratLib.svg)](https://github.com/joaquinbejar/OptionStratLib/issues)
[![PRs](https://img.shields.io/github/issues-pr/joaquinbejar/OptionStratLib.svg)](https://github.com/joaquinbejar/OptionStratLib/pulls)
[![Build Status](https://img.shields.io/github/workflow/status/joaquinbejar/OptionStratLib/CI)](https://github.com/joaquinbejar/OptionStratLib/actions)
[![Coverage](https://img.shields.io/codecov/c/github/joaquinbejar/OptionStratLib)](https://codecov.io/gh/joaquinbejar/OptionStratLib)
[![Dependencies](https://img.shields.io/librariesio/github/joaquinbejar/OptionStratLib)](https://libraries.io/github/joaquinbejar/OptionStratLib)
[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://docs.rs/optionstratlib)
[![Wiki](https://img.shields.io/badge/wiki-latest-blue.svg)](https://deepwiki.com/joaquinbejar/OptionStratLib)


## OptionStratLib v0.9.0: Financial Options Library

### Table of Contents
1. [Introduction]#introduction
2. [Features]#features
3. [Core Modules]#core-modules
4. [Trading Strategies]#trading-strategies
5. [Setup Instructions]#setup-instructions
6. [Library Usage]#library-usage
7. [Usage Examples]#usage-examples
8. [Testing]#testing
9. [Contribution and Contact]#contribution-and-contact

### Introduction

OptionStratLib is a comprehensive Rust library for options trading and strategy development across multiple asset classes.
This versatile toolkit enables traders, quants, and developers to model, analyze, and visualize options strategies with a
robust, type-safe approach. The library focuses on precision with decimal-based calculations, extensive test coverage,
and a modular architecture built on modern Rust 2024 edition.

### Features

#### 1. **Pricing Models**
- **Black-Scholes Model**: European options pricing with full Greeks support
- **Binomial Tree Model**: American and European options with early exercise capability
- **Monte Carlo Simulations**: Complex pricing scenarios and path-dependent options
- **Telegraph Process Model**: Advanced stochastic modeling for jump-diffusion processes

#### 2. **Greeks Calculation**
- Complete Greeks suite: Delta, Gamma, Theta, Vega, Rho
- Real-time sensitivity analysis
- Greeks visualization and risk profiling
- Custom Greeks implementations with adjustable parameters

#### 3. **Volatility Models**
- Implied volatility calculation using Newton-Raphson method
- Volatility surface construction and interpolation
- Historical volatility estimation
- Advanced volatility modeling tools

#### 4. **Option Chain Management**
- Complete option chain construction and analysis
- Strike price generation algorithms
- Chain data import/export (CSV/JSON formats)
- Advanced filtering and selection tools
- Option data grouping and organization

#### 5. **Trading Strategies (25+ Strategies)**
- **Single Leg**: Long/Short Calls and Puts
- **Spreads**: Bull/Bear Call/Put Spreads
- **Butterflies**: Long/Short Butterfly Spreads, Call Butterfly
- **Complex**: Iron Condor, Iron Butterfly
- **Volatility**: Long/Short Straddles and Strangles
- **Income**: Covered Calls, Poor Man's Covered Call
- **Protection**: Protective Puts, Collars
- **Custom**: Flexible custom strategy framework

#### 6. **Risk Management & Analysis**
- Position tracking and management
- Break-even analysis with multiple break-even points
- Profit/Loss calculations at various price points
- Risk profiles and comprehensive visualizations
- Delta neutrality analysis and adjustment
- Probability analysis for strategy outcomes

#### 7. **Backtesting Framework**
- Comprehensive backtesting engine
- Performance metrics calculation
- Strategy optimization tools
- Historical analysis capabilities

#### 8. **Simulation Tools**
- Monte Carlo simulations for strategy testing
- Telegraph process implementation
- Random walk simulations
- Custom simulation frameworks
- Parametrized simulations with adjustable inputs

#### 9. **Visualization & Plotting**
- Strategy payoff diagrams
- Greeks visualization
- 3D volatility surfaces
- Risk profiles and P&L charts
- Interactive charts (powered by `plotly.rs`)
- Binomial tree visualization
- Comprehensive plotting utilities

#### 10. **Data Management**
- Efficient decimal-based calculations using `rust_decimal`
- CSV/JSON import/export functionality
- Time series data handling
- Price series management and manipulation
- Robust data validation and error handling

#### 11. **Mathematical Tools**
- Curve interpolation techniques
- Surface construction and analysis
- Geometric operations for financial modeling
- Advanced mathematical utilities for options pricing


### Core Modules

The library is organized into the following key modules:

#### **Model** (`model/`)
Core data structures and types for options trading:
- `option.rs`: Complete option structures with pricing and Greeks
- `position.rs`: Position management and P&L tracking
- `expiration.rs`: Flexible expiration date handling (Days/DateTime)
- `positive.rs`: Type-safe positive number implementation
- `types.rs`: Common enums (OptionType, Side, OptionStyle)
- `trade.rs`: Trade execution and management
- `format.rs`: Data formatting utilities

#### **Pricing Models** (`pricing/`)
Advanced pricing engines for options valuation:
- `black_scholes_model.rs`: European options pricing with Greeks
- `binomial_model.rs`: American/European options with early exercise
- `monte_carlo.rs`: Path-dependent and exotic options pricing
- `telegraph.rs`: Jump-diffusion process modeling
- `payoff.rs`: Payoff function implementations

#### **Strategies** (`strategies/`)
Comprehensive trading strategy implementations:
- `base.rs`: Core traits (Strategable, BasicAble, Positionable, etc.)
- **Single Leg**: `long_call.rs`, `short_call.rs`, `long_put.rs`, `short_put.rs`
- **Spreads**: `bull_call_spread.rs`, `bear_call_spread.rs`, `bull_put_spread.rs`, `bear_put_spread.rs`
- **Butterflies**: `long_butterfly_spread.rs`, `short_butterfly_spread.rs`, `call_butterfly.rs`
- **Complex**: `iron_condor.rs`, `iron_butterfly.rs`
- **Volatility**: `long_straddle.rs`, `short_straddle.rs`, `long_strangle.rs`, `short_strangle.rs`
- **Income**: `covered_call.rs`, `poor_mans_covered_call.rs`
- **Protection**: `protective_put.rs`, `collar.rs`
- `custom.rs`: Flexible custom strategy framework
- `probabilities/`: Probability analysis for strategy outcomes
- `delta_neutral/`: Delta neutrality analysis and adjustment

#### **Volatility** (`volatility/`)
Volatility modeling and analysis:
- `utils.rs`: Implied volatility calculation (Newton-Raphson method)
- `traits.rs`: Volatility model interfaces
- Advanced volatility surface construction

#### **Greeks** (`greeks/`)
Complete Greeks calculation suite:
- Delta, Gamma, Theta, Vega, Rho calculations
- Real-time sensitivity analysis
- Greeks-based risk management

#### **Chains** (`chains/`)
Option chain management and analysis:
- `chain.rs`: Option chain construction and manipulation
- `utils.rs`: Chain analysis and filtering tools
- CSV/JSON import/export functionality
- Strike price generation algorithms

#### **Backtesting** (`backtesting/`)
Strategy performance analysis:
- `metrics.rs`: Performance metrics calculation
- `results.rs`: Backtesting results management
- `types.rs`: Backtesting data structures

#### **Simulation** (`simulation/`)
Monte Carlo and stochastic simulations:
- Random walk implementations
- Telegraph process modeling
- Custom simulation frameworks
- Parametrized simulation tools

#### **Visualization** (`visualization/`)
Comprehensive plotting and charting:
- `plotly.rs`: Interactive charts with Plotly integration
- Strategy payoff diagrams
- Greeks visualization
- 3D volatility surfaces
- Risk profile charts

#### **Risk Management** (`risk/`)
Risk analysis and management tools:
- Position risk metrics
- Break-even analysis
- Risk profile generation

#### **P&L** (`pnl/`)
Profit and loss calculation:
- Real-time P&L tracking
- Historical P&L analysis
- Performance attribution

#### **Curves & Surfaces** (`curves/`, `surfaces/`)
Mathematical tools for financial modeling:
- Curve interpolation techniques
- Surface construction and analysis
- 3D visualization capabilities

#### **Error Handling** (`error/`)
Robust error management:
- Comprehensive error types for each module
- Type-safe error propagation
- Detailed error reporting

### Core Components

```mermaid
classDiagram
class Options {
+option_type: OptionType
+side: Side
+underlying_symbol: String
+strike_price: Positive
+expiration_date: ExpirationDate
+implied_volatility: Positive
+quantity: Positive
+underlying_price: Positive
+risk_free_rate: Decimal
+option_style: OptionStyle
+dividend_yield: Positive
+exotic_params: Option~ExoticParams~
+calculate_price_black_scholes()
+calculate_price_binomial()
+time_to_expiration()
+is_long()
+is_short()
+validate()
+to_plot()
+calculate_implied_volatility()
+delta()
+gamma()
+theta()
+vega()
+rho()
}

class Position {
+option: Options
+position_cost: Positive
+entry_date: DateTime<Utc>
+open_fee: Positive
+close_fee: Positive
+net_cost()
+net_premium_received()
+unrealized_pnl()
+pnl_at_expiration()
+validate()
}

class ExpirationDate {
+Days(Positive)
+Date(NaiveDate)
+get_years()
+get_date()
+get_date_string()
+from_string()
}

class Positive {
+value: Decimal
+ZERO: Positive
+ONE: Positive
+format_fixed_places()
+round_to_nice_number()
+is_positive()
}

class OptionStyle {
<<enumeration>>
Call
Put
}

class OptionType {
<<enumeration>>
European
American
}

class Side {
<<enumeration>>
Long
Short
}

class Graph {
<<interface>>
+graph_data()
+graph_config()
+to_plot()
+write_html()
+write_png()
+write_svg()
+write_jpeg()
}

class Greeks {
<<interface>>
+delta()
+gamma()
+theta()
+vega()
+rho()
+calculate_all_greeks()
}

Options --|> Greeks : implements
Options --|> Graph : implements
Position o-- Options : contains
Options *-- OptionStyle : has
Options *-- OptionType : has
Options *-- Side : has
Options *-- ExpirationDate : has
Options *-- Positive : uses
```

### Trading Strategies

OptionStratLib provides 25+ comprehensive trading strategies organized by complexity and market outlook:

#### **Single Leg Strategies**
Basic directional strategies for beginners:
- **Long Call**: Bullish strategy with unlimited upside potential
- **Short Call**: Bearish strategy collecting premium with limited profit
- **Long Put**: Bearish strategy with high profit potential
- **Short Put**: Bullish strategy collecting premium with assignment risk

#### **Spread Strategies**
Defined risk strategies with limited profit/loss:
- **Bull Call Spread**: Moderately bullish with limited risk and reward
- **Bear Call Spread**: Moderately bearish credit spread
- **Bull Put Spread**: Moderately bullish credit spread
- **Bear Put Spread**: Moderately bearish debit spread

#### **Butterfly Strategies**
Market neutral strategies profiting from low volatility:
- **Long Butterfly Spread**: Profits from price staying near middle strike
- **Short Butterfly Spread**: Profits from price moving away from middle strike
- **Call Butterfly**: Butterfly using only call options

#### **Complex Multi-Leg Strategies**
Advanced strategies for experienced traders:
- **Iron Condor**: Market neutral strategy with wide profit zone
- **Iron Butterfly**: Market neutral strategy with narrow profit zone

#### **Volatility Strategies**
Strategies that profit from volatility changes:
- **Long Straddle**: Profits from high volatility in either direction
- **Short Straddle**: Profits from low volatility (range-bound market)
- **Long Strangle**: Similar to straddle but with different strikes
- **Short Strangle**: Credit strategy profiting from low volatility

#### **Income Generation Strategies**
Strategies focused on generating regular income:
- **Covered Call**: Stock ownership with call selling for income
- **Poor Man's Covered Call**: LEAPS-based covered call alternative

#### **Protection Strategies**
Risk management and hedging strategies:
- **Protective Put**: Downside protection for stock positions
- **Collar**: Combination of covered call and protective put

#### **Custom Strategy Framework**
- **Custom Strategy**: Flexible framework for creating any multi-leg strategy
- Supports unlimited number of legs
- Full integration with all analysis tools
- Complete trait implementation for consistency

#### **Strategy Analysis Features**
All strategies include comprehensive analysis capabilities:
- **Profit/Loss Analysis**: P&L at any price point and time
- **Break-Even Points**: Multiple break-even calculations
- **Greeks Analysis**: Real-time risk metrics
- **Probability Analysis**: Success probability calculations
- **Delta Neutrality**: Delta-neutral position analysis
- **Visualization**: Interactive payoff diagrams and risk profiles
- **Optimization**: Find optimal strikes and expirations

#### **Strategy Traits System**
All strategies implement a comprehensive trait system:

- **Strategable**: Master trait combining all strategy capabilities
- **BasicAble**: Basic strategy information (symbol, price, etc.)
- **Positionable**: Position management and modification
- **Strategies**: Core strategy calculations (P&L, break-even, etc.)
- **Validable**: Strategy validation and error checking
- **BreakEvenable**: Break-even point calculations
- **Profit**: Profit/loss analysis at various price points
- **Greeks**: Greeks calculations for risk management
- **DeltaNeutrality**: Delta-neutral analysis and adjustments
- **ProbabilityAnalysis**: Outcome probability calculations
- **Graph**: Visualization and plotting capabilities

### Setup Instructions

#### Prerequisites

- Rust 1.80 or higher (2024 edition)
- Cargo package manager

#### Installation

Add OptionStratLib to your `Cargo.toml`:

```toml
[dependencies]
optionstratlib = "0.6.1"
```

Or use cargo to add it to your project:

```bash
cargo add optionstratlib
```

#### Optional Features

The library includes optional features for enhanced functionality:

```toml
[dependencies]
optionstratlib = { version = "0.6.1", features = ["plotly"] }
```

- `plotly`: Enables interactive visualization using plotly.rs

#### Building from Source

Clone the repository and build using Cargo:

```bash
git clone https://github.com/joaquinbejar/OptionStratLib.git
cd OptionStratLib
cargo build --release
```

Run comprehensive test suite:

```bash
cargo test --all-features
```

Generate documentation:

```bash
cargo doc --open --all-features
```

Run benchmarks:

```bash
cargo bench
```

### Library Usage

#### Basic Option Creation and Pricing

```rust
use optionstratlib::{Options, OptionStyle, OptionType, Side, ExpirationDate};
use optionstratlib::pos;
use rust_decimal_macros::dec;
use optionstratlib::greeks::Greeks;

// Create a European call option
let option = Options::new(
    OptionType::European,
    Side::Long,
    "AAPL".to_string(),
    pos!(150.0),            // strike_price
    ExpirationDate::Days(pos!(30.0)),
    pos!(0.25),             // implied_volatility
    pos!(1.0),              // quantity
    pos!(155.0),            // underlying_price
    dec!(0.05),             // risk_free_rate
    OptionStyle::Call,
    pos!(0.02),             // dividend_yield
    None,                   // exotic_params
);

// Calculate option price using Black-Scholes
let price = option.calculate_price_black_scholes().unwrap();
tracing::info!("Option price: ${:.2}", price);

// Calculate Greeks for risk management
let delta = option.delta().unwrap();
let gamma = option.gamma().unwrap();
let theta = option.theta().unwrap();
let vega = option.vega().unwrap();
tracing::info!("Greeks - Delta: {:.4}, Gamma: {:.4}, Theta: {:.4}, Vega: {:.4}",
         delta, gamma, theta, vega);
```

#### Working with Trading Strategies

```rust
use optionstratlib::{Positive, ExpirationDate, pos};
use optionstratlib::strategies::Strategies;
use optionstratlib::strategies::bull_call_spread::BullCallSpread;
use optionstratlib::strategies::base::{BreakEvenable, BasicAble};
use optionstratlib::visualization::Graph;
use rust_decimal_macros::dec;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    use optionstratlib::pricing::Profit;
let underlying_price = pos!(100.0);

    // Create a Bull Call Spread strategy
    let strategy = BullCallSpread::new(
        "AAPL".to_string(),
        underlying_price,
        pos!(95.0),   // long_strike
        pos!(105.0),  // short_strike
        ExpirationDate::Days(pos!(30.0)),
        pos!(0.25),   // implied_volatility
        dec!(0.05),   // risk_free_rate
        pos!(2.50),   // long_call_premium
        pos!(2.50),   // long_call_open_fee
        pos!(1.20),   // short_call_premium
        pos!(1.20),   // short_call_close_fee
        Default::default(), Default::default(),
        Default::default(), Default::default()
    );

    // Analyze the strategy
    tracing::info!("Strategy: {}", strategy.get_title());
    tracing::info!("Break-even points: {:?}", strategy.get_break_even_points()?);
    tracing::info!("Max profit: ${:.2}", strategy.get_max_profit().unwrap_or(Positive::ZERO));
    tracing::info!("Max loss: ${:.2}", strategy.get_max_loss().unwrap_or(Positive::ZERO));
    tracing::info!("Net premium: ${:.2}", strategy.get_net_premium_received()?);

    // Calculate P&L at different price points
    let prices = vec![pos!(90.0), pos!(95.0), pos!(100.0), pos!(105.0), pos!(110.0)];
    for price in prices {
        let pnl = strategy.get_point_at_price(&price)?;
        tracing::info!("P&L at ${}: ${:.2}", price, pnl.0);
    }

    // Generate visualization
    #[cfg(feature = "plotly")]
    {
        strategy.write_html("Draws/Visualization/bull_call_spread.html".as_ref())?;
    }

    Ok(())
}
```

#### Advanced Features: Volatility Analysis

```rust
use optionstratlib::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create an option for implied volatility calculation
    let mut option = Options::new(
        OptionType::European,
        Side::Long,
        "AAPL".to_string(),
        pos!(105.0), // strike
        ExpirationDate::Days(pos!(90.0)),
        pos!(0.20), // initial IV guess
        pos!(1.0), // quantity
        pos!(100.0), // underlying price
        dec!(0.05), // risk free rate
        OptionStyle::Call,
        pos!(0.02), // dividend yield
        None,
    );

    let market_price = pos!(5.50);
    let iv = implied_volatility(market_price, &mut option, 100)?;

    tracing::info!("Implied volatility: {:.2}%", iv.to_f64() * 100.0);
    Ok(())
}
```

#### Custom Strategy Creation

```rust
use optionstratlib::prelude::*;

// Define common parameters
let underlying_symbol = "DAX".to_string();
let underlying_price = pos!(24000.0);
let expiration = ExpirationDate::Days(pos!(30.0));
let implied_volatility = pos!(0.25);
let risk_free_rate = dec!(0.05);
let dividend_yield = pos!(0.02);
let fee = pos!(2.0);

// Create a long put option
let long_put_option = Options::new(
    OptionType::European,
    Side::Long,
    underlying_symbol.clone(),
    pos!(24070.0), // strike
    expiration.clone(),
    implied_volatility,
    pos!(1.0), // quantity
    underlying_price,
    risk_free_rate,
    OptionStyle::Put,
    dividend_yield,
    None,
);
let long_put = Position::new(
    long_put_option,
    pos!(150.0), // premium
    Utc::now(),
    fee,
    fee,
    None,
    None,
);

// Create a long call option
let long_call_option = Options::new(
    OptionType::European,
    Side::Long,
    underlying_symbol.clone(),
    pos!(24030.0), // strike
    expiration.clone(),
    implied_volatility,
    pos!(1.0), // quantity
    underlying_price,
    risk_free_rate,
    OptionStyle::Call,
    dividend_yield,
    None,
);
let long_call = Position::new(
    long_call_option,
    pos!(120.0), // premium
    Utc::now(),
    fee,
    fee,
    None,
    None,
);

// Create CustomStrategy with the positions
let positions = vec![long_call, long_put];
let strategy = CustomStrategy::new(
    "DAX Straddle Strategy".to_string(),
    underlying_symbol,
    "A DAX long straddle strategy".to_string(),
    underlying_price,
    positions,
    pos!(1.0),
    30,
    implied_volatility,
);

tracing::info!("Strategy created: {}", strategy.get_title());
```

### Testing

OptionStratLib includes a comprehensive test suite with over 1000 unit and integration tests:

#### **Running Tests**

Run all tests:
```bash
cargo test --all-features
```

Run tests for specific modules:
```bash
cargo test strategies::bull_call_spread
cargo test pricing::black_scholes
cargo test volatility::utils
```

Run tests with output:
```bash
cargo test -- --nocapture
```

#### **Test Categories**

- **Unit Tests**: Individual function and method testing
- **Integration Tests**: Cross-module functionality testing
- **Strategy Tests**: Comprehensive strategy validation
- **Pricing Model Tests**: Accuracy and performance testing
- **Greeks Tests**: Mathematical precision validation
- **Visualization Tests**: Chart generation and export testing

#### **Benchmarking**

Run performance benchmarks:
```bash
cargo bench
```

Generate test coverage report:
```bash
cargo tarpaulin --all-features --out Html
```

### Examples

The library includes extensive examples organized by functionality:

- **`examples/examples_strategies/`**: Complete strategy examples (25+ strategies)
- **`examples/examples_chains/`**: Option chain analysis examples
- **`examples/examples_pricing/`**: Pricing model demonstrations
- **`examples/examples_visualization/`**: Interactive chart examples
- **`examples/examples_volatility/`**: Volatility analysis examples
- **`examples/examples_simulation/`**: Monte Carlo and simulation examples

Run examples:
```bash
cargo run --example bull_call_spread --features plotly
cargo run --example black_scholes_pricing
cargo run --example volatility_surface
```

### Contribution and Contact

#### **Contributing**

Contributions are welcome! Please follow these guidelines:

1. **Fork** the repository
2. **Create** a feature branch: `git checkout -b feature/amazing-feature`
3. **Commit** your changes: `git commit -m 'Add amazing feature'`
4. **Push** to the branch: `git push origin feature/amazing-feature`
5. **Open** a Pull Request

#### **Development Setup**

```bash
git clone https://github.com/joaquinbejar/OptionStratLib.git
cd OptionStratLib
cargo build --all-features
cargo test --all-features
```

#### **Code Quality**

- All code must pass `cargo clippy` without warnings
- Format code with `cargo fmt`
- Add tests for new functionality
- Update documentation for API changes
- Follow Rust 2024 edition best practices


#### **Support**

- **Issues**: Report bugs and request features on GitHub
- **Discussions**: Join community discussions on GitHub Discussions
- **Documentation**: Comprehensive docs available at docs.rs

---

**OptionStratLib v0.7.0** - Built with ❤️ in Rust for the financial community




## Contribution and Contact

We welcome contributions to this project! If you would like to contribute, please follow these steps:

1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Make your changes and ensure that the project still builds and all tests pass.
4. Commit your changes and push your branch to your forked repository.
5. Submit a pull request to the main repository.

If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:


### **Contact Information**

- **Author**: Joaquín Béjar García
- **Email**: jb@taunais.com
- **Telegram**: [@joaquin_bejar]https://t.me/joaquin_bejar
- **Repository**: <https://github.com/joaquinbejar/OptionStratLib>
- **Documentation**: <https://docs.rs/optionstratlib>

We appreciate your interest and look forward to your contributions!

## ✍️ License

Licensed under **MIT** license