don't wait before fetching first set of data

This commit is contained in:
Paul Campbell 2024-03-31 18:47:39 +01:00
parent 235104ae75
commit 38cd013ab9

View file

@ -178,6 +178,10 @@ async fn main() -> std::io::Result<()> {
// a simple way to output a CSV header // a simple way to output a CSV header
println!("period start,symbol,price,change %,min,max,30d avg"); println!("period start,symbol,price,change %,min,max,30d avg");
// initial data fetch
fetch_and_output_symbol_data(&opts.symbols, from, to).await?;
let mut interval = async_std::stream::interval(Duration::from_secs(30)); let mut interval = async_std::stream::interval(Duration::from_secs(30));
while let Some(_) = interval.next().await { while let Some(_) = interval.next().await {
fetch_and_output_symbol_data(&opts.symbols, from, to).await?; fetch_and_output_symbol_data(&opts.symbols, from, to).await?;