Metadata-Version: 2.5
Name: yenwealth
Version: 0.6.2
Summary: Financial planning tools for individuals living in Japan
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.14
Requires-Dist: arch>=8.0.0
Requires-Dist: beartype>=0.22.2
Requires-Dist: loky>=3.5.2
Requires-Dist: numpy>=2.4.0
Requires-Dist: pandas>=2.3.3
Requires-Dist: pydantic>=2.12.1
Requires-Dist: tqdm>=4.68.3
Provides-Extra: dev
Requires-Dist: codespell; extra == 'dev'
Requires-Dist: icecream; extra == 'dev'
Requires-Dist: mkdocstrings-python; extra == 'dev'
Requires-Dist: pycodestyle; extra == 'dev'
Requires-Dist: pyright; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: zensical; extra == 'dev'
Description-Content-Type: text/markdown

# yenwealth

yenwealth is a Python framework for simulating long-term personal finances for individuals living in Japan.
It aims to make it easy to run long term "what if" financial simulations involving investments held in tax advantaged accounts (iDeCo, NISA, 旧NISA) in Japan.

## Documentation

Read the [yenwealth documentation](https://puchatekwszortach.github.io/yenwealth/)
for setup instructions, model behavior, examples, and the Python API reference.

### Installation

Install with `pip install yenwealth`

## Examples

Here's a minimal example showing a single, deterministic simulation that uses ordinary and NISA accounts:

<!-- front_page_example:start -->
```python
import decimal

import pandas

import yenwealth.investments
import yenwealth.simulations
import yenwealth.utilities


def main() -> None:

    simulation_start_age = 30
    simulation_end_age = 85
    simulation_start_year = 2020

    asset_purchase_strategy = yenwealth.investments.ProportionalAssetPurchaseStrategy(
        weights={"VOO": decimal.Decimal("1.0")}
    )
    asset_sale_strategy = yenwealth.investments.SequentialAssetSaleStrategy(sale_order=["VOO"])

    economic_data_index = range(
        simulation_start_year,
        simulation_start_year + simulation_end_age - simulation_start_age + 1,
    )

    simulated_economic_data = yenwealth.simulations.core.EconomicData(
        return_on_assets_over_time=pandas.DataFrame(
            {"VOO": [decimal.Decimal("0.05")] * len(economic_data_index)},
            index=economic_data_index,
        ),
        inflation_over_time=pandas.DataFrame(
            {"inflation_rate": [decimal.Decimal("0.02")] * len(economic_data_index)},
            index=economic_data_index,
        ),
    )

    inputs = yenwealth.simulations.FinancesSimulatorInputs(
        parameters=yenwealth.simulations.FinancesSimulatorParameters(
            simulation_start_age=simulation_start_age,
            simulation_end_age=simulation_end_age,
            simulation_start_year=simulation_start_year,
        ),
        runtime=yenwealth.simulations.FinancesSimulatorRuntime(
            annual_costs_callable=lambda age: decimal.Decimal(4_000_000),
            earned_annual_income_callable=lambda age: (
                decimal.Decimal(5_000_000) if age < 65 else decimal.Decimal(2_000_000)
            ),
            investment_manager=yenwealth.investments.SimpleInvestmentManager(
                ordinary_investment_account=yenwealth.investments.OrdinaryInvestmentAccount(
                    asset_map={
                        "VOO": yenwealth.investments.Asset(
                            name="VOO",
                            principal=decimal.Decimal(1_000_000),
                            gain=decimal.Decimal(0),
                            annual_management_cost_rate=decimal.Decimal("0.001"),
                        )
                    },
                    asset_purchase_strategy=asset_purchase_strategy,
                    asset_sale_strategy=asset_sale_strategy,
                ),
                nisa_account=yenwealth.investments.NisaAccount(
                    asset_map={
                        "VOO": yenwealth.investments.Asset(
                            name="VOO",
                            principal=decimal.Decimal(500_000),
                            gain=decimal.Decimal(0),
                            annual_management_cost_rate=decimal.Decimal("0.001"),
                        )
                    },
                    asset_purchase_strategy=asset_purchase_strategy,
                    asset_sale_strategy=asset_sale_strategy,
                ),
                simulation_start_age=simulation_start_age,
                simulation_start_year=simulation_start_year,
            )
        ),
        simulated_economic_data=simulated_economic_data,
    )

    simulation_result = yenwealth.simulations.FinancesSimulator(inputs=inputs).run_simulation()
    print(yenwealth.utilities.pretty_format_simulation_summary(simulation_result))


if __name__ == "__main__":
    main()
```
<!-- front_page_example:end -->

While this shows the very basics, other files in `examples` show more realistic scenarios.

- [`examples/simple_simulation.py`](examples/simple_simulation.py) runs one
  deterministic projection.
- [`examples/monte_carlo_simulation.py`](examples/monte_carlo_simulation.py)
  runs multiple projections and summarizes financial targets.
