2021-03-04 21:39:42 -05:00
|
|
|
use anyhow::{Context, Result};
|
2021-06-23 15:32:31 -04:00
|
|
|
use url::Url;
|
2021-03-04 21:39:42 -05:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
tracing::subscriber::set_global_default(
|
2021-03-08 23:35:22 -05:00
|
|
|
tracing_subscriber::fmt().with_env_filter("debug").finish(),
|
2021-03-04 21:39:42 -05:00
|
|
|
)?;
|
|
|
|
|
2021-06-23 15:32:31 -04:00
|
|
|
let price_ticker_ws_url = Url::parse("wss://ws.kraken.com")?;
|
|
|
|
let mut ticker =
|
|
|
|
swap::kraken::connect(price_ticker_ws_url).context("Failed to connect to kraken")?;
|
2021-03-04 21:39:42 -05:00
|
|
|
|
|
|
|
loop {
|
2021-03-31 21:09:51 -04:00
|
|
|
match ticker.wait_for_next_update().await? {
|
|
|
|
Ok(update) => println!("Price update: {}", update.ask),
|
2021-03-04 21:39:42 -05:00
|
|
|
Err(e) => println!("Error: {:#}", e),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|