Life-cycle portfolio choice with liquidity risk, labor-income risk, and consumption adjustment frictions
Project description
liquiditylife
An open-source Python package for liquidity-aware life-cycle portfolio choice, built for interactive exploration of portfolio choice under labor-income risk and consumption rigidity.
Overview
liquiditylife implements a life-cycle portfolio choice model with:
- Risky labor income correlated with stock-market crashes
- Consumption adjustment frictions (asymmetric costs of cutting spending)
- Time-varying equity premium with return predictability
- Illiquid savings during working life and retirement flow income
The package solves for optimal consumption and equity allocation policies via backward induction, simulates household cohorts, and exports visualization-ready outputs for dashboards and research.
Asset Allocation Calculator
Get an instant, personalized recommendation without running the solver:
from liquiditylife import recommend, UserInputs
rec = recommend(UserInputs(
age=35,
annual_income=150_000,
liquid_savings=200_000,
monthly_fixed_expenses=5_000,
risk_tolerance=3, # 1=aggressive, 5=conservative
))
print(f"Stock share: {rec.stock_share_pct}%")
print(f"Emergency fund: {rec.emergency_fund_months} months")
print(f"Stocks: ${rec.stocks_dollars:,.0f}, Safe: ${rec.safe_dollars:,.0f}")
Or from the command line:
liquiditylife calculator recommend \
--age 35 --income 150000 --savings 200000 --expenses 5000 --risk 3
See the Calculator docs for details.
Installation
pip install liquiditylife
With optional extras:
pip install liquiditylife[viz] # Streamlit, Plotly, Panel
pip install liquiditylife[fast] # Numba acceleration
pip install liquiditylife[dev] # Development tools
Quick Start (Research API)
from liquiditylife import load_calibration, solve_model, simulate_cohorts, policy_surface
cal = load_calibration("adams_high_friction")
solution = solve_model(cal)
sim = simulate_cohorts(solution, n_households=100_000, seed=42)
surface = policy_surface(solution, age=35)
CLI
liquiditylife solve --calibration adams_high_friction
liquiditylife simulate --calibration adams_high_friction --n 100000
liquiditylife sweep policy-surface --age 35 --calibration adams_high_friction
liquiditylife list-calibrations
liquiditylife calculator recommend --age 35 --income 150000 --savings 200000 --expenses 5000 --risk 3
Documentation
Full documentation is available at engineerinvestor.github.io/liquiditylife.
Citation
This package implements a model inspired by:
Adams, Patrick. "Stocks for the Long Run or Liquidity? Tax Data Evidence and Portfolio Choice Implications." MIT Sloan School of Management, January 7, 2026. https://patrick-adams.com/jmp
If you use liquiditylife in academic work, please cite the software as:
@software{liquiditylife,
author = {Engineer Investor},
title = {liquiditylife: Life-Cycle Portfolio Choice with Liquidity Risk},
year = {2026},
url = {https://github.com/engineerinvestor/liquiditylife},
version = {0.1.0},
license = {MIT}
}
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file liquiditylife-0.1.0.tar.gz.
File metadata
- Download URL: liquiditylife-0.1.0.tar.gz
- Upload date:
- Size: 85.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9ade37a52b2b8b0ac17ade33602e16826e3137dedbae8d2f00d92e0517ec058
|
|
| MD5 |
b282bc650fbdde76b75e82a67fb539d8
|
|
| BLAKE2b-256 |
12976887223c383b91e9ca6ad7bc49039248d2a8ccbcd9f1d6bb658599d281fb
|
Provenance
The following attestation bundles were made for liquiditylife-0.1.0.tar.gz:
Publisher:
release.yml on engineerinvestor/liquiditylife
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liquiditylife-0.1.0.tar.gz -
Subject digest:
a9ade37a52b2b8b0ac17ade33602e16826e3137dedbae8d2f00d92e0517ec058 - Sigstore transparency entry: 1221259147
- Sigstore integration time:
-
Permalink:
engineerinvestor/liquiditylife@cd51b35049c290d95ed7fb486ef0fd0aca434f80 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/engineerinvestor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd51b35049c290d95ed7fb486ef0fd0aca434f80 -
Trigger Event:
release
-
Statement type:
File details
Details for the file liquiditylife-0.1.0-py3-none-any.whl.
File metadata
- Download URL: liquiditylife-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c33cf0fc7a14405578f65d5a88e7f449d2b2dc00b0ca650bfcf71811a5f835
|
|
| MD5 |
66f1809e6fd1ee25e134bf570deb50eb
|
|
| BLAKE2b-256 |
a62d055fcb1544aa1af581b98da9153846417f4394d6ca8148b85f6bc5748394
|
Provenance
The following attestation bundles were made for liquiditylife-0.1.0-py3-none-any.whl:
Publisher:
release.yml on engineerinvestor/liquiditylife
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liquiditylife-0.1.0-py3-none-any.whl -
Subject digest:
f3c33cf0fc7a14405578f65d5a88e7f449d2b2dc00b0ca650bfcf71811a5f835 - Sigstore transparency entry: 1221259229
- Sigstore integration time:
-
Permalink:
engineerinvestor/liquiditylife@cd51b35049c290d95ed7fb486ef0fd0aca434f80 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/engineerinvestor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd51b35049c290d95ed7fb486ef0fd0aca434f80 -
Trigger Event:
release
-
Statement type: