pub struct MarginCondition {
pub percent: i32,
pub is_more: bool,
pub is_conjunction: bool,
}Expand description
Margin cushion condition that activates an order based on account margin levels.
The margin cushion is a measure of account health, calculated as: (Equity with Loan Value - Maintenance Margin) / Net Liquidation Value
This condition monitors your account’s margin cushion and triggers when it crosses the specified percentage threshold. Useful for risk management and protecting against margin calls.
§TWS Behavior
- Margin cushion is updated in real-time as positions and prices change
- The percentage is specified as an integer (e.g., 30 for 30%)
- Only applies to margin accounts; cash accounts will not trigger this condition
- Common use: Submit protective orders when margin cushion falls below safe levels
§Example
use ibapi::orders::conditions::MarginCondition;
use ibapi::orders::OrderCondition;
// Trigger when margin cushion falls below 30%
let condition = MarginCondition::builder()
.less_than(30)
.build();
let order_condition = OrderCondition::Margin(condition);Fields§
§percent: i32Margin cushion percentage threshold (0-100). Example: 30 represents 30% margin cushion.
is_more: boolTrue to trigger when margin cushion 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§
Source§impl MarginCondition
impl MarginCondition
Sourcepub fn builder() -> MarginConditionBuilder
pub fn builder() -> MarginConditionBuilder
Create a builder for a margin cushion condition.
Trait Implementations§
Source§impl Clone for MarginCondition
impl Clone for MarginCondition
Source§fn clone(&self) -> MarginCondition
fn clone(&self) -> MarginCondition
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 MarginCondition
impl Debug for MarginCondition
Source§impl Default for MarginCondition
impl Default for MarginCondition
Source§fn default() -> MarginCondition
fn default() -> MarginCondition
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MarginCondition
impl<'de> Deserialize<'de> for MarginCondition
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 MarginCondition
impl PartialEq for MarginCondition
Source§impl Serialize for MarginCondition
impl Serialize for MarginCondition
impl StructuralPartialEq for MarginCondition
Auto Trait Implementations§
impl Freeze for MarginCondition
impl RefUnwindSafe for MarginCondition
impl Send for MarginCondition
impl Sync for MarginCondition
impl Unpin for MarginCondition
impl UnwindSafe for MarginCondition
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