pub trait Broker: Send + Sync {
Show 20 methods
// Required methods
fn name(&self) -> &'static str;
fn connect<'async_trait>(
params: BrokerParams,
) -> Pin<Box<dyn Future<Output = Result<Self, BrokerError>> + Send + 'async_trait>>
where Self: Sized + 'async_trait;
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn session<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Session, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_account_type<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AccountType, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn switch_account<'life0, 'async_trait>(
&'life0 mut self,
kind: AccountType,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_assets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Asset>, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn asset_status<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MarketStatus, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_candles<'life0, 'async_trait>(
&'life0 self,
req: CandleRequest,
) -> Pin<Box<dyn Future<Output = Result<Vec<Candle>, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe_candles<'life0, 'async_trait>(
&'life0 self,
req: CandleSubscribe,
) -> Pin<Box<dyn Future<Output = Result<CandleStream, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_position_history<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
limit: usize,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<PositionHistory, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_payout<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
expiration_seconds: u64,
) -> Pin<Box<dyn Future<Output = Result<Payout, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn buy_binary<'life0, 'async_trait>(
&'life0 self,
req: BuyBinaryRequest,
) -> Pin<Box<dyn Future<Output = Result<OrderId, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn sell_option<'life0, 'life1, 'async_trait>(
&'life0 self,
order_id: &'life1 OrderId,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_operation_result<'life0, 'life1, 'async_trait>(
&'life0 self,
order_id: &'life1 OrderId,
) -> Pin<Box<dyn Future<Output = Result<OperationResult, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn events<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<EventStream, BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn iqoption_extras(&self) -> Option<&dyn IqOptionExtras> { ... }
fn subscribe_ticks<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Contrato que todo adaptador de bróker cumple.
Diseño type-erased a propósito: sin associated types para que
Box<dyn Broker> y MultiBroker compilen (ver docs/01_introduccion.es.md).
Required Methods§
Sourcefn connect<'async_trait>(
params: BrokerParams,
) -> Pin<Box<dyn Future<Output = Result<Self, BrokerError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
fn connect<'async_trait>(
params: BrokerParams,
) -> Pin<Box<dyn Future<Output = Result<Self, BrokerError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
Constructor de la sesión: autentica y deja el bróker operativo.
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn session<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Session, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn session<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Session, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Metadatos de la sesión activa (copia: la sesión se actualiza en caliente).
fn get_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Balance, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_account_type<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AccountType, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn switch_account<'life0, 'async_trait>(
&'life0 mut self,
kind: AccountType,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_assets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Asset>, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn asset_status<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MarketStatus, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_candles<'life0, 'async_trait>(
&'life0 self,
req: CandleRequest,
) -> Pin<Box<dyn Future<Output = Result<Vec<Candle>, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_candles<'life0, 'async_trait>(
&'life0 self,
req: CandleSubscribe,
) -> Pin<Box<dyn Future<Output = Result<CandleStream, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn get_position_history<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
limit: usize,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<PositionHistory, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_position_history<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
limit: usize,
offset: usize,
) -> Pin<Box<dyn Future<Output = Result<PositionHistory, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Historial de posiciones cerradas (cartera): para analítica de cuenta.
limit ≤ 100 por página, offset para paginar.
Sourcefn get_payout<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
expiration_seconds: u64,
) -> Pin<Box<dyn Future<Output = Result<Payout, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_payout<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
expiration_seconds: u64,
) -> Pin<Box<dyn Future<Output = Result<Payout, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Payout publicado en el catálogo para el activo.
expiration_seconds se devuelve en el resultado pero no altera la
consulta: no se pide una cotización por expiración ni por strike. Los
cambios en vivo llegan por Event::PayoutChanged.
Sourcefn buy_binary<'life0, 'async_trait>(
&'life0 self,
req: BuyBinaryRequest,
) -> Pin<Box<dyn Future<Output = Result<OrderId, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn buy_binary<'life0, 'async_trait>(
&'life0 self,
req: BuyBinaryRequest,
) -> Pin<Box<dyn Future<Output = Result<OrderId, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Compra clásica (turbo o binary según la duración).
BLITZ tiene su propia petición: [Broker::buy_blitz].
Sourcefn sell_option<'life0, 'life1, 'async_trait>(
&'life0 self,
order_id: &'life1 OrderId,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sell_option<'life0, 'life1, 'async_trait>(
&'life0 self,
order_id: &'life1 OrderId,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Venta anticipada (buyback) de una orden abierta. El bróker la admite
dentro de la ventana buyback_deadtime del activo; si la orden ya no
es vendible responde con su mensaje de rechazo.
Sourcefn get_operation_result<'life0, 'life1, 'async_trait>(
&'life0 self,
order_id: &'life1 OrderId,
) -> Pin<Box<dyn Future<Output = Result<OperationResult, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_operation_result<'life0, 'life1, 'async_trait>(
&'life0 self,
order_id: &'life1 OrderId,
) -> Pin<Box<dyn Future<Output = Result<OperationResult, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resultado leído de la caché local (alimentada por events()).
No consulta al bróker: devuelve OperationResult::Pending mientras el
cierre no haya llegado por eventos.
Sourcefn events<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<EventStream, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn events<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<EventStream, BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stream de eventos (cierres, balances, payouts en vivo, velas suscritas).
Provided Methods§
Sourcefn iqoption_extras(&self) -> Option<&dyn IqOptionExtras>
fn iqoption_extras(&self) -> Option<&dyn IqOptionExtras>
Acceso a las capacidades exclusivas de IQ Option, si el adaptador las
ofrece. Los adaptadores que no las implementan devuelven None.
Sourcefn subscribe_ticks<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn subscribe_ticks<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), BrokerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Suscribe el stream nativo de ticks de un activo.
Los ticks llegan por Event::PriceTick. Un adaptador sin stream nativo
hereda el rechazo explícito; no se simula con polling.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".