Skip to main content

Module streaming

Module streaming 

Source
Expand description

Real-time price streaming with pluggable provider backends.

This module provides a Stream-based API for receiving real-time price updates, similar to Kotlin Flow or Rx observables.

§Overview

A StreamSource trait abstracts the provider-specific transport and wire protocol. Yahoo (YahooStreamSource) is the reference implementation, with additional providers (e.g. Polygon) supported through the same abstraction.

This module handles:

  • Provider-agnostic reconnection logic
  • Subscription management with automatic heartbeats
  • Protobuf message decoding (Yahoo)
  • A clean Stream API for consuming updates

§Example

use finance_query::streaming::PriceStream;
use futures::StreamExt;

// Subscribe to symbols
let mut stream = PriceStream::subscribe(["AAPL", "NVDA", "TSLA"]).await?;

// Process updates as they arrive
while let Some(price) = stream.next().await {
    println!("{}: ${:.2} ({:+.2}%)",
        price.id,
        price.price,
        price.change_percent
    );
}

Structs§

AlertEvaluator
Evaluates AlertRules against a price feed, tracking the per-symbol history that crossing conditions need.
AlertEvent
A fired alert, carrying the tick that triggered it.
AlertRule
A symbol paired with the condition that should trigger an alert.
AlertStream
A Stream<Item = AlertEvent> over any price stream.
Batched
A stream that yields Vec<T> batches collected over a time window.
BookLevel
One price level of an order book.
DepthStream
A subscription to level-2 order-book depth.
DepthStreamBuilder
Builder for a DepthStream.
EconomicStream
A continuous subscription to economic-series releases.
EconomicStreamBuilder
Builder for an EconomicStream with a custom poll interval.
Greeks
Option greeks for a contract.
NewsStream
A continuous subscription to one or more RSS/Atom sources.
NewsStreamBuilder
Builder for creating a NewsStream with custom configuration.
OptionContractUpdate
A live update for one options contract.
OptionsChainStream
A live subscription to one or more options chains.
OptionsChainStreamBuilder
Builder for an OptionsChainStream.
OrderBookUpdate
A depth-of-book update: both sides, best level first.
PriceStream
A streaming price subscription that yields real-time price updates.
PriceStreamBuilder
Builder for creating price streams with custom configuration
PriceUpdate
Real-time price update from Yahoo Finance WebSocket.
SeriesUpdate
A newly published (or revised) observation for an economic series.
TradeStream
A subscription to every trade print for the given symbols.
TradeStreamBuilder
Builder for a TradeStream.
TradeTick
A single executed trade.

Enums§

AlertCondition
A predicate over incoming price ticks.
AlertConditionKind
Which predicate an AlertCondition applies, without its threshold.
AssetClass
Asset class of a Polygon real-time cluster.
MarketHoursType
Market hours type enumeration
OptionType
Option type enumeration
PriceSource
Which upstream backend a PriceStream connects to.
QuoteType
Quote type enumeration
StreamError
Errors that can occur during streaming

Traits§

AlertExt
Adds alerts to every price stream.
StreamBatchExt
Adds batched to every Stream.

Type Aliases§

StreamResult
Result type for streaming operations