adding corporate data to webscraper
This commit is contained in:
31
src/corporate/update.rs
Normal file
31
src/corporate/update.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
// src/corporate/update.rs
|
||||
use super::{scraper::*, storage::*, types::*};
|
||||
use crate::config::Config;
|
||||
|
||||
use chrono::Local;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
|
||||
pub async fn run_full_update(tickers: Vec<String>, config: &Config) -> anyhow::Result<()> {
|
||||
println!("Updating {} tickers (prices from {})", tickers.len(), config.corporate_start_date);
|
||||
|
||||
let today = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||
|
||||
for ticker in tickers {
|
||||
print!(" → {:6} ", ticker);
|
||||
|
||||
// Earnings
|
||||
if let Ok(events) = fetch_earnings_history(&ticker).await {
|
||||
merge_and_save_events(&ticker, events.clone()).await?;
|
||||
println!("{} earnings", events.len());
|
||||
}
|
||||
|
||||
// Prices – now using config.corporate_start_date
|
||||
if let Ok(prices) = fetch_price_history(&ticker, &config.corporate_start_date, &today).await {
|
||||
save_prices_for_ticker(&ticker, prices).await?;
|
||||
}
|
||||
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(250)).await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user