Skip to content

Commit 95e6904

Browse files
committed
- added progress bar
1 parent 5151364 commit 95e6904

4 files changed

Lines changed: 77 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 53 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ simple_logger = "4.2.0"
3030
time = "0.3"
3131
tokio = "1.35.1"
3232
yahoo_finance_api = { version = "4.1.0", features = ["blocking"] }
33+
indicatif = "0.18.4"

src/divanalysis/main.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use calamine::{open_workbook, Xlsx};
22
use clap::Parser;
33
use polars::prelude::*;
4+
use indicatif::ProgressBar;
45

6+
// TODO: Make progressbar
57
// TODO: convert dividends derived elements into TTM data
68
// TODO: Add support for Revenue and FCF
79
// TODO: Make payout ratio based on FCF
@@ -233,6 +235,16 @@ fn get_companies_data(
233235
database: Option<String>,
234236
target_yield: f64,
235237
) -> 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+
236248
let mut symbols: Vec<&str> = vec![];
237249
let mut share_prices: Vec<f64> = vec![];
238250
let mut curr_divs: Vec<Option<f64>> = vec![];
@@ -418,6 +430,8 @@ fn get_companies_data(
418430
log::info!("DataFrame was written to: {database} file");
419431
}
420432

433+
pb.inc(1);
434+
421435
Ok::<(), &'static str>(())
422436
});
423437

@@ -501,12 +515,18 @@ fn main() -> Result<(), &'static str> {
501515
None
502516
};
503517

518+
519+
504520
//let company = <std::string::String as AsRef<str>>::as_ref(&args.company).to_uppercase();
505521
let companies = args
506522
.company
507523
.iter()
508524
.map(|x| x.to_uppercase())
509525
.collect::<Vec<String>>();
526+
527+
528+
529+
510530
// For no handpicked companies just make overall analysis
511531
if companies.len() == 0 {
512532
if args.list_all {

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ use polygon_client::rest::RESTClient;
1010
use std::collections::BTreeMap;
1111
use std::collections::HashMap;
1212

13+
// TODO: connector reuse of yahoo
14+
15+
1316
pub fn load_list<R>(excel: &mut Xlsx<R>, category: &str) -> Result<DataFrame, &'static str>
1417
where
1518
R: std::io::BufRead,

0 commit comments

Comments
 (0)