pub struct XtbClient { /* private fields */ }
Expand description
Implementor of the API traits.
This struct is designed to be an interface between user (application) and XTB API servers.
The XtbClient
is responsible for sending and receiving pings and logout when instance is dropped.
Implementations§
Source§impl XtbClient
impl XtbClient
Sourcepub fn builder() -> XtbClientBuilder
pub fn builder() -> XtbClientBuilder
Create builder for the XtbClient
.
When builder is configured, the build()
method can be called with credentials passed to the
method arguments. This call create new XtbClient
instance.
Sourcepub fn new(
connection: BasicXtbConnection,
stream_connection: BasicXtbStreamConnection,
ping_period: u64,
) -> Self
pub fn new( connection: BasicXtbConnection, stream_connection: BasicXtbStreamConnection, ping_period: u64, ) -> Self
Create new instance of the XtbClient
. it expects connected and logged connections to the
request/response and the stream server.
§Note
The login is performed by the builder because the stream server implementation needs to know
a stream session id which is provided by the login
command.
Trait Implementations§
Source§impl RequestResponseApi for XtbClient
impl RequestResponseApi for XtbClient
Source§type Error = XtbClientError
type Error = XtbClientError
Error returned from methods when command failed
Source§fn get_all_symbols<'life0, 'async_trait>(
&'life0 mut self,
request: GetAllSymbolsRequest,
) -> Pin<Box<dyn Future<Output = Result<GetAllSymbolsResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_symbols<'life0, 'async_trait>(
&'life0 mut self,
request: GetAllSymbolsRequest,
) -> Pin<Box<dyn Future<Output = Result<GetAllSymbolsResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns array of all symbols available for the user.
Source§fn get_calendar<'life0, 'async_trait>(
&'life0 mut self,
request: GetCalendarRequest,
) -> Pin<Box<dyn Future<Output = Result<GetCalendarResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_calendar<'life0, 'async_trait>(
&'life0 mut self,
request: GetCalendarRequest,
) -> Pin<Box<dyn Future<Output = Result<GetCalendarResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns calendar with market events.
Source§fn get_chart_last_request<'life0, 'async_trait>(
&'life0 mut self,
request: GetChartLastRequestRequest,
) -> Pin<Box<dyn Future<Output = Result<GetChartLastRequestResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_chart_last_request<'life0, 'async_trait>(
&'life0 mut self,
request: GetChartLastRequestRequest,
) -> Pin<Box<dyn Future<Output = Result<GetChartLastRequestResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent
getCandles which is the preferred way of retrieving current candle data. Returns chart info,
from start date to the current time. If the chosen period of CHART_LAST_INFO_RECORD is
greater than 1 minute, the last candle returned by the API can change until the end of the
period (the candle is being automatically updated every minute). Read more
Source§fn get_chart_range_request<'life0, 'async_trait>(
&'life0 mut self,
request: GetChartRangeRequestRequest,
) -> Pin<Box<dyn Future<Output = Result<GetChartRangeRequestResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_chart_range_request<'life0, 'async_trait>(
&'life0 mut self,
request: GetChartRangeRequestRequest,
) -> Pin<Box<dyn Future<Output = Result<GetChartRangeRequestResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent
getCandles which is the preferred way of retrieving current candle data. Returns chart info
with data between given start and end dates. Read more
Source§fn get_commission_def<'life0, 'async_trait>(
&'life0 mut self,
request: GetCommissionDefRequest,
) -> Pin<Box<dyn Future<Output = Result<GetCommissionDefResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_commission_def<'life0, 'async_trait>(
&'life0 mut self,
request: GetCommissionDefRequest,
) -> Pin<Box<dyn Future<Output = Result<GetCommissionDefResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns calculation of commission and rate of exchange. The value is calculated as expected
value, and therefore might not be perfectly accurate.
Source§fn get_current_user_data<'life0, 'async_trait>(
&'life0 mut self,
request: GetCurrentUserDataRequest,
) -> Pin<Box<dyn Future<Output = Result<GetCurrentUserDataResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_current_user_data<'life0, 'async_trait>(
&'life0 mut self,
request: GetCurrentUserDataRequest,
) -> Pin<Box<dyn Future<Output = Result<GetCurrentUserDataResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns information about account currency, and account leverage.
Source§fn get_ibs_history<'life0, 'async_trait>(
&'life0 mut self,
request: GetIbsHistoryRequest,
) -> Pin<Box<dyn Future<Output = Result<GetIbsHistoryResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_ibs_history<'life0, 'async_trait>(
&'life0 mut self,
request: GetIbsHistoryRequest,
) -> Pin<Box<dyn Future<Output = Result<GetIbsHistoryResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns IBs data from the given time range.
Source§fn get_margin_level<'life0, 'async_trait>(
&'life0 mut self,
request: GetMarginLevelRequest,
) -> Pin<Box<dyn Future<Output = Result<GetMarginLevelResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_margin_level<'life0, 'async_trait>(
&'life0 mut self,
request: GetMarginLevelRequest,
) -> Pin<Box<dyn Future<Output = Result<GetMarginLevelResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent
getBalance which is the preferred way of retrieving account indicators. Returns various
account indicators.
Source§fn get_margin_trade<'life0, 'async_trait>(
&'life0 mut self,
request: GetMarginTradeRequest,
) -> Pin<Box<dyn Future<Output = Result<GetMarginTradeResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_margin_trade<'life0, 'async_trait>(
&'life0 mut self,
request: GetMarginTradeRequest,
) -> Pin<Box<dyn Future<Output = Result<GetMarginTradeResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns expected margin for given instrument and volume. The value is calculated as expected
margin value, and therefore might not be perfectly accurate.
Source§fn get_news<'life0, 'async_trait>(
&'life0 mut self,
request: GetNewsRequest,
) -> Pin<Box<dyn Future<Output = Result<GetNewsResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_news<'life0, 'async_trait>(
&'life0 mut self,
request: GetNewsRequest,
) -> Pin<Box<dyn Future<Output = Result<GetNewsResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent getNews
which is the preferred way of retrieving news data. Returns news from trading server which
were sent within specified period of time.
Source§fn get_profit_calculation<'life0, 'async_trait>(
&'life0 mut self,
request: GetProfitCalculationRequest,
) -> Pin<Box<dyn Future<Output = Result<GetProfitCalculationResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_profit_calculation<'life0, 'async_trait>(
&'life0 mut self,
request: GetProfitCalculationRequest,
) -> Pin<Box<dyn Future<Output = Result<GetProfitCalculationResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Calculates estimated profit for given deal data Should be used for calculator-like apps
only. Profit for opened transactions should be taken from server, due to higher precision of
server calculation.
Source§fn get_server_time<'life0, 'async_trait>(
&'life0 mut self,
request: GetServerTimeRequest,
) -> Pin<Box<dyn Future<Output = Result<GetServerTimeResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_server_time<'life0, 'async_trait>(
&'life0 mut self,
request: GetServerTimeRequest,
) -> Pin<Box<dyn Future<Output = Result<GetServerTimeResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns current time on trading server.
Source§fn get_step_rules<'life0, 'async_trait>(
&'life0 mut self,
request: GetStepRulesRequest,
) -> Pin<Box<dyn Future<Output = Result<GetStepRulesResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_step_rules<'life0, 'async_trait>(
&'life0 mut self,
request: GetStepRulesRequest,
) -> Pin<Box<dyn Future<Output = Result<GetStepRulesResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns a list of step rules for DMAs.
Source§fn get_symbol<'life0, 'async_trait>(
&'life0 mut self,
request: GetSymbolRequest,
) -> Pin<Box<dyn Future<Output = Result<GetSymbolResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_symbol<'life0, 'async_trait>(
&'life0 mut self,
request: GetSymbolRequest,
) -> Pin<Box<dyn Future<Output = Result<GetSymbolResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns information about symbol available for the user.
Source§fn get_tick_prices<'life0, 'async_trait>(
&'life0 mut self,
request: GetTickPricesRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTickPricesResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_tick_prices<'life0, 'async_trait>(
&'life0 mut self,
request: GetTickPricesRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTickPricesResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent
getTickPrices which is the preferred way of retrieving ticks data. Returns array of current
quotations for given symbols, only quotations that changed from given timestamp are
returned. New timestamp obtained from output will be used as an argument of the next call
of this command.
Source§fn get_trade_records<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradeRecordsRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradeRecordsResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_trade_records<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradeRecordsRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradeRecordsResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns array of trades listed in orders argument.
Source§fn get_trades<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradesRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradesResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_trades<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradesRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradesResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent getTrades
which is the preferred way of retrieving trades data. Returns array of user’s trades.
Source§fn get_trades_history<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradesHistoryRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradesHistoryResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_trades_history<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradesHistoryRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradesHistoryResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Please note that this function can be usually replaced by its streaming equivalent getTrades
which is the preferred way of retrieving trades data. Returns array of user’s trades which
were closed within specified period of time.
Source§fn get_trading_hours<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradingHoursRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradingHoursResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_trading_hours<'life0, 'async_trait>(
&'life0 mut self,
request: GetTradingHoursRequest,
) -> Pin<Box<dyn Future<Output = Result<GetTradingHoursResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns quotes and trading times.
Source§fn get_version<'life0, 'async_trait>(
&'life0 mut self,
request: GetVersionRequest,
) -> Pin<Box<dyn Future<Output = Result<GetVersionResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_version<'life0, 'async_trait>(
&'life0 mut self,
request: GetVersionRequest,
) -> Pin<Box<dyn Future<Output = Result<GetVersionResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the current API version.
Source§fn trade_transaction<'life0, 'async_trait>(
&'life0 mut self,
request: TradeTransactionRequest,
) -> Pin<Box<dyn Future<Output = Result<TradeTransactionResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn trade_transaction<'life0, 'async_trait>(
&'life0 mut self,
request: TradeTransactionRequest,
) -> Pin<Box<dyn Future<Output = Result<TradeTransactionResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Starts trade transaction. tradeTransaction sends main transaction information to the server. Read more
Source§fn trade_transaction_status<'life0, 'async_trait>(
&'life0 mut self,
request: TradeTransactionStatusRequest,
) -> Pin<Box<dyn Future<Output = Result<TradeTransactionStatusResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn trade_transaction_status<'life0, 'async_trait>(
&'life0 mut self,
request: TradeTransactionStatusRequest,
) -> Pin<Box<dyn Future<Output = Result<TradeTransactionStatusResponse, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Description: Please note that this function can be usually replaced by its streaming
equivalent getTradeStatus which is the preferred way of retrieving transaction status data.
Returns current transaction status. At any time of transaction processing client might check
the status of transaction on server side. In order to do that client must provide unique
order taken from tradeTransaction invocation.
Source§impl StreamApi for XtbClient
impl StreamApi for XtbClient
Source§type Error = XtbClientError
type Error = XtbClientError
Error returned from the client when something went wrong
type Stream<T: Send + Sync + for<'de> Deserialize<'de>> = DataStream<T>
Source§fn subscribe_balance<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetBalanceSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetBalanceData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_balance<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetBalanceSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetBalanceData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Each streaming command takes as an argument streamSessionId which is sent in response
message for login command performed in main connection. streamSessionId token allows to
identify user in streaming connection. In one streaming connection multiple commands with
different streamSessionId can be invoked. It will cause sending streaming data for multiple
login sessions in one streaming connection. streamSessionId is valid until logout command is
performed on main connection or main connection is disconnected.
Source§fn subscribe_candles<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetCandlesSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetCandlesData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_candles<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetCandlesSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetCandlesData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribes for and unsubscribes from API chart candles. The interval of every candle
is 1 minute. A new candle arrives every minute.
Source§fn subscribe_keep_alive<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetKeepAliveSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetKeepAliveData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_keep_alive<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetKeepAliveSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetKeepAliveData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribes for and unsubscribes from ‘keep alive’ messages. A new ‘keep alive’ message
is sent by the API every 3 seconds.
Source§fn subscribe_news<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetNewsSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetNewsData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_news<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetNewsSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetNewsData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribes for and unsubscribes from news.
Source§fn subscribe_profits<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetProfitSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetProfitData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_profits<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetProfitSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetProfitData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribes for and unsubscribes from profits.
Source§fn subscribe_tick_prices<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetTickPricesSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetTickPricesData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_tick_prices<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetTickPricesSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetTickPricesData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Establishes subscription for quotations and allows to obtain the relevant information
in real-time, as soon as it is available in the system. The getTickPrices command can
be invoked many times for the same symbol, but only one subscription for a given symbol
will be created. Please beware that when multiple records are available, the order in which
they are received is not guaranteed.
Source§fn subscribe_trades<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetTradesSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetTradesData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_trades<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetTradesSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetTradesData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Establishes subscription for user trade status data and allows to obtain the relevant
information in real-time, as soon as it is available in the system. Please beware that when
multiple records are available, the order in which they are received is not guaranteed.
Source§fn subscribe_trade_status<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetTradeStatusSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetTradeStatusData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_trade_status<'life0, 'async_trait>(
&'life0 mut self,
arguments: StreamGetTradeStatusSubscribe,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream<StreamGetTradeStatusData>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Allows to get status for sent trade requests in real-time, as soon as it is available
in the system. Please beware that when multiple records are available, the order in which
they are received is not guaranteed.
Auto Trait Implementations§
impl Freeze for XtbClient
impl !RefUnwindSafe for XtbClient
impl Send for XtbClient
impl Sync for XtbClient
impl Unpin for XtbClient
impl !UnwindSafe for XtbClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more