-
-
Save mgild/67c8aadd3637c196ef605e4e1e9ef05e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let v: Vec<Pin<Box<dyn Future<Output = Result<Decimal, SbError>>>>> = vec![ | |
Box::pin(switchboard_utils::exchanges::BitfinexApi::fetch_ticker("tETHUSD", None).map_ok(|x| x.last_price)), | |
Box::pin(switchboard_utils::exchanges::CoinbaseApi::fetch_ticker("ETH-USD", None).map_ok(|x| x.price)), | |
Box::pin(switchboard_utils::exchanges::HuobiApi::fetch_ticker("ethusdt", None).map_ok(|x| Decimal::from_f64(x.close).unwrap())), | |
Box::pin(switchboard_utils::exchanges::KrakenApi::fetch_ticker("ETHUSD", None).map_ok(|x| x.close[0])) | |
]; | |
let eth_prices: Vec<Decimal> = join_all(v).await.into_iter().filter_map(|x| x.ok()).collect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment