Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "optionstratlib"
version = "0.15.3"
version = "0.16.0"
edition = "2024"
authors = ["Joaquin Bejar <jb@taunais.com>"]
description = "OptionStratLib is a comprehensive Rust library for options trading and strategy development across multiple asset classes."
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[![Wiki](https://img.shields.io/badge/wiki-latest-blue.svg)](https://deepwiki.com/joaquinbejar/OptionStratLib)


## OptionStratLib v0.15.3: Financial Options Library
## OptionStratLib v0.16.0: Financial Options Library

### Table of Contents
1. [Introduction](#introduction)
Expand Down Expand Up @@ -677,7 +677,7 @@ Add OptionStratLib to your `Cargo.toml`:

```toml
[dependencies]
optionstratlib = "0.15.3"
optionstratlib = "0.16.0"
```

Or use cargo to add it to your project:
Expand All @@ -692,7 +692,7 @@ The library includes optional features for enhanced functionality:

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

- `plotly`: Enables interactive visualization using plotly.rs
Expand Down Expand Up @@ -1042,7 +1042,7 @@ cargo test --all-features

---

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



Expand Down
4 changes: 4 additions & 0 deletions benches/model/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn create_long_call() -> LongCall {
pos_or_panic!(0.5), // open_fee_long_call
pos_or_panic!(0.5), // close_fee_long_call
)
.unwrap()
}

fn create_bull_call_spread() -> BullCallSpread {
Expand All @@ -49,6 +50,7 @@ fn create_bull_call_spread() -> BullCallSpread {
pos_or_panic!(0.5), // open_fee_short_call
pos_or_panic!(0.5), // close_fee_short_call
)
.unwrap()
}

fn create_iron_condor() -> IronCondor {
Expand All @@ -71,6 +73,7 @@ fn create_iron_condor() -> IronCondor {
pos_or_panic!(0.5), // open_fee
pos_or_panic!(0.5), // close_fee
)
.unwrap()
}

fn create_iron_butterfly() -> IronButterfly {
Expand All @@ -92,6 +95,7 @@ fn create_iron_butterfly() -> IronButterfly {
pos_or_panic!(0.5), // open_fee
pos_or_panic!(0.5), // close_fee
)
.unwrap()
}

pub(crate) fn benchmark_strategies(c: &mut Criterion) {
Expand Down
2 changes: 1 addition & 1 deletion examples/examples_chain/src/bin/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> Result<(), optionstratlib::error::Error> {
pos_or_panic!(0.1), // close_fee_short_call
pos_or_panic!(0.1), // open_fee_short_put
pos_or_panic!(0.1), // close_fee_short_put
);
)?;
let max_delta = dec!(0.3);
let min_delta = dec!(0.15);
strategy.get_best_area(
Expand Down
2 changes: 1 addition & 1 deletion examples/examples_chain/src/bin/option_chain_ger40.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() -> Result<(), optionstratlib::error::Error> {
pos_or_panic!(0.10), // close_fee_short_call
pos_or_panic!(0.10), // open_fee_short_put
pos_or_panic!(0.10), // close_fee_short_put
);
)?;
strategy.get_best_ratio(
&option_chain,
FindOptimalSide::DeltaRange(dec!(-0.3), dec!(0.3)),
Expand Down
2 changes: 1 addition & 1 deletion examples/examples_chain/src/bin/option_chain_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() -> Result<(), optionstratlib::error::Error> {
pos_or_panic!(2.2), // close_fee_short_call
pos_or_panic!(1.7), // open_fee_short_put
pos_or_panic!(1.7), // close_fee_short_put
);
)?;

// strategy.best_area(&option_chain, FindOptimalSide::Range(pos_or_panic!(21600.0), pos_or_panic!(21700.0) ));
strategy.get_best_area(&option_chain, FindOptimalSide::Upper);
Expand Down
2 changes: 1 addition & 1 deletion examples/examples_chain/src/bin/option_chain_raw_delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() -> Result<(), optionstratlib::error::Error> {
pos_or_panic!(2.2), // close_fee_short_call
pos_or_panic!(1.7), // open_fee_short_put
pos_or_panic!(1.7), // close_fee_short_put
);
)?;

strategy.get_best_area(
&option_chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn main() -> Result<(), Error> {
premium_positive, // premium paid
Positive::ZERO, // open_fee
Positive::ZERO, // close_fee
);
)?;

// Define exit policy: 100% profit OR expiration
let exit_policy = ExitPolicy::Or(vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn main() -> Result<(), Error> {
premium_positive, // premium received
pos_or_panic!(1.5), // open_fee
pos_or_panic!(1.5), // close_fee
);
)?;

// Define exit policy: 50% profit OR 100% loss
let exit_policy = ExitPolicy::profit_or_loss(dec!(0.7), dec!(0.6));
Expand Down
2 changes: 1 addition & 1 deletion examples/examples_simulation/src/bin/strategy_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() -> Result<(), Error> {
open_premium,
Positive::ZERO,
Positive::ZERO,
);
)?;

