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
120 changes: 94 additions & 26 deletions src/chains/chain.rs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/curves/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 9/1/25
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::curves::Point2D;
use crate::curves::traits::StatisticalCurve;
use crate::curves::utils::detect_peaks_and_valleys;
Expand Down
6 changes: 6 additions & 0 deletions src/curves/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 23/2/25
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::curves::{Curve, Point2D};
use crate::error::{CurveError, OperationErrorKind};
use crate::geometrics::{BasicMetrics, MetricsExtractor, RangeMetrics, ShapeMetrics, TrendMetrics};
Expand Down
6 changes: 6 additions & 0 deletions src/curves/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 9/1/25
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::curves::{Curve, Point2D};
use crate::geometrics::GeometricObject;
use rust_decimal::Decimal;
Expand Down
6 changes: 6 additions & 0 deletions src/geometrics/interpolation/traits.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::error::InterpolationError;
use crate::geometrics::{
BiLinearInterpolation, CubicInterpolation, GeometricObject, InterpolationType,
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#![allow(unknown_lints)]
#![allow(clippy::literal_string_with_formatting_args)]
// Per rules/global_rules.md §Error Handling, unchecked `[]` / slicing is
// banned in production code. Enforced crate-wide; individual modules that
// need a transitional escape hatch carry a scoped `#![allow(..)]` with a
// migration note (tracked as follow-ups to #341).
#![deny(clippy::indexing_slicing)]
// Unit and integration tests routinely index into `Vec`s they just pushed
// into, so the lint is silenced in `#[cfg(test)]` only.
#![cfg_attr(test, allow(clippy::indexing_slicing))]

//! # OptionStratLib v0.16.0: Financial Options Library
//!
Expand Down
10 changes: 3 additions & 7 deletions src/model/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,9 @@ impl Iterator for BasicAxisTypesIter {
type Item = BasicAxisTypes;

fn next(&mut self) -> Option<Self::Item> {
if self.index < BasicAxisTypes::VALUES.len() {
let value = BasicAxisTypes::VALUES[self.index];
self.index += 1;
Some(value)
} else {
None
}
let value = *BasicAxisTypes::VALUES.get(self.index)?;
self.index += 1;
Some(value)
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/model/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,16 @@ impl Options {
side: &self.side,
};
let (asset_tree, option_tree) = generate_binomial_tree(&params)?;
let root = option_tree
.first()
.and_then(|row| row.first())
.copied()
.ok_or(PricingError::BinomialNodeMissing {
node: "option[0][0]",
})?;
let price = match self.side {
Side::Long => option_tree[0][0],
Side::Short => -option_tree[0][0],
Side::Long => root,
Side::Short => -root,
};
Ok((price, asset_tree, option_tree))
}
Expand Down
6 changes: 6 additions & 0 deletions src/pricing/binomial_model.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::error::PricingError;
use crate::model::types::{OptionStyle, OptionType, Side};
use crate::pricing::payoff::{Payoff, PayoffInfo};
Expand Down
6 changes: 6 additions & 0 deletions src/pricing/cliquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
Date: 13/01/26
******************************************************************************/

// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

//! Cliquet option pricing module.
//!
//! Cliquet options (also known as ratchet options) consist of a series of
Expand Down
6 changes: 6 additions & 0 deletions src/pricing/compound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
Date: 13/01/26
******************************************************************************/

// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

//! Compound option pricing module.
//!
//! Compound options are options on options (also called split-fee options).
Expand Down
6 changes: 6 additions & 0 deletions src/pricing/telegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 19/8/24
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

//! # Telegraph Process
//!
//! A Telegraph Process (also known as a two-state process) is a stochastic process
Expand Down
6 changes: 6 additions & 0 deletions src/pricing/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 5/8/24
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::Options;
use crate::error::PricingError;
use crate::error::decimal::DecimalError;
Expand Down
6 changes: 6 additions & 0 deletions src/simulation/randomwalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
Date: 23/3/25
******************************************************************************/

// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::error::PricingError;
use crate::pricing::Profit;
use crate::simulation::WalkParams;
Expand Down
6 changes: 6 additions & 0 deletions src/simulation/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::Options;
use crate::error::PricingError;
use crate::pricing::Profit;
Expand Down
6 changes: 6 additions & 0 deletions src/simulation/traits.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::backtesting::results::SimulationStatsResult;
use crate::error::SimulationError;
use crate::model::decimal::{decimal_normal_sample, finite_decimal};
Expand Down
4 changes: 4 additions & 0 deletions src/strategies/base.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341.
#![allow(clippy::indexing_slicing)]

use crate::chains::OptionData;
use crate::constants::{STRIKE_PRICE_LOWER_BOUND_MULTIPLIER, STRIKE_PRICE_UPPER_BOUND_MULTIPLIER};
use crate::error::strategies::BreakEvenErrorKind;
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/bear_call_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Key characteristics:
- Also known as a vertical call credit spread
*/

// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/bear_put_spread.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use positive::Positive;
#[cfg(test)]
use positive::pos_or_panic;
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/bull_call_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Key characteristics:
- Maximum profit achieved when price rises above higher strike
- Also known as a vertical call debit spread
*/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/bull_put_spread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Key characteristics:
- Maximum profit achieved when price stays above higher strike
- Also known as a vertical put credit spread
*/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/call_butterfly.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 2/10/24
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/delta_neutral/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Email: jb@taunais.com
Date: 10/12/24
******************************************************************************/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::adjustment::{AdjustmentConfig, AdjustmentPlan};
use super::optimizer::AdjustmentOptimizer;
use super::portfolio::{AdjustmentTarget, PortfolioGreeks};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/delta_neutral/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
Date: 24/12/25
******************************************************************************/

// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

//! # Adjustment Optimizer Module
//!
//! Provides optimization algorithms for finding the best adjustment plan
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/graph.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use crate::pricing::Profit;
use crate::strategies::base::BreakEvenable;
use crate::strategies::{
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/iron_butterfly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Key characteristics:
- High probability of small profit
- Requires very low volatility
*/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/iron_condor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Key characteristics:
- Limited risk
- Profit is highest when the underlying asset price remains between the two sold options at expiration
*/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/long_butterfly_spread.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/long_call.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{BreakEvenable, Positionable, StrategyType};
use crate::backtesting::results::{SimulationResult, SimulationStatsResult};
use crate::chains::OptionChain;
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/long_put.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{BreakEvenable, Positionable, StrategyType};
use crate::backtesting::results::{SimulationResult, SimulationStatsResult};

Expand Down
6 changes: 6 additions & 0 deletions src/strategies/long_straddle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Key characteristics:
- High cost due to purchasing both a call and a put
- Profitable only with a large move in either direction
*/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
6 changes: 6 additions & 0 deletions src/strategies/long_strangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Key characteristics:
- Lower cost than a straddle
- Requires a larger price move to become profitable
*/
// Scoped allow: bulk migration of unchecked `[]` indexing to
// `.get().ok_or_else(..)` tracked as follow-ups to #341. The existing
// call sites are internal to this file and audited for invariant-bound
// indices (fixed-length buffers, just-pushed slices, etc.).
#![allow(clippy::indexing_slicing)]

use super::base::{
BreakEvenable, Optimizable, Positionable, Strategable, StrategyBasics, StrategyType, Validable,
};
Expand Down
Loading
Loading