PositionClient

Struct PositionClient 

Source
pub struct PositionClient { /* private fields */ }

Implementations§

Source§

impl PositionClient

Source

pub fn new(client: RestClient) -> Self

Source

pub async fn get_position_info( &self, category: &str, symbol: Option<&str>, base_coin: Option<&str>, settle_coin: Option<&str>, limit: Option<i32>, cursor: Option<&str>, ) -> Result<ServerResponse<Value>>

Get position info

API: GET /v5/position/list https://bybit-exchange.github.io/docs/v5/position

Source

pub async fn set_leverage( &self, category: &str, symbol: &str, buy_leverage: &str, sell_leverage: &str, ) -> Result<ServerResponse<Value>>

Set leverage

API: POST /v5/position/set-leverage https://bybit-exchange.github.io/docs/v5/position/set-leverage

Source

pub async fn switch_margin_mode( &self, category: &str, symbol: &str, trade_mode: i32, buy_leverage: &str, sell_leverage: &str, ) -> Result<ServerResponse<Value>>

Switch between cross/isolated margin

API: POST /v5/position/switch-isolated https://bybit-exchange.github.io/docs/v5/position/switch-isolated

Source

pub async fn switch_position_mode( &self, category: &str, mode: i32, symbol: Option<&str>, coin: Option<&str>, ) -> Result<ServerResponse<Value>>

Switch position mode

API: POST /v5/position/switch-mode https://bybit-exchange.github.io/docs/v5/position/switch-mode

Source

pub async fn set_trading_stop( &self, category: &str, symbol: &str, position_idx: i32, take_profit: Option<&str>, stop_loss: Option<&str>, trailing_stop: Option<&str>, tp_trigger_by: Option<&str>, sl_trigger_by: Option<&str>, active_price: Option<&str>, tp_size: Option<&str>, sl_size: Option<&str>, tp_limit_price: Option<&str>, sl_limit_price: Option<&str>, tp_order_type: Option<&str>, sl_order_type: Option<&str>, ) -> Result<ServerResponse<Value>>

Set Trading Stop (Take profit/Stop loss)

API: POST /v5/position/trading-stop https://bybit-exchange.github.io/docs/v5/position/trading-stop

Source

pub async fn set_auto_add_margin( &self, category: &str, symbol: &str, auto_add_margin: i32, position_idx: Option<i32>, ) -> Result<ServerResponse<Value>>

Set auto add margin

API: POST /v5/position/set-auto-add-margin https://bybit-exchange.github.io/docs/v5/position/set-auto-add-margin

Source

pub async fn get_closed_pnl( &self, category: &str, symbol: Option<&str>, start_time: Option<i64>, end_time: Option<i64>, limit: Option<i32>, cursor: Option<&str>, ) -> Result<ServerResponse<Value>>

Get closed PnL

API: GET /v5/position/closed-pnl https://bybit-exchange.github.io/docs/v5/position/closed-pnl

Source

pub async fn set_tpsl_mode( &self, category: &str, symbol: &str, tp_sl_mode: &str, ) -> Result<ServerResponse<Value>>

Set TP/SL mode

API: POST /v5/position/set-tpsl-mode https://bybit-exchange.github.io/docs/v5/position/set-tpsl-mode

Source

pub async fn set_risk_limit( &self, category: &str, symbol: &str, risk_id: i32, position_idx: Option<i32>, ) -> Result<ServerResponse<Value>>

Set risk limit

API: POST /v5/position/set-risk-limit https://bybit-exchange.github.io/docs/v5/position/set-risk-limit

Source

pub async fn move_positions( &self, from_uid: &str, to_uid: &str, list: Vec<Value>, ) -> Result<ServerResponse<Value>>

Move positions

API: POST /v5/position/move-positions https://bybit-exchange.github.io/docs/v5/position/move-positions

Source

pub async fn get_move_position_history( &self, category: Option<&str>, symbol: Option<&str>, start_time: Option<i64>, end_time: Option<i64>, status: Option<&str>, block_trade_id: Option<&str>, limit: Option<i32>, cursor: Option<&str>, ) -> Result<ServerResponse<Value>>

Get move position history

API: GET /v5/position/move-history https://bybit-exchange.github.io/docs/v5/position/move-history

Source

pub async fn confirm_new_risk_limit( &self, category: &str, symbol: &str, ) -> Result<ServerResponse<Value>>

Confirm new risk limit

API: POST /v5/position/confirm-pending-mmr https://bybit-exchange.github.io/docs/v5/position/confirm-pending-mmr

Source

pub async fn update_margin( &self, category: &str, symbol: &str, margin: &str, position_idx: Option<i32>, ) -> Result<ServerResponse<Value>>

Add/Reduce margin

API: POST /v5/position/add-margin https://bybit-exchange.github.io/docs/v5/position/manual-add-margin

Source

pub async fn get_execution( &self, category: &str, symbol: Option<&str>, order_id: Option<&str>, order_link_id: Option<&str>, base_coin: Option<&str>, start_time: Option<i64>, end_time: Option<i64>, exec_type: Option<&str>, limit: Option<i32>, cursor: Option<&str>, ) -> Result<ServerResponse<Value>>

Get execution

API: GET /v5/execution/list https://bybit-exchange.github.io/docs/v5/position/execution

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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