Skip to main content

InstrumentCosts

Struct InstrumentCosts 

Source
pub struct InstrumentCosts {
    pub commission: Option<CommissionModel>,
    pub swap: Option<SwapSchedule>,
}
Expand description

Complete cost specification for one instrument.

Fields§

§commission: Option<CommissionModel>§swap: Option<SwapSchedule>

Implementations§

Source§

impl InstrumentCosts

Source

pub fn is_empty(&self) -> bool

True when this specification can never produce a charge.

Source

pub fn commission_for_fill( &self, side: Side, lots: f64, fill_price: f64, contract_size: f64, ) -> Option<CostCharge>

Signed commission for one fill of lots at fill_price.

contract_size is the number of quote-currency units moved by one full lot and one price unit, matching the multiplier the accounting path already applies to profit and loss.

Source

pub fn swap_for_rollover( &self, side: Side, lots: f64, contract_size: f64, point_size: f64, nights: u32, ) -> Option<CostCharge>

Signed swap for holding lots across nights rollovers.

point_size is one price point for the instrument, normally 10^-digits. It is ignored when the schedule is expressed in account currency.

Source

pub fn validate(&self) -> Result<(), CostValidationError>

Reject non-finite, negative, or out-of-range configuration before a run starts.

Source

pub fn validate_against_account_currency( &self, account_currency: &str, ) -> Result<(), CostValidationError>

Reject account-currency costs that declare a different currency than the run.

Source

pub fn requires_point_size(&self) -> bool

True when a point-denominated swap requires an instrument point size.

Trait Implementations§

Source§

impl Clone for InstrumentCosts

Source§

fn clone(&self) -> InstrumentCosts

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstrumentCosts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for InstrumentCosts

Source§

fn default() -> InstrumentCosts

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for InstrumentCosts

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<InstrumentCosts, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for InstrumentCosts

Source§

fn eq(&self, other: &InstrumentCosts) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for InstrumentCosts

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for InstrumentCosts

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V