A modern CLI application for monitoring live stock prices in real-time with portfolio tracking.
π Real-time Updates - Stock prices update every 60 seconds
π Stock Search - Search and add any stock
π Portfolio Tracking - Track quantities, invested amounts, and total portfolio value
π± BUY/SELL Transactions - Record buy and sell transactions with historical prices
:chart: Realized & Unrealized P&L - Track profits/losses from trades and current positions
:receipt: Transaction History - View all transactions for any stock with date picker
:floppy_disk: Persistent Portfolio - Portfolio saved to JSON file, survives restarts
:point_down_1: Interactive Table - Select rows, move stocks up/down, delete stocks
β¨οΈ Keyboard Shortcuts - Full keyboard control (b/s/d/o/x/h/arrows)
The easiest way to install on macOS:
brew install darul75/market-cli/market-cliTo update to the latest version:
brew upgrade darul75/market-cli/market-cliIf you prefer to build from source, you'll need Bun installed.
- Modern terminal (WezTerm, Alacritty, iTerm2, etc. recommended)
-
Install dependencies:
bun install
-
Build the application:
bun run build
-
Run the application:
bun run src/main.ts # or for production bun run dist/main.js -
Exit the application: Press
Ctrl+Cto exit gracefully
# Install dependencies
bun install
# Build for production
bun run build
# Run in dev mode
bun run dev
# Run from source
bun run src/main.ts
# Run production build
bun run start
# Type checking
bun run type-check- View stocks - The main table shows all tracked stocks with live prices
- Select a stock - Click on any row or use β/β arrows to select (shows action buttons)
- Add stocks - Type in the search panel to find and add new stocks (saved to portfolio)
- Buy stocks - Press
bor click π button to record a BUY transaction - Sell stocks - Press
sor click π button to record a SELL transaction - View history - Press
oor click π button to see all transactions for a stock - Move stocks - Use πΌ/π½ buttons to reorder stocks (order persisted)
- Delete stocks - Press
dor click β button to remove stock from portfolio - Delete transactions - Press
xto delete selected transaction (in history panel) - View help - Press
hto see all keyboard shortcuts
| Key | Action |
|---|---|
β / β |
Navigate stock selection |
b |
Open buy dialog (stock selected) |
s |
Open sell dialog (stock selected) |
d |
Delete stock confirmation (stock selected) |
o |
Toggle transaction history (stock selected) |
x |
Delete selected transaction |
Enter |
Confirm dialog |
Esc |
Close dialog / Cancel |
h |
Show help dialog |
| Column | Description |
|---|---|
# |
Row number |
Symbol |
Stock ticker symbol |
Price |
Current market price |
Change |
Price change today |
Qty |
Current share quantity held |
Invested |
Total amount invested (from BUY transactions) |
Value |
Current market value (Qty Γ Price) |
Unreal. |
Unrealized P&L (current value - invested) |
Real. |
Realized P&L (from completed SELL transactions) |
Actions |
Action buttons (buy, sell, history, move, delete) |
| Button | Action | Description |
|---|---|---|
| π | Buy | Record a BUY transaction |
| π | Sell | Record a SELL transaction |
| π | History | View transaction history |
| πΌ | Move Up | Move stock up in the list |
| π½ | Move Down | Move stock down in the list |
| β | Delete | Remove stock from portfolio |
- Portfolio is saved to
data/portfolio.json - Automatically loaded on startup
- Changes are saved immediately (add stock, buy, sell, delete)
- Stocks remain in portfolio even with 0 transactions (can add new transactions later)
- Supports empty portfolio - app shows main UI with "No stocks" message
- BUY transactions - Record purchases with date, quantity, and price
- SELL transactions - Record sales with FIFO cost basis calculation
- Date picker - Select transaction date from calendar
- Historical prices - Fetch price from Yahoo Finance for transaction date
- FIFO accounting - First-In-First-Out for realized P&L calculation
Press π on any stock to view all transactions:
ββ Transaction History: AAPL βββββββββββββββββββββββββββββββββββββββββ
β β
β BUY 2026-03-01 10 shares @ β¬200.00 = β¬2,000.00 β
β SELL 2026-03-15 5 shares @ β¬220.00 = β¬1,100.00 β
β β
β Remaining: 5 shares | Avg Cost: β¬200.00 β
β Realized P&L: +β¬100.00 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-
Unrealized P&L - Shows gain/loss on current holdings
- Formula: (Current Price Γ Qty) - Total Invested
- Updates in real-time with price changes
-
Realized P&L - Shows profit/loss from completed trades
- Uses FIFO (First-In-First-Out) method
- Calculated when shares are sold
- Includes partial sells (selling some but not all shares)
- Real-time search - Search any stock symbol via Yahoo Finance
- Debounced queries - 1 second debounce to avoid excessive API calls
- Result display - Shows symbol, name, and exchange for each match
- Quick add - Click on a result to add it to your portfolio
- Row selection - Click to select, click again to deselect
- Keyboard navigation - Use β/β arrows to navigate stocks
- Zebra striping - Visual distinction between rows
- Action buttons - Visible when row is selected
- Scrollable - Handle large lists with viewport culling
- Order persistence - Stock order saved and restored on restart
- Smart batching - Fetches 8 stocks per batch for reliability
- Progress tracking - Shows batch progress, success/error counts
- Rate limiting - 0.8s delay between requests, 2s between batches
- Error handling - Continues with successful stocks even if some fail
- Color-coded data - Green for gains, red for losses
- Mouse support - Full mouse interaction for clicks and selection
- Responsive layout - Flexbox layout adapts to terminal size
- Clean exit - Graceful shutdown with Ctrl+C
- Portfolio summary - Total portfolio value and P&L shown beside search
The application uses Yahoo Finance's v8 chart endpoint as the primary data source:
- Stock Data Endpoint:
https://query1.finance.yahoo.com/v8/finance/chart/{symbol} - Search Endpoint:
https://query2.finance.yahoo.com/v1/finance/search - Historical Data:
https://query1.finance.yahoo.com/v8/finance/chart/{symbol}?period1={timestamp}&period2={timestamp} - Update Frequency: Every 60 seconds
- Initial Load: Smart batching with progress tracking
The portfolio is stored in data/portfolio.json:
{
"positions": [
{
"symbol": "AAPL",
"name": "Apple Inc.",
"transactions": [
{
"id": "abc123",
"type": "BUY",
"date": "2026-03-01",
"qty": 10,
"pricePerShare": 200.00
},
{
"id": "def456",
"type": "SELL",
"date": "2026-03-15",
"qty": 5,
"pricePerShare": 220.00
}
]
}
]
}MIT License - see LICENSE file for details.
- OpenTUI - for the excellent terminal UI framework
- Yahoo Finance - for providing market data
- RxJS - for reactive programming primitives
- Bun - for the fast development experience
