Releases: acturtle/cashflower
v0.7.3
Bug fixes:
- Fixed error in result aggregation - resolved an issue where a shape mismatch could occur when calculating results if only some variables were included in the output. The
multiplier
is now correctly applied only to variables listed inOUTPUT_COLUMNS
, preventing this error.
v0.7.2
Updates:
- removed unnecessary data transposing for increased efficiency,
- added a description of the release process to the documentation,
- updated to numpy 2.0.1 for better compatibility,
- made minor documentation fixes.
v0.7.1
Updates:
- refactored codebase for improved readability and maintainability,
- added support for handling graphs with strongly connected components (SCCs).
v0.7.0
In this release, we have introduced a new feature: stochastic variables.
To run the model stochastically, set the NUM_STOCHASTIC_SCENARIOS
with the desired number of stochastic scenarios.
settings = {
# ...
"NUM_STOCHASTIC_SCENARIOS": 10,
}
Next define create stochastic variables. These variables that have two parameters: t
and stoch
.
@variable()
def discount_rate(t, stoch):
return assumption["discount_rates"+stoch][t]
@variable()
def pv_premiums(t, stoch):
if t == settings["T_MAX_CALCULATION"]:
return premium(t)
else:
return premium(t) + pv_premiums(t+1, stoch) * discount_rate(t+1, stoch)
These stochastic variables will be calculated 10 times, where stoch
value ranging from 1
to 10
.
The output will show the average result from these scenarios.
v0.6.2
In this latest release, the primary focus has been on refining the order of variable calculation within cyclic relationships.
The key improvements in this version:
-
Addition of the
cycle_order
attribute - we've introduced thecycle_order
attribute within theVariable
class. This attribute contains an integer that defines the calculation order within groups of variables forming cycles. -
Prevention of bidirectional recursion - bidirectional recursion, where a variable calls both
t-...
andt+...
in its definition, is now explicitly disallowed in the models. This restriction helps maintain clear and manageable relationships between variables. -
Error handling for negative index calls - the package raises errors for calls with negative indexes. When a model variable is invoked for
t<0
, the package prompts an error, preventing potential inconsistencies in computations.
v0.6.1
New in this release:
- new feature for model variables that don’t aggregate,
- eliminated redundant warnings for non-git repository folders,
- enhanced and updated the documentation.
New feature:
Now, users can specify the aggregation_type
for variables.
Default behaviour:
All results are summed automatically.
@variable()
def my_variable(t):
# code
This is equivalent to explicitly defining aggregation as sum:
@variable(aggregation_type="sum")
def my_variable(t):
# code
This default behavior suits most financial scenarios involving cash flows like premiums and expenses.
Additional customization:
Users can now specify variables where results are sourced only from the first model point:
@variable(aggregation_type="first")
def my_variable(t):
# code
This configuration ensures that only the results from the first model point are included.
Suitable for containing results like interest rate curves or projection years.
v0.6.0
In this release, we have focused on enhancing the command lines arguments.
Now, you can run the model for the specific version of the runplan and model point ID.
For example, to run the 3rd version for model point "A123", use the following command:
python run.py --version 3 --id "A123"
This featured required a couple of changes to the run.py
script:
- the
start()
function has been renamed torun()
to align with the script's name, - the
run()
function takes two optional arguments: settings and the path to the current file.
How to upgrade to version >= 0.6.0?
To upgrade your existing model to version >= 0.6.0 of the cashflower, insert the following code into your run.py
script:
import os
from cashflower import run
from settings import settings
if __name__ == "__main__":
output = run(settings=settings, path=os.path.dirname(__file__))
v0.5.7
In this release, we're introducing a new configuration setting called GROUP_BY_COLUMN
. This feature enables the creation of aggregated results based on specified groups.
To generate results grouped by a specific column, such as product_code
, configure the settings as shown below:
settings.py
settings = {
"AGGREGATE": True,
"GROUP_BY_COLUMN": "product_code",
...
}
Please note that the product_code
column must be part of the main
model point set, as demonstrated below:
input.py
main = ModelPointSet(data=pd.DataFrame({
"id": [1, 2, 3],
"product_code": ["A", "B", "A"]
}))
The output will provide aggregated results grouped by the chosen column, for example:
t,product_code,fund_value
0,A,24000
1,A,24048
2,A,24096.1
3,A,24144.29
0,B,3000
1,B,3006
2,B,3012.01
3,B,3018.03
v0.5.5
In this release, we have focused on enhancing the package's stability and maintainability.
Our efforts include the following improvements:
- fixed a bug which logged the runplan version multiple times when multiprocessing
- renamed
cashflow.py
tocore.py
- this change aligns with the widely-accepted convention of using "core.py" to designate a central module within a Python package, emphasizing its fundamental role, - moved
pytest
configuration frompytest.ini
topyproject.toml
to reduce the number of configuration files, - added configuration for
ruff
(linter tool) inpyproject.toml
, - added documentation on development testing and files overview,
- improved speed of the
discount()
function by incorporating@cython.boundscheck(False)
and@cython.wraparound(False)
.
v0.5.4
For users:
In this release, we've introduced a new discount()
function. Written in Cython, its primary purpose is to optimize the speed of discounting calculations, commonly used in actuarial cash flow models.
Example usage:
from cashflower import discount
@variable(array=True)
def present_value():
return discount(cash_flows=cash_flow(), discount_rates=discount_rate())
This addition is aimed at enhancing the efficiency of your actuarial modeling tasks by accelerating the discounting process.
For developers:
This release marks the integration of Cython, bringing changes to our release process.
We've implemented a new GitHub workflow that generates wheel packages for various operating systems and Python versions. Unlike versions up to 0.5.3, which offered a single wheel file with the "py3-none-any.whl" suffix, version 0.5.4 provides multiple wheel files tailored to different Python environments.
You can explore these options in the PyPI "Download files" section for increased flexibility and compatibility.
Version <=0.5.3
Version 0.5.4