|
1 | 1 | use calamine::{open_workbook, Xlsx}; |
2 | 2 | use clap::Parser; |
3 | 3 | use polars::prelude::*; |
| 4 | +use indicatif::ProgressBar; |
4 | 5 |
|
| 6 | +// TODO: Make progressbar |
5 | 7 | // TODO: convert dividends derived elements into TTM data |
6 | 8 | // TODO: Add support for Revenue and FCF |
7 | 9 | // TODO: Make payout ratio based on FCF |
@@ -233,6 +235,16 @@ fn get_companies_data( |
233 | 235 | database: Option<String>, |
234 | 236 | target_yield: f64, |
235 | 237 | ) -> Result<(), &'static str> { |
| 238 | + |
| 239 | + |
| 240 | + // If we have explicitly given companies then make progress bar with specific length |
| 241 | + // otherwise just make the one without length |
| 242 | + let pb = if companies.is_empty() { |
| 243 | + ProgressBar::no_length() |
| 244 | + } else { |
| 245 | + ProgressBar::new(companies.len() as u64) |
| 246 | + }; |
| 247 | + |
236 | 248 | let mut symbols: Vec<&str> = vec![]; |
237 | 249 | let mut share_prices: Vec<f64> = vec![]; |
238 | 250 | let mut curr_divs: Vec<Option<f64>> = vec![]; |
@@ -418,6 +430,8 @@ fn get_companies_data( |
418 | 430 | log::info!("DataFrame was written to: {database} file"); |
419 | 431 | } |
420 | 432 |
|
| 433 | + pb.inc(1); |
| 434 | + |
421 | 435 | Ok::<(), &'static str>(()) |
422 | 436 | }); |
423 | 437 |
|
@@ -501,12 +515,18 @@ fn main() -> Result<(), &'static str> { |
501 | 515 | None |
502 | 516 | }; |
503 | 517 |
|
| 518 | + |
| 519 | + |
504 | 520 | //let company = <std::string::String as AsRef<str>>::as_ref(&args.company).to_uppercase(); |
505 | 521 | let companies = args |
506 | 522 | .company |
507 | 523 | .iter() |
508 | 524 | .map(|x| x.to_uppercase()) |
509 | 525 | .collect::<Vec<String>>(); |
| 526 | + |
| 527 | + |
| 528 | + |
| 529 | + |
510 | 530 | // For no handpicked companies just make overall analysis |
511 | 531 | if companies.len() == 0 { |
512 | 532 | if args.list_all { |
|
0 commit comments