pub struct QuoteStream { /* private fields */ }Expand description
Quotes of the symbols of one account, in the order the server sends them.
The subscription behind the stream is restored after a reconnection, so the stream goes on without further calls. The last known prices are forgotten the moment the loss of the connection is reported, so a price from before the loss is never combined with one from after it.
A stream that is read too slowly loses events: the connection holds a limited number of
them, set with
ConnectionOptions::event_capacity.
The loss is reported once by QuoteStream::next with ConnectorError::Lagged and the
last known prices are forgotten, so a quote delivered afterwards carries only sides the
server has sent since. The stream stays usable.
Implementations§
Source§impl QuoteStream
impl QuoteStream
Sourcepub fn symbols(&self) -> impl Iterator<Item = SymbolId> + '_
pub fn symbols(&self) -> impl Iterator<Item = SymbolId> + '_
Returns the symbols the stream delivers quotes of, in ascending order.
Sourcepub fn last(&self, symbol: SymbolId) -> Option<&Quote>
pub fn last(&self, symbol: SymbolId) -> Option<&Quote>
Returns the latest quote the stream has delivered for the symbol.
Sourcepub async fn next(&mut self) -> Result<Quote, ConnectorError>
pub async fn next(&mut self) -> Result<Quote, ConnectorError>
Waits for the next quote of one of the symbols of the stream.
§Errors
Returns ConnectorError::Closed when the connection is shut down,
ConnectorError::SessionEnded when the server ended the authorisation of the account,
ConnectorError::Lagged when events were dropped because the stream was read too
slowly, and ConnectorError::Value when the server sends a value out of range.
Sourcepub async fn unsubscribe(self) -> Result<(), ConnectorError>
pub async fn unsubscribe(self) -> Result<(), ConnectorError>
Ends the subscription to the spot prices of the symbols of the stream.
§Errors
Fails like OpenApiClient::unsubscribe_spots.