Skip to main content

PeggedToBenchmark

Struct PeggedToBenchmark 

Source
pub struct PeggedToBenchmark { /* private fields */ }
Expand description

Builder for a pegged-to-benchmark order referencing another contract.

Pegged-to-benchmark orders track the price of a different contract (the reference contract) and adjust automatically as that contract moves. The order is active while the reference price stays inside an optional range and is cancelled if it leaves the range.

action, quantity, and starting_price are required and supplied to PeggedToBenchmark::new. The reference contract (id + exchange) is also required and supplied via reference_contract; build returns Err(ValidationError::MissingRequiredField("reference_contract")) if it was not set. All other fields are optional.

§Examples

use ibapi::orders::{order_builder::PeggedToBenchmark, Action};

let order = PeggedToBenchmark::new(Action::Buy, 100.0, 50.0)
    .reference_contract(12345, "ISLAND")
    .pegged_change_amount(0.02)
    .reference_change_amount(0.01)
    .stock_reference_price(49.0)
    .reference_range(48.0, 52.0)
    .build()
    .expect("reference_contract is set");

assert_eq!(order.order_type, "PEG BENCH");

Implementations§

Source§

impl PeggedToBenchmark

Source

pub fn new( action: Action, quantity: f64, starting_price: f64, ) -> PeggedToBenchmark

Start a new pegged-to-benchmark order with the required core fields.

Source

pub fn reference_contract( self, id: i32, exchange: impl Into<String>, ) -> PeggedToBenchmark

Set the reference contract by id and exchange. Required.

Source

pub fn pegged_change_amount(self, amount: f64) -> PeggedToBenchmark

Set how much this order’s price moves per reference_change_amount of movement in the reference contract.

Source

pub fn pegged_change_amount_decrease(self, decrease: bool) -> PeggedToBenchmark

If true, the order price moves opposite the reference price. Defaults to false.

Source

pub fn reference_change_amount(self, amount: f64) -> PeggedToBenchmark

Set the reference contract price change that triggers a pegged_change_amount adjustment in this order.

Source

pub fn stock_reference_price(self, price: f64) -> PeggedToBenchmark

Set the starting reference price used to compute the pegged offset.

Source

pub fn reference_range(self, lower: f64, upper: f64) -> PeggedToBenchmark

Keep the order active only while the reference contract trades between lower and upper.

Source

pub fn build(self) -> Result<Order, ValidationError>

Build the Order, validating that reference_contract was set.

Trait Implementations§

Source§

impl Clone for PeggedToBenchmark

Source§

fn clone(&self) -> PeggedToBenchmark

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 PeggedToBenchmark

Source§

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

Formats the value using the given formatter. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more