pub struct AddReduceMarginRequest<'a> {
pub category: Category,
pub symbol: Cow<'a, str>,
pub margin: f64,
pub position_idx: Option<i32>,
}Expand description
Parameters for manually adding or reducing margin for a position.
Used to construct a request to the /v5/position/add-margin endpoint to manually adjust the margin allocated to a specific position. Bots use this to increase margin to avoid liquidation or reduce margin to free up capital in perpetual futures trading.
Fields§
§category: CategoryThe product category (e.g., Linear, Inverse).
Specifies the instrument type. Bots must set this to target the correct contract type.
symbol: Cow<'a, str>The trading pair symbol (e.g., “BTCUSDT”).
Identifies the perpetual futures contract for which margin is being adjusted. Bots must specify a valid symbol.
margin: f64The margin amount to add (positive) or reduce (negative).
A positive value adds margin to the position, reducing liquidation risk. A negative value reduces margin, freeing up capital but increasing risk. Bots should calculate this based on position size and margin requirements.
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. If unset, applies to the default position.
Implementations§
Source§impl<'a> AddReduceMarginRequest<'a>
impl<'a> AddReduceMarginRequest<'a>
Sourcepub fn new(
category: Category,
symbol: &'a str,
margin: f64,
position_idx: Option<i32>,
) -> Self
pub fn new( category: Category, symbol: &'a str, margin: f64, position_idx: Option<i32>, ) -> Self
Constructs a new AddReduceMargin request with specified parameters.
Allows customization of the margin adjustment request. Bots should use this to specify the exact symbol, category, margin amount, and position index.
Sourcepub fn default() -> AddReduceMarginRequest<'a>
pub fn default() -> AddReduceMarginRequest<'a>
Creates a default AddReduceMargin request.
Returns a request with category set to Linear, symbol set to "BTCUSDT", margin set to 1.0, and no position index. Suitable for testing but should be customized for production.
Trait Implementations§
Source§impl<'a> Clone for AddReduceMarginRequest<'a>
impl<'a> Clone for AddReduceMarginRequest<'a>
Source§fn clone(&self) -> AddReduceMarginRequest<'a>
fn clone(&self) -> AddReduceMarginRequest<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more