Struct bybit::position::PositionManager

source ·
pub struct PositionManager {
    pub client: Client,
    pub recv_window: u64,
}

Fields§

§client: Client§recv_window: u64

Implementations§

source§

impl PositionManager

source

pub async fn get_info<'a>( &self, req: PositionRequest<'a>, ) -> Result<InfoResponse, BybitError>

Asynchronously retrieves information about a position based on the provided request.

§Arguments
  • req - The position request containing the category, symbol, base coin, settle coin, and limit.
§Returns

A Result containing a vector of PositionInfo if the operation is successful, or an error if it fails.

§Example
use crate::model::{PositionRequest, Category};
use crate::errors::Result;
use crate::api::PositionInfo;
use my_module::PositionManager;

#[tokio::main]
async fn main() -> Result<()> {
    let position_manager = PositionManager::new();
    let request = PositionRequest::new(Category::Linear, Some("symbol"), Some("base_coin"), Some("settle_coin"), Some(10));
    let position_info = position_manager.get_info(request).await?;
    Ok(())
}
source

pub async fn set_leverage<'a>( &self, req: LeverageRequest<'a>, ) -> Result<LeverageResponse, BybitError>

§Arguments
  • req - The leverage request containing category, symbol, and leverage.
§Returns

A result containing the leverage response.

source

pub async fn set_margin_mode<'a>( &self, req: ChangeMarginRequest<'a>, ) -> Result<ChangeMarginResponse, BybitError>

Set the margin mode.

§Arguments
  • req - The ChangeMarginRequest containing the necessary information.
§Returns
  • Result - The result of setting the margin mode.
source

pub async fn set_position_mode<'a>( &self, req: MarginModeRequest<'a>, ) -> Result<MarginModeResponse, BybitError>

Set the position mode.

§Arguments
  • req - The MarginModeRequest containing the necessary information.
§Returns
  • Result - The result of setting the position mode.
source

pub async fn set_risk_limit<'a>( &self, req: SetRiskLimit<'a>, ) -> Result<SetRiskLimitResponse, BybitError>

Set the risk limit.

§Arguments
  • req - The SetRiskLimitRequest containing the necessary information.
§Returns
  • Result - The result of setting the risk limit.
source

pub async fn set_trading_stop<'a>( &self, req: TradingStopRequest<'a>, ) -> Result<TradingStopResponse, BybitError>

Set the trading stop.

§Arguments
  • req - The TradingStopRequest containing the necessary information.
§Returns
  • Result - The result of setting the trading stop.
source

pub async fn set_add_margin<'a>( &self, req: AddMarginRequest<'a>, ) -> Result<AddMarginResponse, BybitError>

source

pub async fn add_or_reduce_margin<'a>( &self, req: AddReduceMarginRequest<'a>, ) -> Result<AddReduceMarginResponse, BybitError>

source

pub async fn get_closed_pnl<'a>( &self, req: ClosedPnlRequest<'a>, ) -> Result<ClosedPnlResponse, BybitError>

source

pub async fn move_position<'a>( &self, req: MovePositionRequest<'a>, ) -> Result<MovePositionResponse, BybitError>

source

pub async fn move_position_history<'a>( &self, req: MoveHistoryRequest<'a>, ) -> Result<MoveHistoryResponse, BybitError>

Trait Implementations§

source§

impl Bybit for PositionManager

source§

fn new(api_key: Option<String>, secret_key: Option<String>) -> PositionManager

source§

fn new_with_config( config: &Config, api_key: Option<String>, secret_key: Option<String>, ) -> PositionManager

source§

impl Clone for PositionManager

source§

fn clone(&self) -> PositionManager

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T