pub struct PriceCondition {
pub contract_id: i32,
pub exchange: String,
pub price: f64,
pub trigger_method: TriggerMethod,
pub is_more: bool,
pub is_conjunction: bool,
}Expand description
Price-based condition that activates an order when a contract reaches a specified price.
This condition monitors the price of a specific contract and triggers when the price crosses the specified threshold. The trigger method determines which price feed to use (last, bid/ask, mid-point, etc.).
§TWS Behavior
- The contract must be specified by its contract ID, which can be obtained via
contract_details()API call - Different exchanges may have different price feeds available
- The condition continuously monitors the price during market hours
- When
conditions_ignore_rthis true on the order, monitoring extends to after-hours trading
§Example
use ibapi::orders::conditions::{PriceCondition, TriggerMethod};
use ibapi::orders::OrderCondition;
// Trigger when AAPL (contract ID 265598) goes above $150 on SMART
let condition = PriceCondition::builder(265598, "SMART")
.greater_than(150.0)
.trigger_method(TriggerMethod::Last)
.build();
let order_condition = OrderCondition::Price(condition);Fields§
§contract_id: i32Contract identifier for the instrument to monitor. Use contract_details() to obtain the contract_id for a symbol.
exchange: StringExchange where the price is monitored (e.g., “SMART”, “NASDAQ”, “NYSE”).
price: f64Trigger price threshold.
trigger_method: TriggerMethodMethod for price evaluation.
is_more: boolTrue to trigger when price goes above threshold, false for below.
is_conjunction: boolTrue for AND condition (all conditions must be met), false for OR condition (any condition triggers).
Implementations§
Trait Implementations§
Source§impl Clone for PriceCondition
impl Clone for PriceCondition
Source§fn clone(&self) -> PriceCondition
fn clone(&self) -> PriceCondition
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 ComposeSchema for PriceCondition
impl ComposeSchema for PriceCondition
Source§impl Debug for PriceCondition
impl Debug for PriceCondition
Source§impl Default for PriceCondition
impl Default for PriceCondition
Source§impl<'de> Deserialize<'de> for PriceCondition
impl<'de> Deserialize<'de> for PriceCondition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for PriceCondition
impl PartialEq for PriceCondition
Source§impl Serialize for PriceCondition
impl Serialize for PriceCondition
Source§impl ToSchema for PriceCondition
impl ToSchema for PriceCondition
impl StructuralPartialEq for PriceCondition
Auto Trait Implementations§
impl Freeze for PriceCondition
impl RefUnwindSafe for PriceCondition
impl Send for PriceCondition
impl Sync for PriceCondition
impl Unpin for PriceCondition
impl UnsafeUnpin for PriceCondition
impl UnwindSafe for PriceCondition
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