pub mod client;
pub mod streaming;
pub mod types;
pub use client::DataFeed;
pub use streaming::{start_streaming, subscribe_on_stream, unsubscribe_from_stream};
pub use types::{Bar, Handler, Subscription, Subscriptions, SymbolInfo, PeriodParams};
pub const STREAMING_URL: &str = "https://benchmarks.pyth.network/v1/shims/tradingview/streaming";
pub const API_ENDPOINT: &str = "https://benchmarks.pyth.network/v1/shims/tradingview";
#[cfg(test)]
mod tests {
use super::*;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
#[test]
fn test_bar_creation() {
let bar = Bar {
time: 1_717_000_000,
open: 100.0,
high: 105.0,
low: 95.0,
close: 102.0,
};
assert_eq!(bar.time, 1_717_000_000);
assert_eq!(bar.open, 100.0);
assert_eq!(bar.high, 105.0);
assert_eq!(bar.low, 95.0);
assert_eq!(bar.close, 102.0);
}
#[test]
fn test_symbol_info_creation() {
let symbol = SymbolInfo {
ticker: "BTC/USD".to_string(),
};
assert_eq!(symbol.ticker, "BTC/USD");
}
#[test]
fn test_datafeed_creation() {
let subscriptions = Arc::new(Mutex::new(HashMap::new()));
let datafeed = DataFeed::new(subscriptions);
assert!(format!("{:?}", datafeed.client).len() > 0);
}
}