Compound — Compound Interest Calculator
Compound is a command-line compound interest calculator that helps you plan investments, compare interest rates, build amortization schedules, and project financial growth over time.
All calculation history is stored in ~/.compound/data.jsonl as JSONL records for future reference and comparison.
Prerequisites
- - Python 3.8+ with standard library
- INLINECODE1 shell
Commands
calculate
Calculate compound interest for a given principal, rate, and time period.
Environment Variables:
- -
PRINCIPAL (required) — Initial investment amount - INLINECODE4 (required) — Annual interest rate as percentage (e.g., 5.5)
- INLINECODE5 (required) — Number of years
- INLINECODE6 — Compounding frequency:
daily, monthly, quarterly, annually (default: monthly) - INLINECODE11 — Regular contribution amount (default: 0)
- INLINECODE12 — Contribution frequency:
monthly, quarterly, annually (default: monthly)
Example:
CODEBLOCK0
compare
Compare multiple interest rate or compounding frequency scenarios side by side.
Environment Variables:
- -
PRINCIPAL (required) — Initial investment amount - INLINECODE18 (required) — Comma-separated list of rates to compare (e.g., "3,5,7,10")
- INLINECODE19 (required) — Number of years
- INLINECODE20 — Compounding frequency (default: monthly)
schedule
Generate a detailed payment/growth schedule showing balances at each period.
Environment Variables:
- -
PRINCIPAL (required) — Initial investment amount - INLINECODE23 (required) — Annual interest rate as percentage
- INLINECODE24 (required) — Number of years
- INLINECODE25 — Compounding frequency (default: monthly)
- INLINECODE26 — Regular contribution amount (default: 0)
table
Display a year-by-year summary table of investment growth.
Environment Variables:
- -
PRINCIPAL (required) — Initial investment amount - INLINECODE29 (required) — Annual interest rate
- INLINECODE30 (required) — Number of years
- INLINECODE31 — Regular contribution (default: 0)
rate
Calculate the required interest rate to reach a financial goal.
Environment Variables:
- -
PRINCIPAL (required) — Starting amount - INLINECODE34 (required) — Target amount
- INLINECODE35 (required) — Time period in years
- INLINECODE36 — Compounding frequency (default: monthly)
goal
Calculate how long it takes to reach a savings goal.
Environment Variables:
- -
PRINCIPAL (required) — Starting amount - INLINECODE39 (required) — Goal amount
- INLINECODE40 (required) — Annual interest rate
- INLINECODE41 — Regular contribution (default: 0)
chart
Generate an ASCII chart of investment growth over time.
Environment Variables:
- -
PRINCIPAL (required) — Initial amount - INLINECODE44 (required) — Annual interest rate
- INLINECODE45 (required) — Number of years
- INLINECODE46 — Chart width in characters (default: 60)
- INLINECODE47 — Chart height in lines (default: 20)
export
Export calculation history to a file.
Environment Variables:
- -
OUTPUT — Output file path (default: stdout) - INLINECODE50 — Export format:
json, csv, jsonl (default: json) - INLINECODE54 — Specific calculation ID to export (default: all)
config
View or update default configuration settings.
Environment Variables:
- -
KEY — Configuration key to set - INLINECODE57 — Configuration value
history
View past calculations with their results.
Environment Variables:
- -
LIMIT — Maximum entries to display (default: 20) - INLINECODE60 — Sort by:
date, principal, rate, total (default: date)
help
Display usage information and available commands.
version
Display the current version of the compound tool.
Data Storage
All calculations are stored in ~/.compound/data.jsonl. Each line is a JSON object with fields:
- -
id — Unique calculation identifier - INLINECODE69 — ISO 8601 creation time
- INLINECODE70 — Calculation type (calculate, compare, goal, etc.)
- INLINECODE71 — Input parameters
- INLINECODE72 — Calculation results (final amount, interest earned, etc.)
Configuration
Config stored in ~/.compound/config.json:
- -
default_frequency — Default compounding frequency (default: monthly) - INLINECODE75 — Currency symbol for display (default: $)
- INLINECODE76 — Number of decimal places (default: 2)
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
Compound — 复利计算器
Compound 是一款命令行复利计算器,可帮助您规划投资、比较利率、构建摊销计划并预测长期财务增长。
所有计算历史记录均以 JSONL 格式存储在 ~/.compound/data.jsonl 中,供日后查阅和比较。
前提条件
- - Python 3.8+(含标准库)
- bash shell
命令
calculate
计算给定本金、利率和时间段的复利。
环境变量:
- - PRINCIPAL(必填)— 初始投资金额
- RATE(必填)— 年利率百分比(例如 5.5)
- YEARS(必填)— 年数
- FREQUENCY — 复利频率:daily(每日)、monthly(每月)、quarterly(每季度)、annually(每年)(默认:monthly)
- CONTRIBUTION — 定期缴款金额(默认:0)
- CONTRIB_FREQ — 缴款频率:monthly(每月)、quarterly(每季度)、annually(每年)(默认:monthly)
示例:
bash
PRINCIPAL=10000 RATE=7.5 YEARS=20 FREQUENCY=monthly bash scripts/script.sh calculate
compare
并排比较多种利率或复利频率方案。
环境变量:
- - PRINCIPAL(必填)— 初始投资金额
- RATES(必填)— 要比较的利率列表,以逗号分隔(例如 3,5,7,10)
- YEARS(必填)— 年数
- FREQUENCY — 复利频率(默认:monthly)
schedule
生成详细的付款/增长计划,显示每个期间的余额。
环境变量:
- - PRINCIPAL(必填)— 初始投资金额
- RATE(必填)— 年利率百分比
- YEARS(必填)— 年数
- FREQUENCY — 复利频率(默认:monthly)
- CONTRIBUTION — 定期缴款金额(默认:0)
table
显示逐年投资增长汇总表。
环境变量:
- - PRINCIPAL(必填)— 初始投资金额
- RATE(必填)— 年利率
- YEARS(必填)— 年数
- CONTRIBUTION — 定期缴款(默认:0)
rate
计算达到财务目标所需的利率。
环境变量:
- - PRINCIPAL(必填)— 起始金额
- TARGET(必填)— 目标金额
- YEARS(必填)— 时间周期(年)
- FREQUENCY — 复利频率(默认:monthly)
goal
计算达到储蓄目标所需的时间。
环境变量:
- - PRINCIPAL(必填)— 起始金额
- TARGET(必填)— 目标金额
- RATE(必填)— 年利率
- CONTRIBUTION — 定期缴款(默认:0)
chart
生成投资随时间增长的 ASCII 图表。
环境变量:
- - PRINCIPAL(必填)— 初始金额
- RATE(必填)— 年利率
- YEARS(必填)— 年数
- WIDTH — 图表宽度(字符数)(默认:60)
- HEIGHT — 图表高度(行数)(默认:20)
export
将计算历史记录导出到文件。
环境变量:
- - OUTPUT — 输出文件路径(默认:标准输出)
- FORMAT — 导出格式:json、csv、jsonl(默认:json)
- CALC_ID — 要导出的特定计算 ID(默认:全部)
config
查看或更新默认配置设置。
环境变量:
- - KEY — 要设置的配置键
- VALUE — 配置值
history
查看过去的计算结果。
环境变量:
- - LIMIT — 最大显示条目数(默认:20)
- SORT — 排序方式:date(日期)、principal(本金)、rate(利率)、total(总额)(默认:date)
help
显示使用信息和可用命令。
version
显示 Compound 工具的当前版本。
数据存储
所有计算均存储在 ~/.compound/data.jsonl 中。每行是一个 JSON 对象,包含以下字段:
- - id — 唯一计算标识符
- timestamp — ISO 8601 格式的创建时间
- type — 计算类型(calculate、compare、goal 等)
- params — 输入参数
- result — 计算结果(最终金额、赚取利息等)
配置
配置存储在 ~/.compound/config.json 中:
- - defaultfrequency — 默认复利频率(默认:monthly)
- currencysymbol — 显示用的货币符号(默认:$)
- decimal_places — 小数位数(默认:2)
由 BytesAgain 提供支持 | bytesagain.com | hello@bytesagain.com