pub struct Ticker { /* private fields */ }Expand description
A forex ticker for fetching exchange rate data.
§Example
use dukascopy_fx::Ticker;
let ticker = Ticker::new("EUR", "USD");
// Get recent rate
let rate = ticker.rate().await?;
println!("EUR/USD: {}", rate.rate);
// Get historical data
let history = ticker.history("1w").await?;Implementations§
Source§impl Ticker
impl Ticker
Sourcepub fn parse(pair: &str) -> Result<Self, DukascopyError>
pub fn parse(pair: &str) -> Result<Self, DukascopyError>
Creates a ticker from a pair string like “EUR/USD” or “EURUSD”.
Sourcepub fn interval(self, interval: Duration) -> Self
pub fn interval(self, interval: Duration) -> Self
Sets the data interval for historical queries.
Sourcepub fn pair(&self) -> &CurrencyPair
pub fn pair(&self) -> &CurrencyPair
Returns the currency pair.
Sourcepub async fn rate_at(
&self,
timestamp: DateTime<Utc>,
) -> Result<CurrencyExchange, DukascopyError>
pub async fn rate_at( &self, timestamp: DateTime<Utc>, ) -> Result<CurrencyExchange, DukascopyError>
Fetches the exchange rate at a specific timestamp.
Sourcepub async fn rate(&self) -> Result<CurrencyExchange, DukascopyError>
pub async fn rate(&self) -> Result<CurrencyExchange, DukascopyError>
Fetches the most recent available exchange rate.
Sourcepub async fn history(
&self,
period: &str,
) -> Result<Vec<CurrencyExchange>, DukascopyError>
pub async fn history( &self, period: &str, ) -> Result<Vec<CurrencyExchange>, DukascopyError>
Fetches historical data for a time period.
§Period Strings
"1d"- 1 day"5d"- 5 days"1w"- 1 week"1mo"- 1 month (30 days)"3mo"- 3 months"1y"- 1 year
Sourcepub async fn history_range(
&self,
start: DateTime<Utc>,
end: DateTime<Utc>,
) -> Result<Vec<CurrencyExchange>, DukascopyError>
pub async fn history_range( &self, start: DateTime<Utc>, end: DateTime<Utc>, ) -> Result<Vec<CurrencyExchange>, DukascopyError>
Fetches historical data between two dates.
pub fn eur_usd() -> Self
pub fn gbp_usd() -> Self
pub fn usd_jpy() -> Self
pub fn usd_chf() -> Self
pub fn aud_usd() -> Self
pub fn usd_cad() -> Self
pub fn xau_usd() -> Self
pub fn xag_usd() -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ticker
impl RefUnwindSafe for Ticker
impl Send for Ticker
impl Sync for Ticker
impl Unpin for Ticker
impl UnwindSafe for Ticker
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