Skip to content

Commit

Permalink
Don't fail if company is not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaijira committed Dec 22, 2024
1 parent 4646c39 commit 459c4aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/parsers/ib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,18 @@ impl IBParser {
let company_info = self
.companies_info
.get(*symbol)
.ok_or_else(|| anyhow!("Not company info found"))?;
.cloned()
.or_else(|| {
log::error!("Not company info found for {}", symbol);
Some(CompanyInfo {
name: symbol.to_string(),
isin: "".to_string(),
})
})
.unwrap();

Ok(BalanceNote::new(
company_info.clone(),
company_info,
String::from(""),
Decimal::from_str(&decimal::normalize_str(quantity))?
* Decimal::from_str(&decimal::normalize_str(mult))?,
Expand Down
14 changes: 12 additions & 2 deletions src/parsers/ib_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,20 @@ impl IBCSVParser {
let company_info = self
.companies_info
.get(symbol)
.ok_or_else(|| anyhow!("Not company info found"))?;
.cloned()
.or_else({
|| {
log::error!("Not company info found for {}", symbol);
Some(CompanyInfo {
name: symbol.to_string(),
isin: "".to_string(),
})
}
})
.unwrap();

Ok(BalanceNote::new(
company_info.clone(),
company_info,
String::from(""),
Decimal::from_str(&decimal::normalize_str(quantity))?
* Decimal::from_str(&decimal::normalize_str(mult))?,
Expand Down

0 comments on commit 459c4aa

Please sign in to comment.