Skip to content

Commit

Permalink
save cache
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Dec 12, 2024
1 parent 6b33101 commit 628e44a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/warehouse_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ pub enum AnalyticsSub {

TradesMatching {
#[clap(long)]
/// start day (exclusive) of trades YYYY-MM-DD
start_day: String,
#[clap(long)]
/// end day (exclusive) of trades YYYY-MM-DD
end_day: String,

#[clap(long)]
Expand Down Expand Up @@ -234,14 +236,17 @@ impl WarehouseCli {
start_day,
end_day,
} => {
let pool = try_db_connection_pool(self).await?;

let dir: PathBuf = PathBuf::from(".");

if *clear_cache {
Matching::clear_cache(&dir)?;
}

if replay_balances.is_none() && match_simple_dumps.is_none() {
bail!("nothing to do. Must enter --replay-balance or --match-simple-dumps")
}
let pool = try_db_connection_pool(self).await?;

let mut m = Matching::read_cache_from_file(&dir).unwrap_or_default();
if let Some(top_n) = replay_balances {
let _ = m
Expand All @@ -250,7 +255,7 @@ impl WarehouseCli {
date_util::parse_date(start_day),
date_util::parse_date(end_day),
*top_n,
Some(dir),
Some(dir.clone()),
)
.await;
}
Expand All @@ -265,7 +270,10 @@ impl WarehouseCli {
.await?;
}

println!("{:?}", &m.definite);
m.write_cache_to_file(&dir)?;
m.write_definite_to_file(&dir)?;

println!("{:#}", json!(&m.definite));
}
},
};
Expand Down

0 comments on commit 628e44a

Please sign in to comment.