pub struct BullSpread { /* private fields */ }Expand description
Bull spread option payoff and profit.
Bull Spread = Long Call + Short Call
Implementations§
Source§impl BullSpread
impl BullSpread
Trait Implementations§
Source§impl Clone for BullSpread
impl Clone for BullSpread
Source§fn clone(&self) -> BullSpread
fn clone(&self) -> BullSpread
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BullSpread
impl Debug for BullSpread
Source§impl ErrorTitle for BullSpread
impl ErrorTitle for BullSpread
Source§fn error_title() -> String
fn error_title() -> String
Returns the error title.
Source§impl Payoff for BullSpread
impl Payoff for BullSpread
Source§fn payoff(&self, s: f64) -> f64
fn payoff(&self, s: f64) -> f64
Bull spread option payoff.
§Input
s: Underlying asset price
§Output
- Payoff of the bull spread option
§LaTeX Formula
- \textit{Bull Spread Payoff} = max(S_{t}-K_{l}, 0) + min(K_{s}-S_{t}, 0)
§Examples
use ndarray::{Array1, array};
use digifi::utilities::TEST_ACCURACY;
use digifi::financial_instruments::{Payoff, BullSpread};
let s: Array1<f64> = Array1::from_vec(vec![3.0, 4.0, 5.0, 6.0, 7.0]);
let bull_spread: BullSpread = BullSpread::build(4.0, 6.0, 1.0).unwrap();
assert!((bull_spread.payoff_iter(&s) - Array1::from_vec(vec![0.0, 0.0, 1.0, 2.0, 2.0])).map(|v| v.abs() ).sum() < TEST_ACCURACY);Source§fn update_cost(&mut self, new_cost: f64)
fn update_cost(&mut self, new_cost: f64)
Updates the cost/premium of the instrument. Read more
Source§fn payoff_iter(&self, s: &Array1<f64>) -> Array1<f64>
fn payoff_iter(&self, s: &Array1<f64>) -> Array1<f64>
Payoff function applied to the array of values.
Source§fn validate_payoff(&self, val_length: usize) -> Result<(), DigiFiError>
fn validate_payoff(&self, val_length: usize) -> Result<(), DigiFiError>
Validation of payoff object to satisfy the computational requirements. Read more
impl Copy for BullSpread
Auto Trait Implementations§
impl Freeze for BullSpread
impl RefUnwindSafe for BullSpread
impl Send for BullSpread
impl Sync for BullSpread
impl Unpin for BullSpread
impl UnsafeUnpin for BullSpread
impl UnwindSafe for BullSpread
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PayoffClone for T
impl<T> PayoffClone for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.