This is a program that calculates the price of all your stocks/ETFs/cryptos in your portfolio.
- Get your total portfolio value in any currency
- Real-time price streaming for crypto and forex
- Multiple data sources with fallback support
- Terminal UI with asset allocation visualization
- Support for Taiwan, US stocks/ETFs and cryptocurrencies
- Hot-reload of
config/— editportfolio.tomlortarget_forex.tomlwhile the program is running and changes are picked up automatically (no restart) - One-shot mode (
--once/--json) for scripts, cron jobs and status bars
In the config/ dir. You can add a portfolio.toml to create your assets list.
The program watches the config/ files while running: changing quantities,
adding or removing holdings, or switching the target currency takes effect
within a couple of seconds. Newly added holdings start streaming live prices
automatically; only the one-year historical back-fill still requires a restart.
By default price runs the interactive TUI. Two flags make it usable from
scripts instead:
price --once # fetch prices once, print the portfolio breakdown, exit
price --json # same, but print one machine-readable JSON object--json emits a single JSON object on stdout, e.g. for a status bar:
price --json | jq .total_value_usdThe object contains total_value_usd, target_currency, total_value_target
(null when the display-currency rate is unavailable), category_values_usd,
the raw prices map, a complete flag and any fetch errors. Diagnostics go
to the log file (and, in text mode, warnings to stderr), so stdout stays
parseable. The exit code is 0 when every holding was priced and 1 when the
valuation is incomplete.
By default the program reads config/ and writes to data/ relative to the
current directory. For deployment outside the source tree, override these with
environment variables (the Pyth feed table is compiled into the binary, so no
extra files are needed):
| Variable | Default | Controls |
|---|---|---|
PRICE_CONFIG_DIR |
config |
portfolio.toml, target_forex.toml, … |
PRICE_DATA_DIR |
data |
history.jsonl, history.csv, price.log |
PRICE_LOG |
— | overrides the log file path outright |
Diagnostics are written to the log file (default data/price.log) rather than
the terminal, so they never disturb the TUI.
config/portfolio.toml required
This toml file is used to store your portfolio. You can add as many assets as you want. The program will automatically fetch the price of each asset and calculate the total value of your portfolio in the target currencies.
[US-Stock]
amd = 10
[US-ETF]
QQQ = 2
[TW-Stock]
2330 = 10
[TW-ETF]
0050 = 200
[Crypto]
eth = 0.5
sol = 0.5
[Forex]
USD = 100
TWD = 10000config/api_key.toml optional
This file is used to store your API keys. You can add as many API keys as you want. The program will automatically fetch the price of each asset and calculate the total value of your portfolio in the target currencies.
"alpha_vantage_api_key" = "XXXXXXXXXXXXXXXX"
"exchangerate_api_key" = "xxxxxxxxxxxxxxxxxxxxxxxx"config/target_forex.toml optional
This file is used to store your target currencies. You can add as many target currencies as you want. The program will automatically fetch the price of each asset and calculate the total value of your portfolio in the target currencies.
Default is USD.
target = "TWD"- Fetch stock prices
- Fetch ETF prices
- Fetch crypto prices
- Fetch forex prices
- Calculate total portfolio value in USD
- target forex calculation
- alpha_vantage API
- binance API
- exchange_rate API
- pyth(pyth network) API
- redstone API
- yahoo finance API
- TWSE API
- Basic layout
- Portfolio table
- Portfolio value
- Colors
- Charts
