pub struct AlorHttpClient { /* private fields */ }Expand description
The authorized HTTP client of the ALOR OpenAPI.
It holds the refresh token and the current access token and adds Authorization: Bearer ... to every call:
- The first call trades the refresh token for an access token (
POST /refreshof the authorization server). The access token is cached for 20 minutes (or less, if its own expiry is nearer). - When the broker answers 401 to a read, the client gets a new access token and repeats the same request once.
- A command (placing, changing or cancelling an order) is never repeated, not even after a 401: the client renews the token for the next call and returns the 401 as an error.
- A transport error or a timeout is never repeated.
The client is cheap to clone. Clones share the tokens and the connection pool. The endpoint methods (one per
REST call) are documented on this type too, they are in super::endpoints. The broker limits HTTP calls to
100 a second per user; the client does not throttle, the connector does it through the shared limiter.
§Examples
use brokapi_alor_protocol::http::client::AlorHttpClient;
let client = AlorHttpClient::new(cfg)?;
let book = client.get_order_book("MOEX", "SBER", Some("TQBR"), Some(5)).await?;
println!("{} levels of bids", book.bids.len());Implementations§
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub fn new(config: AlorConfig) -> Result<Self, AlorApiError>
pub fn new(config: AlorConfig) -> Result<Self, AlorApiError>
Creates a client from a configuration. No network call is made.
§Errors
AlorApiError::Http (no status) if the HTTP stack cannot be built.
§Examples
use brokapi_alor_protocol::config::AlorConfig;
use brokapi_alor_protocol::http::client::AlorHttpClient;
let client = AlorHttpClient::new(AlorConfig::new("refresh-token".to_string()))?;
assert_eq!(client.base_url(), "https://api.alor.ru");Sourcepub async fn get_access_token(&self) -> Result<String, AlorApiError>
pub async fn get_access_token(&self) -> Result<String, AlorApiError>
The access token now: the cached one, or a new one if there is none or it is past its time.
The WebSocket session calls this before every message that needs a token.
§Errors
As AlorHttpClient::refresh_access_token, and only when a new token is needed.
§Examples
use brokapi_alor_protocol::http::client::AlorHttpClient;
let client = AlorHttpClient::new(cfg)?;
let first = client.get_access_token().await?;
let second = client.get_access_token().await?; // from the cache, no second token request
assert_eq!(first, second);Sourcepub async fn refresh_access_token(&self) -> Result<String, AlorApiError>
pub async fn refresh_access_token(&self) -> Result<String, AlorApiError>
Trades the refresh token for a new access token and stores it. Always calls the authorization server.
Sends POST /refresh with the refresh token in a JSON body (not in the URL, so it stays out of logs).
The new access token is cached. Refreshes are serialised by a lock.
§Errors
AlorApiError::Auth: the server refused the refresh token (HTTP 400, 401 or 403).AlorApiError::Http: a transport failure, or another status.AlorApiError::Parse: the answer has noAccessToken.
Sourcepub async fn token_portfolios(&self) -> Result<Vec<String>, AlorApiError>
pub async fn token_portfolios(&self) -> Result<Vec<String>, AlorApiError>
The portfolios named in the claims of the current access token (the portfolios claim of the JWT).
The connector uses it to find the portfolio when the config names none. Empty when the token is not a JWT or carries no portfolios.
§Errors
Sourcepub async fn read<T: DeserializeOwned>(
&self,
path: &str,
query: &[(&str, String)],
) -> Result<T, AlorApiError>
pub async fn read<T: DeserializeOwned>( &self, path: &str, query: &[(&str, String)], ) -> Result<T, AlorApiError>
GETs a path with query parameters and parses the JSON reply into T.
path starts with / and is added to the base URL. A 401 is answered with one token refresh and one
repeat. Other failures are not retried. The typed methods of super::endpoints call it.
§Errors
AlorApiError::NotFound: HTTP 404.AlorApiError::RateLimitExceeded: HTTP 429.AlorApiError::Http: any other non-success status, or a transport failure.AlorApiError::Parse: the reply is a success but is not the JSON thatTexpects.AlorApiError::Auth: the token refresh after a 401 failed.
§Examples
use brokapi_alor_protocol::error::AlorApiError;
use brokapi_alor_protocol::http::client::AlorHttpClient;
let client = AlorHttpClient::new(cfg)?;
let time: serde_json::Value = client.read("/md/v2/time", &[]).await?;
assert!(time.is_number());
// A path the broker does not know ends in an error that carries the status.
let err = client.read::<serde_json::Value>("/no/such/path", &[]).await.unwrap_err();
assert!(matches!(err, AlorApiError::NotFound { .. }));Sourcepub async fn command<T, B>(
&self,
method: Method,
path: &str,
query: &[(&str, String)],
body: Option<&B>,
req_id: Option<&str>,
) -> Result<T, AlorApiError>where
T: DeserializeOwned,
B: Serialize,
pub async fn command<T, B>(
&self,
method: Method,
path: &str,
query: &[(&str, String)],
body: Option<&B>,
req_id: Option<&str>,
) -> Result<T, AlorApiError>where
T: DeserializeOwned,
B: Serialize,
Sends a command (place, change or cancel an order) and parses the JSON reply into T. Never repeats
the request.
A repeat of a command is the one way to place an order twice, so the client sends it once. If the
broker answers 401, the client renews the access token (so the next call works) and returns the 401 as
AlorApiError::Http with status: Some(401); a 401 means the broker did not act. A transport error
or a timeout is an unknown outcome, as for every command. req_id becomes the header X-REQID: the
broker answers a repeated id with a copy of its first answer instead of doing the command again.
§Errors
The same as AlorHttpClient::read.
Sourcepub async fn read_raw(
&self,
path: &str,
query: &[(&str, String)],
) -> Result<(StatusCode, String), AlorApiError>
pub async fn read_raw( &self, path: &str, query: &[(&str, String)], ) -> Result<(StatusCode, String), AlorApiError>
GETs a path and returns the status and the body text, without parsing and without mapping errors.
An error status is not an Err here: you get it as the first element of the pair. Only a 401 is
handled (one refresh, one repeat).
§Errors
AlorApiError::Http (no status) on a transport failure, and the errors of
AlorHttpClient::refresh_access_token when a 401 needs a new token.
Sourcepub fn inner_client(&self) -> &Client
pub fn inner_client(&self) -> &Client
The underlying reqwest client, for calls this crate does not wrap. It carries no authorization:
add the token yourself with AlorHttpClient::get_access_token.
Sourcepub fn ws_base_url(&self) -> &str
pub fn ws_base_url(&self) -> &str
The WebSocket base URL that sessions started from this client connect to.
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub async fn get_securities(
&self,
query: &[(&str, String)],
) -> Result<Vec<SecurityInfo>, AlorApiError>
pub async fn get_securities( &self, query: &[(&str, String)], ) -> Result<Vec<SecurityInfo>, AlorApiError>
GET /md/v2/Securities: a search over the instruments of all markets. query takes query (a
ticker part), limit, offset, sector (FORTS, FOND, CURR), cficode, exchange,
instrumentGroup and includeNonBaseBoards.
§Errors
Sourcepub async fn get_securities_by_exchange(
&self,
exchange: &str,
query: &[(&str, String)],
) -> Result<Vec<SecurityInfo>, AlorApiError>
pub async fn get_securities_by_exchange( &self, exchange: &str, query: &[(&str, String)], ) -> Result<Vec<SecurityInfo>, AlorApiError>
GET /md/v2/Securities/{exchange}: the instruments of one exchange. query is as in
AlorHttpClient::get_securities (limit, offset, sector, …).
§Errors
Sourcepub async fn get_security(
&self,
exchange: &str,
symbol: &str,
group: Option<&str>,
) -> Result<SecurityInfo, AlorApiError>
pub async fn get_security( &self, exchange: &str, symbol: &str, group: Option<&str>, ) -> Result<SecurityInfo, AlorApiError>
GET /md/v2/Securities/{exchange}/{symbol}: one instrument, in the trading mode group (the main one if
left out).
§Errors
As AlorHttpClient::read; AlorApiError::NotFound for an unknown instrument.
§Examples
use brokapi_alor_protocol::http::client::AlorHttpClient;
let client = AlorHttpClient::new(cfg)?;
let sber = client.get_security("MOEX", "SBER", Some("TQBR")).await?;
assert_eq!(sber.symbol, "SBER");
assert!(sber.lot_size.is_some());Sourcepub async fn get_available_boards(
&self,
exchange: &str,
symbol: &str,
) -> Result<Value, AlorApiError>
pub async fn get_available_boards( &self, exchange: &str, symbol: &str, ) -> Result<Value, AlorApiError>
GET /md/v2/Securities/{exchange}/{symbol}/availableBoards: the trading modes the instrument trades in.
§Errors
Sourcepub async fn get_quotes(
&self,
symbols: &[(&str, &str)],
) -> Result<Vec<QuoteRecord>, AlorApiError>
pub async fn get_quotes( &self, symbols: &[(&str, &str)], ) -> Result<Vec<QuoteRecord>, AlorApiError>
GET /md/v2/Securities/{symbols}/quotes: the quotations of several instruments. symbols are pairs of
exchange and ticker.
§Errors
Sourcepub async fn get_currency_pairs(&self) -> Result<Value, AlorApiError>
pub async fn get_currency_pairs(&self) -> Result<Value, AlorApiError>
Sourcepub async fn get_actual_futures_quote(
&self,
exchange: &str,
symbol: &str,
) -> Result<Value, AlorApiError>
pub async fn get_actual_futures_quote( &self, exchange: &str, symbol: &str, ) -> Result<Value, AlorApiError>
GET /md/v2/Securities/{exchange}/{symbol}/actualFuturesQuote: the quotation of the nearest futures of
an underlying.
§Errors
Sourcepub async fn get_risk_rates(
&self,
query: &[(&str, String)],
) -> Result<Value, AlorApiError>
pub async fn get_risk_rates( &self, query: &[(&str, String)], ) -> Result<Value, AlorApiError>
GET /md/v2/risk/rates: the risk rates of instruments. query takes exchange, ticker, riskCategoryId,
search, limit, offset, …
§Errors
Sourcepub async fn get_time(&self) -> Result<i64, AlorApiError>
pub async fn get_time(&self) -> Result<i64, AlorApiError>
GET /md/v2/time: the server time, Unix seconds. The broker asks for it rarely (the time is not exact).
§Errors
Sourcepub async fn get_market_status(
&self,
exchange: &str,
market: &str,
) -> Result<MarketStatus, AlorApiError>
pub async fn get_market_status( &self, exchange: &str, market: &str, ) -> Result<MarketStatus, AlorApiError>
GET /md/status/{exchange}/{market}: the state of the trading session of a market (FORTS, FOND, CURR,
SPBX).
§Errors
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub async fn get_order_book(
&self,
exchange: &str,
symbol: &str,
group: Option<&str>,
depth: Option<u32>,
) -> Result<OrderBook, AlorApiError>
pub async fn get_order_book( &self, exchange: &str, symbol: &str, group: Option<&str>, depth: Option<u32>, ) -> Result<OrderBook, AlorApiError>
GET /md/v2/orderbooks/{exchange}/{symbol}: the order book. depth is 20 by default and 50 at most.
§Errors
Sourcepub async fn get_history(
&self,
exchange: &str,
symbol: &str,
group: Option<&str>,
tf: &str,
from: i64,
to: i64,
count_back: Option<u32>,
) -> Result<HistoryResponse, AlorApiError>
pub async fn get_history( &self, exchange: &str, symbol: &str, group: Option<&str>, tf: &str, from: i64, to: i64, count_back: Option<u32>, ) -> Result<HistoryResponse, AlorApiError>
GET /md/v2/history: candles. tf is a number of seconds (60, 3600) or D, W, M, Y; from and
to are Unix seconds; count_back asks for at least that many candles.
§Errors
Sourcepub async fn get_all_trades(
&self,
exchange: &str,
symbol: &str,
group: Option<&str>,
query: &[(&str, String)],
) -> Result<Vec<MarketTradeRecord>, AlorApiError>
pub async fn get_all_trades( &self, exchange: &str, symbol: &str, group: Option<&str>, query: &[(&str, String)], ) -> Result<Vec<MarketTradeRecord>, AlorApiError>
GET /md/v2/Securities/{exchange}/{symbol}/alltrades: the trades of the market of today. query takes
from, to (Unix seconds), fromId, toId, qtyFrom, qtyTo, priceFrom, priceTo, side,
offset, take, descending, includeVirtualTrades.
§Errors
Sourcepub async fn get_all_trades_history(
&self,
exchange: &str,
symbol: &str,
group: Option<&str>,
query: &[(&str, String)],
) -> Result<AllTradesHistory, AlorApiError>
pub async fn get_all_trades_history( &self, exchange: &str, symbol: &str, group: Option<&str>, query: &[(&str, String)], ) -> Result<AllTradesHistory, AlorApiError>
GET /md/v2/Securities/{exchange}/{symbol}/alltrades/history: the trades of the market of the past days,
a page at a time. query takes from, to (Unix seconds), limit (required by the broker, 1 to 50000)
and offset.
§Errors
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub async fn get_orders(
&self,
exchange: &str,
portfolio: &str,
) -> Result<Vec<OrderRecord>, AlorApiError>
pub async fn get_orders( &self, exchange: &str, portfolio: &str, ) -> Result<Vec<OrderRecord>, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/orders: all orders of the portfolio of today.
§Errors
Sourcepub async fn get_order(
&self,
exchange: &str,
portfolio: &str,
order_id: &str,
) -> Result<OrderRecord, AlorApiError>
pub async fn get_order( &self, exchange: &str, portfolio: &str, order_id: &str, ) -> Result<OrderRecord, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/orders/{orderId}: one order. AlorApiError::NotFound when the
broker does not know the number.
§Errors
Sourcepub async fn get_stop_orders(
&self,
exchange: &str,
portfolio: &str,
) -> Result<Vec<StopOrderRecord>, AlorApiError>
pub async fn get_stop_orders( &self, exchange: &str, portfolio: &str, ) -> Result<Vec<StopOrderRecord>, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/stoporders: all stop orders of the portfolio of today.
§Errors
Sourcepub async fn get_stop_order(
&self,
exchange: &str,
portfolio: &str,
order_id: &str,
) -> Result<StopOrderRecord, AlorApiError>
pub async fn get_stop_order( &self, exchange: &str, portfolio: &str, order_id: &str, ) -> Result<StopOrderRecord, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/stoporders/{orderId}: one stop order.
§Errors
Sourcepub async fn get_money_legacy(
&self,
exchange: &str,
portfolio: &str,
) -> Result<Value, AlorApiError>
pub async fn get_money_legacy( &self, exchange: &str, portfolio: &str, ) -> Result<Value, AlorApiError>
GET /md/v2/Clients/legacy/{exchange}/{portfolio}/money: the money of the portfolio (the old form).
§Errors
Sourcepub async fn get_summary(
&self,
exchange: &str,
portfolio: &str,
) -> Result<SummaryRecord, AlorApiError>
pub async fn get_summary( &self, exchange: &str, portfolio: &str, ) -> Result<SummaryRecord, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/summary: the summary of the portfolio.
§Errors
Sourcepub async fn get_positions(
&self,
exchange: &str,
portfolio: &str,
without_currency: bool,
) -> Result<Vec<PositionRecord>, AlorApiError>
pub async fn get_positions( &self, exchange: &str, portfolio: &str, without_currency: bool, ) -> Result<Vec<PositionRecord>, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/positions: the positions, with the money as positions of
currencies unless without_currency is set.
§Errors
Sourcepub async fn get_position(
&self,
exchange: &str,
portfolio: &str,
symbol: &str,
) -> Result<PositionRecord, AlorApiError>
pub async fn get_position( &self, exchange: &str, portfolio: &str, symbol: &str, ) -> Result<PositionRecord, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/positions/{symbol}: the position in one instrument.
§Errors
Sourcepub async fn get_login_positions(
&self,
login: &str,
) -> Result<Vec<PositionRecord>, AlorApiError>
pub async fn get_login_positions( &self, login: &str, ) -> Result<Vec<PositionRecord>, AlorApiError>
GET /md/v2/Clients/{login}/positions: the positions of all portfolios of a trade login.
§Errors
Sourcepub async fn get_trades(
&self,
exchange: &str,
portfolio: &str,
) -> Result<Vec<TradeRecord>, AlorApiError>
pub async fn get_trades( &self, exchange: &str, portfolio: &str, ) -> Result<Vec<TradeRecord>, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/trades: the trades of the portfolio of today.
§Errors
Sourcepub async fn get_symbol_trades(
&self,
exchange: &str,
portfolio: &str,
symbol: &str,
) -> Result<Vec<TradeRecord>, AlorApiError>
pub async fn get_symbol_trades( &self, exchange: &str, portfolio: &str, symbol: &str, ) -> Result<Vec<TradeRecord>, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/{symbol}/trades: the trades of the portfolio in one instrument.
§Errors
Sourcepub async fn get_forts_risk(
&self,
exchange: &str,
portfolio: &str,
) -> Result<Value, AlorApiError>
pub async fn get_forts_risk( &self, exchange: &str, portfolio: &str, ) -> Result<Value, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/fortsrisk: the risks of the futures market.
§Errors
Sourcepub async fn get_risk(
&self,
exchange: &str,
portfolio: &str,
) -> Result<Value, AlorApiError>
pub async fn get_risk( &self, exchange: &str, portfolio: &str, ) -> Result<Value, AlorApiError>
GET /md/v2/Clients/{exchange}/{portfolio}/risk: the risks of the portfolio.
§Errors
Sourcepub async fn get_trade_stats(
&self,
exchange: &str,
portfolio: &str,
query: &[(&str, String)],
) -> Result<Value, AlorApiError>
pub async fn get_trade_stats( &self, exchange: &str, portfolio: &str, query: &[(&str, String)], ) -> Result<Value, AlorApiError>
GET /md/stats/{exchange}/{portfolio}/history/trades: the statistics of the trades (the old form).
query takes dateFrom, ticker, id, limit, side, descending, …
§Errors
Sourcepub async fn get_trade_stats_by_symbol(
&self,
exchange: &str,
portfolio: &str,
symbol: &str,
query: &[(&str, String)],
) -> Result<Value, AlorApiError>
pub async fn get_trade_stats_by_symbol( &self, exchange: &str, portfolio: &str, symbol: &str, query: &[(&str, String)], ) -> Result<Value, AlorApiError>
GET /md/stats/{exchange}/{portfolio}/history/trades/{symbol}: the same for one instrument.
§Errors
Sourcepub async fn get_history_trades(
&self,
exchange: &str,
portfolio: &str,
query: &[(&str, String)],
) -> Result<Vec<TradeRecord>, AlorApiError>
pub async fn get_history_trades( &self, exchange: &str, portfolio: &str, query: &[(&str, String)], ) -> Result<Vec<TradeRecord>, AlorApiError>
GET /md/v2/Stats/{exchange}/{portfolio}/history/trades: the trades of the portfolio of the past days,
a page at a time. query takes dateFrom (a date or a date and time), from (the number of the
first trade), limit (1 to 1000), ticker, side, orderByTradeDate, descending, withRepo.
§Errors
Sourcepub async fn get_history_trades_by_symbol(
&self,
exchange: &str,
portfolio: &str,
symbol: &str,
query: &[(&str, String)],
) -> Result<Vec<TradeRecord>, AlorApiError>
pub async fn get_history_trades_by_symbol( &self, exchange: &str, portfolio: &str, symbol: &str, query: &[(&str, String)], ) -> Result<Vec<TradeRecord>, AlorApiError>
GET /md/v2/Stats/{exchange}/{portfolio}/history/trades/{symbol}: the same for one instrument.
§Errors
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub async fn create_limit_order(
&self,
req_id: &str,
order: &LimitOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_limit_order( &self, req_id: &str, order: &LimitOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
POST .../orders/actions/limit: a limit order. req_id is the header X-REQID: unique for the whole
system; the broker answers a repeated id with a copy of its first answer and does not place a second order.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn create_market_order(
&self,
req_id: &str,
order: &MarketOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_market_order( &self, req_id: &str, order: &MarketOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
POST .../orders/actions/market: a market order. See AlorHttpClient::create_limit_order for req_id.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn update_limit_order(
&self,
req_id: &str,
order_id: &str,
order: &LimitOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_limit_order( &self, req_id: &str, order_id: &str, order: &LimitOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../orders/actions/limit/{orderId}: changes a limit order (the broker takes the new quantity and
price and answers with the number of the order that replaced it).
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn update_market_order(
&self,
req_id: &str,
order_id: &str,
order: &MarketOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_market_order( &self, req_id: &str, order_id: &str, order: &MarketOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../orders/actions/market/{orderId}: changes a market order.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn create_stop_order(
&self,
req_id: &str,
order: &StopOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_stop_order( &self, req_id: &str, order: &StopOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
POST .../orders/actions/stop: a stop order that makes a market order on trigger.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn create_stop_limit_order(
&self,
req_id: &str,
order: &StopOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_stop_limit_order( &self, req_id: &str, order: &StopOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
POST .../orders/actions/stopLimit: a stop order that makes a limit order on trigger (order.price).
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn update_stop_order(
&self,
req_id: &str,
order_id: &str,
order: &StopOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_stop_order( &self, req_id: &str, order_id: &str, order: &StopOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../orders/actions/stop/{stopOrderId}: changes a stop order.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn update_stop_limit_order(
&self,
req_id: &str,
order_id: &str,
order: &StopOrderRequest,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_stop_limit_order( &self, req_id: &str, order_id: &str, order: &StopOrderRequest, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../orders/actions/stopLimit/{stopOrderId}: changes a stop-limit order.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn cancel_order(
&self,
exchange: &str,
portfolio: &str,
order_id: &str,
stop: bool,
) -> Result<Value, AlorApiError>
pub async fn cancel_order( &self, exchange: &str, portfolio: &str, order_id: &str, stop: bool, ) -> Result<Value, AlorApiError>
DELETE .../orders/{orderId}: cancels an order, or a stop order when stop is set. The broker names the
exchange and the portfolio in the query, not in the path.
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn cancel_all_orders(
&self,
exchange: &str,
portfolio: &str,
stop: Option<bool>,
) -> Result<Value, AlorApiError>
pub async fn cancel_all_orders( &self, exchange: &str, portfolio: &str, stop: Option<bool>, ) -> Result<Value, AlorApiError>
DELETE .../orders/all: cancels all orders of the portfolio on the exchange (the stop orders when
stop is Some(true)).
§Errors
As AlorHttpClient::command. The call is never repeated.
Sourcepub async fn estimate_order(&self, body: &Value) -> Result<Value, AlorApiError>
pub async fn estimate_order(&self, body: &Value) -> Result<Value, AlorApiError>
POST .../orders/estimate: estimates one order (the quantity the portfolio can buy or sell, the cost, the
commission). The body is portfolio, ticker, exchange, price, lotQuantity or budget, board,
includeLimitOrders.
§Errors
As AlorHttpClient::command. It changes nothing at the broker, but is not repeated either.
Sourcepub async fn estimate_orders(&self, body: &Value) -> Result<Value, AlorApiError>
pub async fn estimate_orders(&self, body: &Value) -> Result<Value, AlorApiError>
POST .../orders/estimate/all: estimates a list of orders. The body is a list of the bodies of
AlorHttpClient::estimate_order.
§Errors
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub async fn get_order_groups(&self) -> Result<Value, AlorApiError>
pub async fn get_order_groups(&self) -> Result<Value, AlorApiError>
Sourcepub async fn create_order_group(
&self,
body: &Value,
) -> Result<Value, AlorApiError>
pub async fn create_order_group( &self, body: &Value, ) -> Result<Value, AlorApiError>
POST /commandapi/api/orderGroups: makes a group of orders (orders and executionPolicy), where
the execution or cancel of one order triggers the others.
§Errors
Sourcepub async fn get_order_group(
&self,
group_id: &str,
) -> Result<Value, AlorApiError>
pub async fn get_order_group( &self, group_id: &str, ) -> Result<Value, AlorApiError>
Sourcepub async fn update_order_group(
&self,
group_id: &str,
body: &Value,
) -> Result<Value, AlorApiError>
pub async fn update_order_group( &self, group_id: &str, body: &Value, ) -> Result<Value, AlorApiError>
PUT /commandapi/api/orderGroups/{orderGroupId}: changes an order group.
§Errors
Sourcepub async fn delete_order_group(
&self,
group_id: &str,
) -> Result<Value, AlorApiError>
pub async fn delete_order_group( &self, group_id: &str, ) -> Result<Value, AlorApiError>
DELETE /commandapi/api/orderGroups/{orderGroupId}: removes an order group (the orders stay).
§Errors
Source§impl AlorHttpClient
impl AlorHttpClient
Sourcepub async fn create_stop_loss(
&self,
server: &str,
req_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_stop_loss( &self, server: &str, req_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
POST /warptrans/{tradeServerCode}/v2/client/orders/actions/stopLoss: the old stop-loss order. The broker
marks the whole family as outdated: use AlorHttpClient::create_stop_order.
§Errors
Sourcepub async fn create_stop_loss_limit(
&self,
server: &str,
req_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_stop_loss_limit( &self, server: &str, req_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
POST .../actions/stopLossLimit: the old stop-loss order with a limit price.
§Errors
Sourcepub async fn create_take_profit(
&self,
server: &str,
req_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_take_profit( &self, server: &str, req_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
Sourcepub async fn create_take_profit_limit(
&self,
server: &str,
req_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn create_take_profit_limit( &self, server: &str, req_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
POST .../actions/takeProfitLimit: the old take-profit order with a limit price.
§Errors
Sourcepub async fn update_stop_loss(
&self,
server: &str,
req_id: &str,
order_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_stop_loss( &self, server: &str, req_id: &str, order_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../actions/stopLoss/{orderId}: changes an old stop-loss order.
§Errors
Sourcepub async fn update_stop_loss_limit(
&self,
server: &str,
req_id: &str,
order_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_stop_loss_limit( &self, server: &str, req_id: &str, order_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../actions/stopLossLimit/{orderId}: changes an old stop-loss order with a limit price.
§Errors
Sourcepub async fn update_take_profit(
&self,
server: &str,
req_id: &str,
order_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_take_profit( &self, server: &str, req_id: &str, order_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../actions/takeProfit/{orderId}: changes an old take-profit order.
§Errors
Sourcepub async fn update_take_profit_limit(
&self,
server: &str,
req_id: &str,
order_id: &str,
body: &Value,
) -> Result<OrderCommandResponse, AlorApiError>
pub async fn update_take_profit_limit( &self, server: &str, req_id: &str, order_id: &str, body: &Value, ) -> Result<OrderCommandResponse, AlorApiError>
PUT .../actions/takeProfitLimit/{orderId}: changes an old take-profit order with a limit price.
§Errors
Sourcepub async fn cancel_order_legacy(
&self,
server: &str,
order_id: &str,
query: &[(&str, String)],
) -> Result<Value, AlorApiError>
pub async fn cancel_order_legacy( &self, server: &str, order_id: &str, query: &[(&str, String)], ) -> Result<Value, AlorApiError>
DELETE /warptrans/{tradeServerCode}/v2/client/orders/{orderId}: cancels an order by the old path.
§Errors
Trait Implementations§
Source§impl Clone for AlorHttpClient
impl Clone for AlorHttpClient
Source§fn clone(&self) -> AlorHttpClient
fn clone(&self) -> AlorHttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more