diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/cli.rs | 3 | ||||
-rw-r--r-- | src/lib.rs | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 5ca388b..2dae8ec 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -2,7 +2,8 @@ use hiccup::{SimUpdate::*, SimUpdates, Simulation}; fn main() { let mut sim = Simulation::new(390_000., 0.028, 30); - let updates: SimUpdates = Amortize(12_000.).every(12).and(Amortize(30_000.).at(1)); + let updates: SimUpdates = Amortize(12_000.).every(12).and(Amortize(30_000.).at(1)) + .and(SetI1(0.01).at(10)); // let mut sim = Simulation::new(200_000., 0.01621, 30); // let updates: SimUpdates = SimUpdates::default(); @@ -90,6 +90,10 @@ impl Simulation { self.payed.principal += principal; self.payed_amortized += principal; } + SimUpdate::SetI1(i1) => { + st.i12 = i1 / 12.0; + st.calculate_monthly(); + } } } } @@ -261,6 +265,7 @@ impl SimUpdates { #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum SimUpdate { Amortize(f64), + SetI1(f64), } impl fmt::Display for SimUpdate { @@ -270,6 +275,9 @@ impl fmt::Display for SimUpdate { Self::Amortize(principal) => { write!(f, "{principal:.2} amortized to reduce pending quotas]") } + Self::SetI1(i1) => { + write!(f, "I1 set to {i1:.2}]") + } } } } @@ -296,6 +304,9 @@ fn flatten_amortizations(updates: Vec<SimUpdate>) -> Vec<SimUpdate> { SimUpdate::Amortize(n) => { amortized += n; } + SimUpdate::SetI1(_) => { + result.push(update); + } } } if amortized > 0. { |