adding corporate data to webscraper

This commit is contained in:
2025-11-21 00:17:59 +01:00
parent 0ea3fcc3b5
commit 9d0d15f3f8
18 changed files with 2128 additions and 970 deletions

31
src/corporate/update.rs Normal file
View 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(())
}