let walk_params = WalkParams {
size: n_steps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.78), // open_fee_long
pos_or_panic!(0.73), // close_fee_long
pos_or_panic!(0.73), // close_fee_short
);
)?;
info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
info!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.78), // open_fee_long
pos_or_panic!(0.73), // close_fee_long
pos_or_panic!(0.73), // close_fee_short
);
)?;
info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
info!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.78), // open_fee_long
pos_or_panic!(0.73), // close_fee_long
pos_or_panic!(0.73), // close_fee_short
);
)?;
info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
info!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.78), // open_fee_long
pos_or_panic!(0.73), // close_fee_long
pos_or_panic!(0.73), // close_fee_short
);
)?;

info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.73), // close_fee_short
pos_or_panic!(0.73), // close_fee_short
pos_or_panic!(0.72), // open_fee_short
);
)?;
let range = strategy.get_range_of_profit().unwrap_or(Positive::ZERO);

info!("Title: {}", strategy.get_title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn main() -> Result<(), Error> {
Default::default(),
100,
Default::default(),
);
)?;

// Display strategy information
info!("=== CUSTOM COMPLEX STRATEGY ===");
Expand Down
3 changes: 2 additions & 1 deletion examples/examples_strategies/src/bin/strategy_custom_dax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ fn main() {
Positive::ONE, // Default quantity
1, // days to expiration
implied_volatility,
);
)
.unwrap();

// Fees are already set in Position::new() above

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn main() -> Result<(), Error> {
Default::default(),
100,
Default::default(),
);
)?;

// Calculate range between break-even points (if we have at least 2)
let range = if strategy.break_even_points.len() >= 2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn main() -> Result<(), Error> {
Default::default(),
50, // Fewer calculation points for simplicity
Default::default(),
);
)?;

// Display strategy information
info!("=== CUSTOM COVERED CALL STRATEGY ===");
Expand Down
2 changes: 1 addition & 1 deletion examples/examples_strategies/src/bin/strategy_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.58),
pos_or_panic!(0.55),
pos_or_panic!(0.54),
);
)?;

info!("Title: {}", strategy.get_title());
info!("Break Even {:?}", strategy.get_break_even_points());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(16.8), // premium_long_put
pos_or_panic!(0.96), // open_fee
pos_or_panic!(0.96), // close_fee
);
)?;
if !strategy.validate() {
return Err("Invalid strategy".into());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(30.7), // premium_long_put
pos_or_panic!(0.1), // open_fee
pos_or_panic!(0.1), // close_fee
);
)?;
if !strategy.validate() {
return Err("Invalid strategy".into());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.05), // close_fee_long_call_low
pos_or_panic!(0.05), // open_fee_long_call_high
pos_or_panic!(0.05), // close_fee_long_call_high
);
)?;

info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(7.01), // close_fee_short_call
pos_or_panic!(7.01), // open_fee_short_put
pos_or_panic!(7.01), // close_fee_short_put
);
)?;
let range = strategy.break_even_points[1] - strategy.break_even_points[0];

info!("Title: {}", strategy.get_title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(7.01), // close_fee_short_call
pos_or_panic!(7.01), // open_fee_short_put
pos_or_panic!(7.01), // close_fee_short_put
);
)?;
let range = strategy.break_even_points[1] - strategy.break_even_points[0];

info!("Title: {}", strategy.get_title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(1.74), // close_fee_short_call
pos_or_panic!(0.85), // open_fee_short_put
pos_or_panic!(0.85), // close_fee_short_put
);
)?;

info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.05),
pos_or_panic!(0.05),
pos_or_panic!(0.05),
);
)?;

info!("Title: {}", strategy.get_title());
info!("Break Even Points: {:?}", strategy.break_even_points);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(7.01), // close_fee_short_call
pos_or_panic!(7.01), // open_fee_short_put
pos_or_panic!(7.01), // close_fee_short_put
);
)?;
let range = strategy.break_even_points[1] - strategy.break_even_points[0];

info!("Title: {}", strategy.get_title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(7.01), // close_fee_short_call
pos_or_panic!(7.01), // open_fee_short_put
pos_or_panic!(7.01), // close_fee_short_put
);
)?;
let range = strategy.break_even_points[1] - strategy.break_even_points[0];

info!("Title: {}", strategy.get_title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(7.01), // close_fee_short_call
pos_or_panic!(7.01), // open_fee_short_put
pos_or_panic!(7.01), // close_fee_short_put
);
)?;

let range = strategy.get_range_of_profit().unwrap_or(Positive::ZERO);
info!("Title: {}", strategy.get_title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_area(&option_chain, FindOptimalSide::Center);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_ratio(&option_chain, FindOptimalSide::Upper);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_area(&option_chain, FindOptimalSide::Center);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_ratio(&option_chain, FindOptimalSide::Upper);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_area(&option_chain, FindOptimalSide::Center);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_ratio(&option_chain, FindOptimalSide::All);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.81), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_area(&option_chain, FindOptimalSide::Center);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> Result<(), Error> {
pos_or_panic!(0.82), // close_fee_short_call
pos_or_panic!(0.82), // open_fee_short_put
pos_or_panic!(0.82), // close_fee_short_put
);
)?;
strategy.get_best_area(&option_chain, FindOptimalSide::Lower);
debug!("Option Chain: {}", option_chain);
debug!("Strategy: {:#?}", strategy);
Expand Down
Loading
Loading