|
FinanceSim 0.1.0
Financial Simulation Library
|
Savings account - earns APY interest, compounded monthly. More...
#include <savings_account.hpp>
Public Member Functions | |
| SavingsAccount (std::string id, std::string name, double apy, double initial_balance=0.0, std::string routing_tag="savings", Schedule schedule=make_savings_schedule()) | |
| ~SavingsAccount () override=default | |
| double | apy () const |
| Get the APY (annual percentage yield) | |
| void | initialize (EventBus &bus) override |
| void | update (SimTime time) override |
| void | finalize () override |
| void | reset () override |
| Reset model to initial state (for replay) | |
Public Member Functions inherited from financesim::AccountBase | |
| AccountBase (std::string id, std::string name, std::string routing_tag, double initial_balance=0.0, Schedule schedule=make_account_schedule()) | |
| virtual | ~AccountBase ()=default |
| const std::string & | id () const override |
| Unique identifier for this model instance. | |
| const std::string & | name () const override |
| Human-readable name/description. | |
| const Schedule & | schedule () const override |
| Get the model's execution schedule. | |
| const std::string & | routing_tag () const |
| Get the routing tag used to match income/expense events. | |
| double | balance () const |
| Get current balance. | |
Public Member Functions inherited from financesim::Model | |
| virtual | ~Model ()=default |
Protected Member Functions | |
| void | on_income (const IncomeEvent &event) override |
| Called when an income event is routed to this account. | |
| void | on_expense (const ExpenseEvent &event) override |
| Called when an expense event is routed to this account. | |
Protected Member Functions inherited from financesim::AccountBase | |
| EventBus & | bus () |
| void | deposit (SimTime time, double amount, const std::string &reason) |
| Deposit funds into the account. | |
| void | withdraw (SimTime time, double amount, const std::string &reason) |
| Withdraw funds from the account. | |
| template<typename EventType , typename... Args> | |
| void | emit (SimTime time, Args &&... args) |
Protected Member Functions inherited from financesim::Model | |
| Model ()=default | |
Private Member Functions | |
| void | accrue_interest_up_to (SimTime time) |
Private Attributes | |
| double | apy_ |
| SimTime | last_interest_time_ = 0.0 |
Savings account - earns APY interest, compounded monthly.
Definition at line 15 of file savings_account.hpp.
| financesim::SavingsAccount::SavingsAccount | ( | std::string | id, |
| std::string | name, | ||
| double | apy, | ||
| double | initial_balance = 0.0, |
||
| std::string | routing_tag = "savings", |
||
| Schedule | schedule = make_savings_schedule() |
||
| ) |
Create a savings account
| id | Unique identifier |
| name | Human-readable name |
| apy | Annual Percentage Yield (e.g., 0.05 for 5%) |
| initial_balance | Starting balance |
| routing_tag | Tag for routing events (defaults to "savings") |
| schedule | Execution schedule (default: monthly updates for interest) |
Definition at line 6 of file savings_account.cpp.
|
overridedefault |
Definition at line 53 of file savings_account.cpp.
References apy_, financesim::AccountBase::balance(), financesim::AccountBase::deposit(), financesim::AccountBase::emit(), and last_interest_time_.
Referenced by on_expense(), on_income(), and update().
|
inline |
Get the APY (annual percentage yield)
Definition at line 32 of file savings_account.hpp.
References apy_.
Referenced by PYBIND11_MODULE().
|
overridevirtual |
Called once after simulation ends Use for cleanup, final calculations, releasing resources
Reimplemented from financesim::AccountBase.
Definition at line 29 of file savings_account.cpp.
References financesim::AccountBase::finalize().
Called once before simulation starts Use for setup, subscribing to events, allocating resources
Reimplemented from financesim::AccountBase.
Definition at line 18 of file savings_account.cpp.
References financesim::AccountBase::bus(), and financesim::AccountBase::initialize().
|
overrideprotectedvirtual |
Called when an expense event is routed to this account.
Reimplemented from financesim::AccountBase.
Definition at line 47 of file savings_account.cpp.
References accrue_interest_up_to(), financesim::AccountBase::emit(), and financesim::AccountBase::on_expense().
|
overrideprotectedvirtual |
Called when an income event is routed to this account.
Reimplemented from financesim::AccountBase.
Definition at line 41 of file savings_account.cpp.
References accrue_interest_up_to(), financesim::AccountBase::emit(), and financesim::AccountBase::on_income().
|
overridevirtual |
Reset model to initial state (for replay)
Reimplemented from financesim::AccountBase.
Definition at line 36 of file savings_account.cpp.
References last_interest_time_, and financesim::AccountBase::reset().
Called at each scheduled execution time Must be deterministic given the same inputs and time
Reimplemented from financesim::AccountBase.
Definition at line 23 of file savings_account.cpp.
References accrue_interest_up_to(), and financesim::AccountBase::emit().
|
private |
Definition at line 46 of file savings_account.hpp.
Referenced by accrue_interest_up_to(), and apy().
|
private |
Definition at line 47 of file savings_account.hpp.
Referenced by accrue_interest_up_to(), and reset().