investment-portfolio
Investment portfolio tracker — record holdings with buy prices, track performance and P/L, view allocation charts, analyze risk, calculate DCA, manage dividends, rebalance to targets, compare assets, and view sector breakdown. All data stored locally in JSONL format.
Commands
add
Add a holding — specify ticker, number of shares, and purchase price.
CODEBLOCK0
remove
Remove a holding by ticker symbol.
CODEBLOCK1
update
Update the current market price of a holding.
CODEBLOCK2
list
Show all holdings with shares, buy price, and current price.
CODEBLOCK3
summary
Portfolio summary — total value, total cost, overall P/L.
CODEBLOCK4
allocation
ASCII bar chart showing portfolio allocation by ticker as percentage.
CODEBLOCK5
performance
Detailed gain/loss analysis per holding with percentage returns.
CODEBLOCK6
risk
Risk metrics — standard deviation of returns and diversification score.
CODEBLOCK7
rebalance
Generate buy/sell suggestions to match target allocation percentages.
CODEBLOCK8
dca
Dollar-cost averaging calculator — monthly investment table over 12 months.
CODEBLOCK9
dividend
Calculate dividend yield from annual dividend and current price.
CODEBLOCK10
compare
Compare two holdings side by side — shares, prices, and P/L.
CODEBLOCK11
sectors
Sector breakdown with allocation chart. Uses built-in ticker-to-sector mapping.
CODEBLOCK12
export
Export portfolio data as CSV.
CODEBLOCK13
history
Show transaction history from the log file.
CODEBLOCK14
help
CODEBLOCK15
version
CODEBLOCK16
Examples
CODEBLOCK17
Configuration
| Variable | Required | Description |
|---|
| INLINECODE17 | No | Data directory (default: ~/.local/share/investment-portfolio/) |
Data Storage
All data saved in ~/.local/share/investment-portfolio/:
- -
holdings.jsonl — Portfolio holdings (one JSON object per line) - INLINECODE21 — Transaction log
Requirements
- - bash 4.0+
- python3 (for JSONL processing and calculations)
All prices are manually entered — no external API calls.
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
投资组合
投资组合追踪器——记录持仓及买入价格,追踪表现与盈亏,查看配置图表,分析风险,计算定投成本,管理股息,再平衡至目标,比较资产,查看行业分布。所有数据以JSONL格式本地存储。
命令
add
添加持仓——指定股票代码、持股数量和买入价格。
bash
scripts/script.sh add AAPL 10 175.50
scripts/script.sh add BTC 0.5 42000
remove
按股票代码移除持仓。
bash
scripts/script.sh remove TSLA
update
更新持仓的当前市场价格。
bash
scripts/script.sh update AAPL 195.00
list
显示所有持仓的持股数量、买入价格和当前价格。
bash
scripts/script.sh list
summary
投资组合摘要——总价值、总成本、总盈亏。
bash
scripts/script.sh summary
allocation
以ASCII条形图显示按股票代码划分的投资组合配置百分比。
bash
scripts/script.sh allocation
performance
每项持仓的详细盈亏分析,含百分比回报率。
bash
scripts/script.sh performance
risk
风险指标——回报率标准差和分散化评分。
bash
scripts/script.sh risk
rebalance
生成买入/卖出建议以匹配目标配置百分比。
bash
scripts/script.sh rebalance {AAPL:40,GOOGL:30,BTC:30}
dca
定投成本计算器——12个月月度投资表。
bash
scripts/script.sh dca AAPL 500
dividend
根据年股息和当前价格计算股息收益率。
bash
scripts/script.sh dividend AAPL 3.76 195.00
compare
并排比较两项持仓——持股数量、价格和盈亏。
bash
scripts/script.sh compare AAPL GOOGL
sectors
行业分布及配置图表。使用内置的股票代码到行业映射。
bash
scripts/script.sh sectors
export
将投资组合数据导出为CSV格式。
bash
scripts/script.sh export csv
history
显示日志文件中的交易历史。
bash
scripts/script.sh history
help
bash
scripts/script.sh help
version
bash
scripts/script.sh version
示例
bash
构建投资组合
scripts/script.sh add AAPL 10 175
scripts/script.sh add GOOGL 5 140
scripts/script.sh add BTC 0.1 42000
scripts/script.sh update AAPL 195
分析
scripts/script.sh summary
scripts/script.sh allocation
scripts/script.sh performance
scripts/script.sh risk
再平衡
scripts/script.sh rebalance {AAPL:50,GOOGL:30,BTC:20}
scripts/script.sh compare AAPL GOOGL
scripts/script.sh sectors
配置
| 变量 | 必需 | 描述 |
|---|
| PORTFOLIO_DIR | 否 | 数据目录(默认:~/.local/share/investment-portfolio/) |
数据存储
所有数据保存在 ~/.local/share/investment-portfolio/:
- - holdings.jsonl — 投资组合持仓(每行一个JSON对象)
- history.log — 交易日志
要求
- - bash 4.0+
- python3(用于JSONL处理和计算)
所有价格均为手动输入——无外部API调用。
由BytesAgain提供 | bytesagain.com | hello@bytesagain.com