Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Shareable OANDA v20 client.

Implementations§

Source§

impl Client

Source§

impl Client

Source

pub async fn account_details( &self, account_id: &AccountID, ) -> Result<ApiResponse<AccountDetailsResponse>, OperationError<GenericRejection>>

Account details.

Source§

impl Client

Source

pub async fn account_summary( &self, account_id: &AccountID, ) -> Result<ApiResponse<AccountSummaryResponse>, OperationError<GenericRejection>>

Account summary.

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub fn set_exit_reserve(&self, requests: u32) -> Result<()>

Replace the shared request reserve for cancellation and position or trade closes.

Zero releases the reserve. All clients sharing this admission owner observe the replacement; waiting reads reconsider it immediately. One caller coordinator should own this policy. Changes preserve spent capacity, provider cooldowns and already admitted requests. Exit capacity is finite.

§Errors

Returns Error::InvalidInput when requests is at least 120 or the rate lock is poisoned. Invalid changes preserve the policy and admission state.

Source

pub fn builder( environment: Environment, bearer_token: impl Into<String>, ) -> ClientBuilder

Start building a client with an injected personal access token.

Source

pub fn acknowledge_reconciliation(&self, account: &AccountID) -> Result<()>

Allow mutations after the caller has reconciled this account against OANDA state.

This is an acknowledgement by the caller, not a state query performed by the client.

§Errors

Returns an error when the shared fence set cannot be locked. The account then stays fenced, so its remaining mutations are refused until a client that can lock succeeds.

Source

pub async fn fetch_page<T: DeserializeOwned>( &self, next_page: &Url, ) -> Result<ApiResponse<T>, OperationError<GenericRejection>>

Follow a provider pagination link on this client’s REST origin.

The caller supplies the expected typed body for the originating list operation.

§Errors

Returns an error for an off-origin link, transport failure, provider rejection, or invalid response.

Source§

impl Client

Source§

impl Client

Source

pub async fn list_orders( &self, account_id: &AccountID, query: Option<&ListOrdersQuery>, ) -> Result<ApiResponse<ListOrdersResponse>, OperationError<GenericRejection>>

List orders.

Source§

impl Client

Source

pub async fn list_pending_orders( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListPendingOrdersResponse>, OperationError<GenericRejection>>

List pending orders.

Source§

impl Client

Source

pub async fn order_details( &self, account_id: &AccountID, order_specifier: &OrderSpecifier, ) -> Result<ApiResponse<OrderDetailsResponse>, OperationError<GenericRejection>>

Order details.

Source§

impl Client

Source

pub async fn replace_order( &self, account_id: &AccountID, order_specifier: &OrderSpecifier, body: &ReplaceOrderBody, client_request_id: Option<&ClientRequestID>, ) -> Result<ApiResponse<ReplaceOrderResponse>, OperationError<ReplaceOrderRejection>>

Replace order.

Source§

impl Client

Source

pub async fn cancel_order( &self, account_id: &AccountID, order_specifier: &OrderSpecifier, client_request_id: Option<&ClientRequestID>, ) -> Result<ApiResponse<CancelOrderResponse>, OperationError<CancelOrderRejection>>

Cancel order.

Source§

impl Client

Source§

impl Client

Source

pub async fn list_positions( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListPositionsResponse>, OperationError<GenericRejection>>

List positions.

Source§

impl Client

Source

pub async fn list_open_positions( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListOpenPositionsResponse>, OperationError<GenericRejection>>

List open positions.

Source§

impl Client

Source

pub async fn position_details( &self, account_id: &AccountID, instrument: &InstrumentName, ) -> Result<ApiResponse<PositionDetailsResponse>, OperationError<GenericRejection>>

Position details.

Source§

impl Client

Source

pub async fn close_position( &self, account_id: &AccountID, instrument: &InstrumentName, body: &ClosePositionBody, ) -> Result<ApiResponse<ClosePositionResponse>, OperationError<ClosePositionRejection>>

Close position.

Source§

impl Client

Source§

impl Client

Source

pub async fn pricing( &self, account_id: &AccountID, query: &PricingQuery, ) -> Result<ApiResponse<PricingResponse>, OperationError<GenericRejection>>

Pricing.

Source§

impl Client

Source§

impl Client

Source

pub async fn stream_pricing( &self, account: &AccountID, query: &StreamPricingQuery, ) -> Result<HttpStream<PriceStreamEvent>>

Open the sampled account pricing stream.

§Errors

Returns an error for an invalid query, exhausted stream capacity, transport failure, or provider rejection.

Source

pub async fn stream_transactions( &self, account: &AccountID, ) -> Result<HttpStream<TransactionStreamEvent>>

Open the account transaction stream. It starts at connection time; use transaction history for recovery.

§Errors

Returns an error for exhausted stream capacity, transport failure, or provider rejection.

Source§

impl Client

Source

pub async fn list_trades( &self, account_id: &AccountID, query: Option<&ListTradesQuery>, ) -> Result<ApiResponse<ListTradesResponse>, OperationError<GenericRejection>>

List trades.

Source§

impl Client

Source

pub async fn list_open_trades( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListOpenTradesResponse>, OperationError<GenericRejection>>

List open trades.

Source§

impl Client

Source

pub async fn trade_details( &self, account_id: &AccountID, trade_specifier: &TradeSpecifier, ) -> Result<ApiResponse<TradeDetailsResponse>, OperationError<GenericRejection>>

Trade details.

Source§

impl Client

Source

pub async fn close_trade( &self, account_id: &AccountID, trade_specifier: &TradeSpecifier, body: &CloseTradeBody, ) -> Result<ApiResponse<CloseTradeResponse>, OperationError<CloseTradeRejection>>

Close trade.

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source§

impl Client

Source

pub async fn transaction_details( &self, account_id: &AccountID, transaction_id: &TransactionID, ) -> Result<ApiResponse<TransactionDetailsResponse>, OperationError<GenericRejection>>

Transaction details.

Source§

impl Client

Source§

impl Client

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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: Sized + 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: Sized + 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> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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