Stock is an Emacs package for displaying A-share (Chinese stock market) real-time data based on Sina Finance API.
- 📊 Dashboard Buffer: Display stock indices and favorite stocks with auto-refresh
- 📈 Mode-line Display: Quick glance at stock prices while working
- 📉 Header-line Display: Alternative display in buffer header
- 🔄 Auto Refresh: Data updates during trading hours (9:00-11:30, 13:00-15:00)
- 🔍 Stock Search: Search any stock by code
- ⭐ Favorites Management: Add/remove favorite stocks with persistence
- ⚡ Incremental Updates: Uses tp.el for efficient text property updates
- Emacs 28.1+
- tp.el - Text Properties manipulation library
Download stock.el and stock-utils.el to your Emacs load-path.
Make sure tp.el is installed.
(use-package stock
:load-path "~/.emacs.d/site-lisp/stock"
:bind
("C-c s s" . stock)
("C-c s m" . stock-modeline-mode)
:custom
(stock-auto-refresh t)
(stock-refresh-seconds 5)
(stock-code-list '("sh600036" "sz000625")))M-x stock ; Open dashboard
In the dashboard:
+: Add favorite stocks_: Remove a stockg: Refresh datas: sort stocksc: Toggle color (stealth mode)
- 用户使用指南 (User Guide) - Comprehensive user documentation in Chinese
- 设计文档 (Design Doc) - Developer documentation for extending the package
| Variable | Default | Description |
|---|---|---|
stock-index-list | ’(“sh000001” “sz399001” “sz399006”) | Stock indices to display |
stock-code-list | ’(“sh600036” “sz000625”) | Default favorite stocks |
stock-buffer-name | ”A Chive” | Dashboard buffer name |
stock-auto-refresh | t | Enable auto-refresh |
stock-refresh-seconds | 5 | Refresh interval (seconds) |
stock-colouring | t | Enable colored display |
stock-modeline-stocks | nil | Stocks for mode-line display |
stock-modeline-format | ”[%n:%p]” | Mode-line format (%n=name, %p=percent) |
stock-modeline-refresh-seconds | 1 | Mode-line refresh interval |
stock-headerline-stocks | nil | Stocks for header-line display |
stock-headerline-format | ”[%n:%p]” | Header-line format |
stock-headerline-refresh-seconds | 1 | Header-line refresh interval |
| Command | Description |
|---|---|
stock | Open the main stock dashboard |
stock-refresh | Manually refresh stock data |
stock-search | Search stocks by codes |
stock-add | Add stocks to favorites |
stock-remove | Remove a stock from favorites |
stock-switch-colouring | Toggle color display (stealth mode) |
stock-modeline-mode | Toggle mode-line stock display |
stock-modeline-add | Add stocks to mode-line |
stock-modeline-remove | Remove a stock from mode-line |
stock-headerline-mode | Toggle header-line stock display |
stock-headerline-add | Add stocks to header-line |
stock-headerline-remove | Remove a stock from header-line |
Display real-time stock prices in your mode-line:
;; Configure stocks
(setq stock-modeline-stocks '("sh600036" "sz000625"))
;; Enable mode-line display
(stock-modeline-mode 1)Display stocks in the header-line:
;; Configure stocks
(setq stock-headerline-stocks '("sh600036" "sz000625"))
;; Enable header-line display
(stock-headerline-mode 1)Buy and forget. 买了就忘。
