From 235104ae7546116a02cfd39e2a870a999e57c1a9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 31 Mar 2024 18:45:03 +0100 Subject: [PATCH] handle each symbol concurrently --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ee41bee..ed2b345 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use async_std::prelude::*; use chrono::prelude::*; use clap::Parser; +use futures::future::try_join_all; use std::{ io::{Error, ErrorKind}, time::Duration, @@ -160,9 +161,12 @@ async fn fetch_and_output_symbol_data( from: DateTime, to: DateTime, ) -> std::io::Result<()> { + let mut fs = vec![]; for symbol in symbols.split(',') { - fetch_and_output_closing_data(symbol, from, to).await?; + let f = fetch_and_output_closing_data(symbol, from, to); + fs.push(f); } + try_join_all(fs).await?; Ok(()) }