pub struct DataFeed { /* private fields */ }
Expand description
Main client for interacting with the Pyth Network API
Implementations§
Source§impl DataFeed
impl DataFeed
Sourcepub fn new(subscriptions: Subscriptions) -> Self
pub fn new(subscriptions: Subscriptions) -> Self
Create a new DataFeed instance with the given subscriptions
Sourcepub async fn on_ready<F>(&self, callback: F)
pub async fn on_ready<F>(&self, callback: F)
Initialize the data feed and call the callback when ready
§Arguments
callback
- Function to call when the data feed is ready with config data
Sourcepub async fn search_symbols<F>(
&self,
user_input: &str,
_exchange: &str,
_symbol_type: &str,
on_result_ready_callback: F,
)
pub async fn search_symbols<F>( &self, user_input: &str, _exchange: &str, _symbol_type: &str, on_result_ready_callback: F, )
Search for symbols matching the given query
§Arguments
user_input
- Search query stringexchange
- Exchange filter (currently unused)symbol_type
- Symbol type filter (currently unused)on_result_ready_callback
- Callback for when search results are ready
Sourcepub async fn resolve_symbol<F1, F2>(
&self,
symbol_name: &str,
on_symbol_resolved_callback: F1,
on_resolve_error_callback: F2,
)
pub async fn resolve_symbol<F1, F2>( &self, symbol_name: &str, on_symbol_resolved_callback: F1, on_resolve_error_callback: F2, )
Resolve symbol information for the given symbol name
§Arguments
symbol_name
- Name of the symbol to resolveon_symbol_resolved_callback
- Callback for successful resolutionon_resolve_error_callback
- Callback for resolution errors
Sourcepub async fn get_bars<F1, F2>(
&self,
symbol_info: &SymbolInfo,
resolution: &str,
period_params: &PeriodParams,
on_history_callback: F1,
_on_error_callback: F2,
)
pub async fn get_bars<F1, F2>( &self, symbol_info: &SymbolInfo, resolution: &str, period_params: &PeriodParams, on_history_callback: F1, _on_error_callback: F2, )
Get historical bar data for a symbol
§Arguments
symbol_info
- Symbol informationresolution
- Time resolution (e.g., “1D”, “1H”)period_params
- Time period parameterson_history_callback
- Callback for historical dataon_error_callback
- Callback for errors
Sourcepub async fn subscribe_bars(
&self,
symbol_info: SymbolInfo,
resolution: String,
on_realtime_callback: UnboundedSender<Bar>,
subscriber_uid: String,
_on_reset_cache_needed_callback: Option<fn()>,
)
pub async fn subscribe_bars( &self, symbol_info: SymbolInfo, resolution: String, on_realtime_callback: UnboundedSender<Bar>, subscriber_uid: String, _on_reset_cache_needed_callback: Option<fn()>, )
Subscribe to real-time bar updates for a symbol
§Arguments
symbol_info
- Symbol informationresolution
- Time resolutionon_realtime_callback
- Channel for receiving bar updatessubscriber_uid
- Unique identifier for this subscriptionon_reset_cache_needed_callback
- Optional callback for cache resets
Sourcepub async fn unsubscribe_bars(&self, subscriber_uid: &str)
pub async fn unsubscribe_bars(&self, subscriber_uid: &str)
Unsubscribe from bar updates
§Arguments
subscriber_uid
- Unique identifier of the subscription to remove
Sourcepub fn get_last_bar(&self, ticker: &str) -> Option<Bar>
pub fn get_last_bar(&self, ticker: &str) -> Option<Bar>
Get the cached last bar for a symbol, if available
Sourcepub fn set_last_bar(&self, ticker: String, bar: Bar)
pub fn set_last_bar(&self, ticker: String, bar: Bar)
Manually set the last bar for a symbol in the cache
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataFeed
impl !RefUnwindSafe for DataFeed
impl Send for DataFeed
impl Sync for DataFeed
impl Unpin for DataFeed
impl !UnwindSafe for DataFeed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more