📖 English | 中文
A real-time stock trading monitoring tool developed in Go, providing an elegant Terminal User Interface (TUI) to monitor stock price changes and market conditions.
- 🚀 Real-time Monitoring: Support real-time price monitoring for custom stock code lists
- 📊 Market Overview: Real-time display of major indices (Shanghai, Shenzhen, ChiNext) market conditions
- 🎯 TUI Interface: Modern terminal-based user interface with keyboard shortcuts support
- ⚙️ Flexible Configuration: Support custom configuration files with runtime dynamic updates
- 🔄 Auto Restart: Support graceful restart and recovery of monitoring services
- 🛡️ Safe & Reliable: Comprehensive error handling and goroutine management
- Go 1.20 or higher
- Network connection (for fetching stock data)
- Clone the repository
git clone https://github.com/wanyuqin/live-trading.git
cd live-trading- Build the project
go build -o live-trading main.go- Run the program
./live-trading./live-trading -c /path/to/your/config.yaml- Add Stock: Press
akey, input 6-digit stock code (e.g., 000001) - Delete Stock: Press
xkey to delete the currently selected stock - Exit Program: Press
Ctrl+C
- Shanghai Stock Exchange: 6-digit numbers starting with
6or5(e.g., 600000) - Shenzhen Stock Exchange: 6-digit numbers starting with
0,1, or3(e.g., 000001) - Indices: Support major market indices (000001, 399001, 399006)
Default configuration file location: ~/.live_trading/trading.yaml
watchList:
stock:
- "000001" # Shanghai Composite Index
- "600000" # SPD Bank
- "000002" # Vanke Alive-trading/
├── cmd/ # Command line entry
├── internal/ # Internal packages
│ ├── configs/ # Configuration management
│ ├── domain/ # Domain layer (entities, services, repositories)
│ ├── infrastructure/ # Infrastructure layer (API integration)
│ ├── views/ # View layer (UI components)
│ └── watcher/ # Monitors
├── tools/ # Utility packages
└── main.go # Program entry point
- Language: Go 1.20+
- UI Framework: Bubble Tea
- CLI Framework: Cobra
- Configuration: YAML
- Data Source: East Money API
- Install dependencies
go mod download- Run tests
go test ./...- Build development version
go build -o live-trading-dev main.go- Domain Layer: Contains business logic, entity definitions, and service interfaces
- Infrastructure Layer: Handles external API calls and data persistence
- Views Layer: Manages user interface and interaction logic
- Watcher Layer: Responsible for data monitoring and updates
This project uses East Money (eastmoney.com) public API as the data source:
- Real-time Quotes: Obtained through SSE (Server-Sent Events)
- Load Balancing: Support for multiple API server random selection
- Data Fields: Contains key information such as price, change percentage, volume, etc.
Issues and Pull Requests are welcome!
- Fork this repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Optimize error handling mechanism
- Implement smooth refresh when adding/deleting stocks
- Add more technical indicators
- Support historical data queries
- Delete stock code functionality
- Market monitoring
- Restart monitoring via context
- Custom configuration file support
- Basic TUI interface
This project is licensed under the MIT License - see the LICENSE file for details
- Bubble Tea - Excellent TUI framework
- Cobra - Powerful CLI framework
- East Money - Provides stock data API
- Project Homepage: https://github.com/wanyuqin/live-trading
- Issue Reports: Issues
⭐ If this project helps you, please give it a star!