use polynode::{PolyNodeClient, ShortFormInterval, Coin, ShortFormMessage};
#[tokio::main]
async fn main() -> polynode::Result<()> {
let client = PolyNodeClient::new("pn_live_test_session_tracking_51eca107e9b347b589f5b0a04f98eb1d")?;
let mut stream = client
.short_form(ShortFormInterval::FifteenMin)
.coins(&[Coin::Btc, Coin::Eth, Coin::Sol])
.rotation_buffer(3)
.start()
.await?;
while let Some(msg) = stream.next().await {
match msg {
ShortFormMessage::Event(event) => {
println!("event: {:?}", event);
}
ShortFormMessage::Rotation(info) => {
println!("--- window rotated ({}) ---", info.interval);
for m in &info.markets {
println!(" {}: beat ${:?} | {:.0}% up | {}s left",
m.coin.id(), m.price_to_beat,
m.up_odds * 100.0, info.time_remaining);
}
}
ShortFormMessage::Error(e) => {
eprintln!("non-fatal: {}", e);
}
}
}
Ok(())
}