added mapping figi info onto common shares / warrants / options
This commit is contained in:
@@ -4,9 +4,8 @@ use crate::config::Config;
|
||||
use crate::scraper::webdriver::ChromeDriverPool;
|
||||
|
||||
use chrono::Local;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{HashMap};
|
||||
use std::sync::Arc;
|
||||
use futures::{stream::{self, StreamExt}};
|
||||
|
||||
/// Main function: Full update for all companies (LEI-based) with optimized parallel execution.
|
||||
///
|
||||
@@ -54,8 +53,8 @@ pub async fn run_full_update(config: &Config, pool: &Arc<ChromeDriverPool>) -> a
|
||||
};
|
||||
|
||||
// 4. Load or build companies
|
||||
let mut companies = load_or_build_companies_by_name(&figi_to_lei).await?;
|
||||
println!("Processing {} companies", companies.len());
|
||||
let mut companies = load_or_build_all_securities(&figi_to_lei).await?;
|
||||
println!("Processing {} companies", companies.0.len());
|
||||
|
||||
// 5. Load existing earnings events (for change detection)
|
||||
let today = Local::now().format("%Y-%m-%d").to_string();
|
||||
@@ -96,35 +95,6 @@ pub async fn run_full_update(config: &Config, pool: &Arc<ChromeDriverPool>) -> a
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn assign_leis_from_figi(
|
||||
companies: &mut [CompanyMetadata],
|
||||
lei_to_isins: &HashMap<String, Vec<String>>
|
||||
) -> anyhow::Result<()> {
|
||||
for company in companies {
|
||||
let figi_infos = company.figi.as_ref().map_or(&[][..], |v| &v[..]);
|
||||
let isins: Vec<String> = figi_infos
|
||||
.iter()
|
||||
.map(|f| f.isin.clone())
|
||||
.collect::<HashSet<_>>()
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
// Try to find LEI by any known ISIN
|
||||
for isin in &isins {
|
||||
for (lei, isins) in lei_to_isins.iter() {
|
||||
if isins.contains(isin) {
|
||||
company.lei = lei.clone();
|
||||
let name = figi_infos.first().map(|f| f.name.as_str()).unwrap_or("Unknown");
|
||||
println!("Found real LEI {} for {}", lei, name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !company.lei.is_empty() { break; }
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct ProcessResult {
|
||||
pub changes: Vec<CompanyEventChange>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user