Skip to content

Commit 459c4aa

Browse files
committed
Don't fail if company is not found.
1 parent 4646c39 commit 459c4aa

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/parsers/ib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,18 @@ impl IBParser {
272272
let company_info = self
273273
.companies_info
274274
.get(*symbol)
275-
.ok_or_else(|| anyhow!("Not company info found"))?;
275+
.cloned()
276+
.or_else(|| {
277+
log::error!("Not company info found for {}", symbol);
278+
Some(CompanyInfo {
279+
name: symbol.to_string(),
280+
isin: "".to_string(),
281+
})
282+
})
283+
.unwrap();
276284

277285
Ok(BalanceNote::new(
278-
company_info.clone(),
286+
company_info,
279287
String::from(""),
280288
Decimal::from_str(&decimal::normalize_str(quantity))?
281289
* Decimal::from_str(&decimal::normalize_str(mult))?,

src/parsers/ib_csv.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,20 @@ impl IBCSVParser {
182182
let company_info = self
183183
.companies_info
184184
.get(symbol)
185-
.ok_or_else(|| anyhow!("Not company info found"))?;
185+
.cloned()
186+
.or_else({
187+
|| {
188+
log::error!("Not company info found for {}", symbol);
189+
Some(CompanyInfo {
190+
name: symbol.to_string(),
191+
isin: "".to_string(),
192+
})
193+
}
194+
})
195+
.unwrap();
186196

187197
Ok(BalanceNote::new(
188-
company_info.clone(),
198+
company_info,
189199
String::from(""),
190200
Decimal::from_str(&decimal::normalize_str(quantity))?
191201
* Decimal::from_str(&decimal::normalize_str(mult))?,

0 commit comments

Comments
 (0)