Crate pyth_benchmark_rs

Source
Expand description

§Pyth Benchmark Rust Client

A Rust client for streaming and processing price data from the Pyth Network oracle. This crate provides a robust interface for accessing real-time price data and converting it into OHLC (Open, High, Low, Close) bar data.

§Features

  • Real-time price streaming from Pyth Network
  • OHLC bar generation from price feeds
  • Daily bar aggregation
  • Subscription-based architecture
  • Automatic reconnection with exponential backoff
  • Thread-safe subscription management

§Quick Start

use pyth_benchmark_rs::{DataFeed, SymbolInfo, PeriodParams, start_streaming};
use std::sync::{Arc, Mutex};
use std::collections::HashMap;
use tokio::sync::mpsc;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize subscriptions
    let subscriptions = Arc::new(Mutex::new(HashMap::new()));
     
    // Create DataFeed instance
    let datafeed = DataFeed::new(subscriptions.clone());
     
    // Start streaming in background
    let subs_clone = subscriptions.clone();
    tokio::spawn(async move {
        let _ = start_streaming(subs_clone).await;
    });
     
    // Use the datafeed...
    Ok(())
}

Re-exports§

pub use client::DataFeed;
pub use streaming::start_streaming;
pub use streaming::subscribe_on_stream;
pub use streaming::unsubscribe_from_stream;
pub use types::Bar;
pub use types::Handler;
pub use types::Subscription;
pub use types::Subscriptions;
pub use types::SymbolInfo;
pub use types::PeriodParams;

Modules§

client
streaming
types

Constants§

API_ENDPOINT
The default Pyth Network API endpoint
STREAMING_URL
The default Pyth Network streaming URL