pub struct TrendbarStream { /* private fields */ }Expand description
The forming bar of one symbol and period, sent anew whenever a price changes it.
The subscription behind the stream is restored after a reconnection. The last bid the stream has seen is forgotten the moment the loss of the connection is reported, so a bar from after the loss never closes at a bid from before 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 TrendbarStream::next with ConnectorError::Lagged and
the last bid is forgotten, so no bar closes at a bid older than the loss. The stream stays
usable.
Implementations§
Source§impl TrendbarStream
impl TrendbarStream
Sourcepub async fn next(&mut self) -> Result<Trendbar, ConnectorError>
pub async fn next(&mut self) -> Result<Trendbar, ConnectorError>
Waits for the next state of the forming bar.
The server leaves the last price out of a live bar; it is taken from the bid that arrives with the bar or, failing that, from the last bid the stream has seen. A bar that arrives before any bid is passed over.
§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 live bars; the spot subscription of the symbol stays.
§Errors
Fails like OpenApiClient::unsubscribe_live_trendbars.