pub struct AddMarginRequest<'a> {
pub category: Category,
pub symbol: Cow<'a, str>,
pub auto_add: bool,
pub position_idx: Option<i32>,
}Expand description
Parameters for enabling or disabling auto-add margin for a position.
Used to construct a request to the /v5/position/set-auto-add-margin endpoint to enable or disable automatic margin addition for a specific position. Bots use this to control margin behavior, preventing unwanted margin calls or optimizing capital allocation in perpetual futures.
Fields§
§category: CategoryThe product category (e.g., Linear, Inverse).
Specifies the instrument type. Bots must set this to target the correct contract type, such as Linear for USDT-margined perpetuals.
symbol: Cow<'a, str>The trading pair symbol (e.g., “BTCUSDT”).
Identifies the perpetual futures contract for which auto-add margin is being configured. Bots must specify a valid symbol.
auto_add: boolWhether to enable auto-add margin.
If true, Bybit will automatically add margin to prevent liquidation when margin levels are low. If false, no automatic margin addition occurs, increasing liquidation risk. Bots should set this based on their risk tolerance and capital management strategy.
position_idx: Option<i32>The position index (optional, e.g., 0 for one-way mode, 1 or 2 for hedge mode).
Specifies the position type. Bots should set this for hedge mode positions to target the correct side (e.g., long or short). If unset, applies to the default position.
Implementations§
Source§impl<'a> AddMarginRequest<'a>
impl<'a> AddMarginRequest<'a>
Sourcepub fn new(
category: Category,
symbol: &'a str,
auto_add: bool,
position_idx: Option<i32>,
) -> Self
pub fn new( category: Category, symbol: &'a str, auto_add: bool, position_idx: Option<i32>, ) -> Self
Constructs a new AddMargin request with specified parameters.
Allows customization of the auto-add margin request. Bots should use this to specify the exact symbol, category, and auto-add setting to align with their margin management strategy.
Sourcepub fn default() -> AddMarginRequest<'a>
pub fn default() -> AddMarginRequest<'a>
Creates a default AddMargin request.
Returns a request with category set to Linear, symbol set to "BTCUSDT", auto_add set to false, and no position index. Suitable for testing but should be customized for production.
Trait Implementations§
Source§impl<'a> Clone for AddMarginRequest<'a>
impl<'a> Clone for AddMarginRequest<'a>
Source§fn clone(&self) -> AddMarginRequest<'a>
fn clone(&self) -> AddMarginRequest<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more