pub struct Client { /* private fields */ }Expand description
Shareable OANDA v20 client.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn list_accounts(
&self,
) -> Result<ApiResponse<ListAccountsResponse>, OperationError<GenericRejection>>
pub async fn list_accounts( &self, ) -> Result<ApiResponse<ListAccountsResponse>, OperationError<GenericRejection>>
List accounts.
Source§impl Client
impl Client
Sourcepub async fn account_details(
&self,
account_id: &AccountID,
) -> Result<ApiResponse<AccountDetailsResponse>, OperationError<GenericRejection>>
pub async fn account_details( &self, account_id: &AccountID, ) -> Result<ApiResponse<AccountDetailsResponse>, OperationError<GenericRejection>>
Account details.
Source§impl Client
impl Client
Sourcepub async fn account_summary(
&self,
account_id: &AccountID,
) -> Result<ApiResponse<AccountSummaryResponse>, OperationError<GenericRejection>>
pub async fn account_summary( &self, account_id: &AccountID, ) -> Result<ApiResponse<AccountSummaryResponse>, OperationError<GenericRejection>>
Account summary.
Source§impl Client
impl Client
Sourcepub async fn account_instruments(
&self,
account_id: &AccountID,
query: Option<&AccountInstrumentsQuery>,
) -> Result<ApiResponse<AccountInstrumentsResponse>, OperationError<GenericRejection>>
pub async fn account_instruments( &self, account_id: &AccountID, query: Option<&AccountInstrumentsQuery>, ) -> Result<ApiResponse<AccountInstrumentsResponse>, OperationError<GenericRejection>>
Account instruments.
Source§impl Client
impl Client
Sourcepub async fn configure_account(
&self,
account_id: &AccountID,
body: &ConfigureAccountBody,
) -> Result<ApiResponse<ConfigureAccountResponse>, OperationError<ConfigureAccountRejection>>
pub async fn configure_account( &self, account_id: &AccountID, body: &ConfigureAccountBody, ) -> Result<ApiResponse<ConfigureAccountResponse>, OperationError<ConfigureAccountRejection>>
Configure account.
Source§impl Client
impl Client
Sourcepub async fn account_changes(
&self,
account_id: &AccountID,
query: Option<&AccountChangesQuery>,
) -> Result<ApiResponse<AccountChangesResponse>, OperationError<GenericRejection>>
pub async fn account_changes( &self, account_id: &AccountID, query: Option<&AccountChangesQuery>, ) -> Result<ApiResponse<AccountChangesResponse>, OperationError<GenericRejection>>
Account changes.
Source§impl Client
impl Client
Sourcepub fn set_exit_reserve(&self, requests: u32) -> Result<()>
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 clones observe the latest replacement; waiting reads and stream starts 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 100 or the rate
lock is poisoned. Invalid changes preserve the policy and admission state.
Sourcepub fn builder(
environment: Environment,
bearer_token: impl Into<String>,
) -> ClientBuilder
pub fn builder( environment: Environment, bearer_token: impl Into<String>, ) -> ClientBuilder
Start building a client with an injected personal access token.
Sourcepub fn acknowledge_reconciliation(&self, account: &AccountID) -> Result<()>
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.
Sourcepub async fn fetch_page<T: DeserializeOwned>(
&self,
next_page: &Url,
) -> Result<ApiResponse<T>, OperationError<GenericRejection>>
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
impl Client
Sourcepub async fn create_order(
&self,
account_id: &AccountID,
body: &CreateOrderBody,
) -> Result<ApiResponse<CreateOrderResponse>, OperationError<CreateOrderRejection>>
pub async fn create_order( &self, account_id: &AccountID, body: &CreateOrderBody, ) -> Result<ApiResponse<CreateOrderResponse>, OperationError<CreateOrderRejection>>
Create order.
Source§impl Client
impl Client
Sourcepub async fn list_orders(
&self,
account_id: &AccountID,
query: Option<&ListOrdersQuery>,
) -> Result<ApiResponse<ListOrdersResponse>, OperationError<GenericRejection>>
pub async fn list_orders( &self, account_id: &AccountID, query: Option<&ListOrdersQuery>, ) -> Result<ApiResponse<ListOrdersResponse>, OperationError<GenericRejection>>
List orders.
Source§impl Client
impl Client
Sourcepub async fn list_pending_orders(
&self,
account_id: &AccountID,
) -> Result<ApiResponse<ListPendingOrdersResponse>, OperationError<GenericRejection>>
pub async fn list_pending_orders( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListPendingOrdersResponse>, OperationError<GenericRejection>>
List pending orders.
Source§impl Client
impl Client
Sourcepub async fn order_details(
&self,
account_id: &AccountID,
order_specifier: &OrderSpecifier,
) -> Result<ApiResponse<OrderDetailsResponse>, OperationError<GenericRejection>>
pub async fn order_details( &self, account_id: &AccountID, order_specifier: &OrderSpecifier, ) -> Result<ApiResponse<OrderDetailsResponse>, OperationError<GenericRejection>>
Order details.
Source§impl Client
impl Client
Sourcepub async fn replace_order(
&self,
account_id: &AccountID,
order_specifier: &OrderSpecifier,
body: &ReplaceOrderBody,
client_request_id: Option<&ClientRequestID>,
) -> Result<ApiResponse<ReplaceOrderResponse>, OperationError<ReplaceOrderRejection>>
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
impl Client
Sourcepub async fn cancel_order(
&self,
account_id: &AccountID,
order_specifier: &OrderSpecifier,
client_request_id: Option<&ClientRequestID>,
) -> Result<ApiResponse<CancelOrderResponse>, OperationError<CancelOrderRejection>>
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
impl Client
Sourcepub async fn update_order_client_extensions(
&self,
account_id: &AccountID,
order_specifier: &OrderSpecifier,
body: &UpdateOrderClientExtensionsBody,
) -> Result<ApiResponse<UpdateOrderClientExtensionsResponse>, OperationError<UpdateOrderClientExtensionsRejection>>
pub async fn update_order_client_extensions( &self, account_id: &AccountID, order_specifier: &OrderSpecifier, body: &UpdateOrderClientExtensionsBody, ) -> Result<ApiResponse<UpdateOrderClientExtensionsResponse>, OperationError<UpdateOrderClientExtensionsRejection>>
Update order client extensions.
Source§impl Client
impl Client
Sourcepub async fn list_positions(
&self,
account_id: &AccountID,
) -> Result<ApiResponse<ListPositionsResponse>, OperationError<GenericRejection>>
pub async fn list_positions( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListPositionsResponse>, OperationError<GenericRejection>>
List positions.
Source§impl Client
impl Client
Sourcepub async fn list_open_positions(
&self,
account_id: &AccountID,
) -> Result<ApiResponse<ListOpenPositionsResponse>, OperationError<GenericRejection>>
pub async fn list_open_positions( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListOpenPositionsResponse>, OperationError<GenericRejection>>
List open positions.
Source§impl Client
impl Client
Sourcepub async fn position_details(
&self,
account_id: &AccountID,
instrument: &InstrumentName,
) -> Result<ApiResponse<PositionDetailsResponse>, OperationError<GenericRejection>>
pub async fn position_details( &self, account_id: &AccountID, instrument: &InstrumentName, ) -> Result<ApiResponse<PositionDetailsResponse>, OperationError<GenericRejection>>
Position details.
Source§impl Client
impl Client
Sourcepub async fn close_position(
&self,
account_id: &AccountID,
instrument: &InstrumentName,
body: &ClosePositionBody,
) -> Result<ApiResponse<ClosePositionResponse>, OperationError<ClosePositionRejection>>
pub async fn close_position( &self, account_id: &AccountID, instrument: &InstrumentName, body: &ClosePositionBody, ) -> Result<ApiResponse<ClosePositionResponse>, OperationError<ClosePositionRejection>>
Close position.
Source§impl Client
impl Client
Sourcepub async fn latest_candles(
&self,
account_id: &AccountID,
query: &LatestCandlesQuery,
) -> Result<ApiResponse<LatestCandlesResponse>, OperationError<GenericRejection>>
pub async fn latest_candles( &self, account_id: &AccountID, query: &LatestCandlesQuery, ) -> Result<ApiResponse<LatestCandlesResponse>, OperationError<GenericRejection>>
Latest candles.
Source§impl Client
impl Client
Sourcepub async fn pricing(
&self,
account_id: &AccountID,
query: &PricingQuery,
) -> Result<ApiResponse<PricingResponse>, OperationError<GenericRejection>>
pub async fn pricing( &self, account_id: &AccountID, query: &PricingQuery, ) -> Result<ApiResponse<PricingResponse>, OperationError<GenericRejection>>
Pricing.
Source§impl Client
impl Client
Sourcepub async fn instrument_candles(
&self,
account_id: &AccountID,
instrument: &InstrumentName,
query: Option<&InstrumentCandlesQuery>,
) -> Result<ApiResponse<InstrumentCandlesResponse>, OperationError<GenericRejection>>
pub async fn instrument_candles( &self, account_id: &AccountID, instrument: &InstrumentName, query: Option<&InstrumentCandlesQuery>, ) -> Result<ApiResponse<InstrumentCandlesResponse>, OperationError<GenericRejection>>
Instrument candles.
Source§impl Client
impl Client
Sourcepub async fn stream_pricing(
&self,
account: &AccountID,
query: &StreamPricingQuery,
) -> Result<HttpStream<PriceStreamEvent>>
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.
Sourcepub async fn stream_transactions(
&self,
account: &AccountID,
) -> Result<HttpStream<TransactionStreamEvent>>
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
impl Client
Sourcepub async fn list_trades(
&self,
account_id: &AccountID,
query: Option<&ListTradesQuery>,
) -> Result<ApiResponse<ListTradesResponse>, OperationError<GenericRejection>>
pub async fn list_trades( &self, account_id: &AccountID, query: Option<&ListTradesQuery>, ) -> Result<ApiResponse<ListTradesResponse>, OperationError<GenericRejection>>
List trades.
Source§impl Client
impl Client
Sourcepub async fn list_open_trades(
&self,
account_id: &AccountID,
) -> Result<ApiResponse<ListOpenTradesResponse>, OperationError<GenericRejection>>
pub async fn list_open_trades( &self, account_id: &AccountID, ) -> Result<ApiResponse<ListOpenTradesResponse>, OperationError<GenericRejection>>
List open trades.
Source§impl Client
impl Client
Sourcepub async fn trade_details(
&self,
account_id: &AccountID,
trade_specifier: &TradeSpecifier,
) -> Result<ApiResponse<TradeDetailsResponse>, OperationError<GenericRejection>>
pub async fn trade_details( &self, account_id: &AccountID, trade_specifier: &TradeSpecifier, ) -> Result<ApiResponse<TradeDetailsResponse>, OperationError<GenericRejection>>
Trade details.
Source§impl Client
impl Client
Sourcepub async fn close_trade(
&self,
account_id: &AccountID,
trade_specifier: &TradeSpecifier,
body: &CloseTradeBody,
) -> Result<ApiResponse<CloseTradeResponse>, OperationError<CloseTradeRejection>>
pub async fn close_trade( &self, account_id: &AccountID, trade_specifier: &TradeSpecifier, body: &CloseTradeBody, ) -> Result<ApiResponse<CloseTradeResponse>, OperationError<CloseTradeRejection>>
Close trade.
Source§impl Client
impl Client
Sourcepub async fn update_trade_client_extensions(
&self,
account_id: &AccountID,
trade_specifier: &TradeSpecifier,
body: &UpdateTradeClientExtensionsBody,
) -> Result<ApiResponse<UpdateTradeClientExtensionsResponse>, OperationError<UpdateTradeClientExtensionsRejection>>
pub async fn update_trade_client_extensions( &self, account_id: &AccountID, trade_specifier: &TradeSpecifier, body: &UpdateTradeClientExtensionsBody, ) -> Result<ApiResponse<UpdateTradeClientExtensionsResponse>, OperationError<UpdateTradeClientExtensionsRejection>>
Update trade client extensions.
Source§impl Client
impl Client
Sourcepub async fn set_trade_dependent_orders(
&self,
account_id: &AccountID,
trade_specifier: &TradeSpecifier,
body: &SetTradeDependentOrdersBody,
) -> Result<ApiResponse<SetTradeDependentOrdersResponse>, OperationError<SetTradeDependentOrdersRejection>>
pub async fn set_trade_dependent_orders( &self, account_id: &AccountID, trade_specifier: &TradeSpecifier, body: &SetTradeDependentOrdersBody, ) -> Result<ApiResponse<SetTradeDependentOrdersResponse>, OperationError<SetTradeDependentOrdersRejection>>
Set trade dependent orders.
Source§impl Client
impl Client
Sourcepub async fn list_transactions(
&self,
account_id: &AccountID,
query: Option<&ListTransactionsQuery>,
) -> Result<ApiResponse<ListTransactionsResponse>, OperationError<GenericRejection>>
pub async fn list_transactions( &self, account_id: &AccountID, query: Option<&ListTransactionsQuery>, ) -> Result<ApiResponse<ListTransactionsResponse>, OperationError<GenericRejection>>
List transactions.
Source§impl Client
impl Client
Sourcepub async fn transaction_details(
&self,
account_id: &AccountID,
transaction_id: &TransactionID,
) -> Result<ApiResponse<TransactionDetailsResponse>, OperationError<GenericRejection>>
pub async fn transaction_details( &self, account_id: &AccountID, transaction_id: &TransactionID, ) -> Result<ApiResponse<TransactionDetailsResponse>, OperationError<GenericRejection>>
Transaction details.
Source§impl Client
impl Client
Sourcepub async fn transactions_by_id_range(
&self,
account_id: &AccountID,
query: &TransactionsByIdRangeQuery,
) -> Result<ApiResponse<TransactionsByIdRangeResponse>, OperationError<GenericRejection>>
pub async fn transactions_by_id_range( &self, account_id: &AccountID, query: &TransactionsByIdRangeQuery, ) -> Result<ApiResponse<TransactionsByIdRangeResponse>, OperationError<GenericRejection>>
Transactions by id range.
Source§impl Client
impl Client
Sourcepub async fn transactions_since_id(
&self,
account_id: &AccountID,
query: &TransactionsSinceIdQuery,
) -> Result<ApiResponse<TransactionsSinceIdResponse>, OperationError<GenericRejection>>
pub async fn transactions_since_id( &self, account_id: &AccountID, query: &TransactionsSinceIdQuery, ) -> Result<ApiResponse<TransactionsSinceIdResponse>, OperationError<GenericRejection>>
Transactions since id.