fetch symbols every thirty seconds
This commit is contained in:
parent
1337176474
commit
d3091369f4
1 changed files with 10 additions and 2 deletions
12
src/main.rs
12
src/main.rs
|
@ -1,6 +1,11 @@
|
||||||
|
use async_std::prelude::*;
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::io::{Error, ErrorKind};
|
use std::{
|
||||||
|
io::{Error, ErrorKind},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
use yahoo_finance_api as yahoo;
|
use yahoo_finance_api as yahoo;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
|
@ -169,7 +174,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");
|
||||||
fetch_and_output_symbol_data(&opts.symbols, from, to).await?;
|
let mut interval = async_std::stream::interval(Duration::from_secs(30));
|
||||||
|
while let Some(_) = interval.next().await {
|
||||||
|
fetch_and_output_symbol_data(&opts.symbols, from, to).await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue