FinanceSim 0.1.0
Financial Simulation Library
Loading...
Searching...
No Matches
savings_account.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace financesim {
6
9 Schedule s;
10 s.rate = 30.0; // Monthly interest calculation
11 return s;
12}
13
16public:
24 SavingsAccount(std::string id, std::string name,
25 double apy,
26 double initial_balance = 0.0,
27 std::string routing_tag = "savings",
29 ~SavingsAccount() override = default;
30
32 double apy() const { return apy_; }
33
34 void initialize(EventBus& bus) override;
35 void update(SimTime time) override;
36 void finalize() override;
37 void reset() override;
38
39protected:
40 void on_income(const IncomeEvent& event) override;
41 void on_expense(const ExpenseEvent& event) override;
42
43private:
45
46 double apy_;
48};
49
50} // namespace financesim
const std::string & name() const override
Human-readable name/description.
const std::string & routing_tag() const
Get the routing tag used to match income/expense events.
void emit(SimTime time, Args &&... args)
const Schedule & schedule() const override
Get the model's execution schedule.
Event emitted when an expense occurs.
Definition event.hpp:62
Event emitted when income is received.
Definition event.hpp:39
Savings account - earns APY interest, compounded monthly.
~SavingsAccount() override=default
void reset() override
Reset model to initial state (for replay)
void initialize(EventBus &bus) override
void on_income(const IncomeEvent &event) override
Called when an income event is routed to this account.
void accrue_interest_up_to(SimTime time)
void on_expense(const ExpenseEvent &event) override
Called when an expense event is routed to this account.
double apy() const
Get the APY (annual percentage yield)
void update(SimTime time) override
double SimTime
Represents a point in simulation time (continuous, in days)
Definition time.hpp:6
Schedule make_savings_schedule()
Helper to create default schedule for savings accounts (monthly interest)