Skip to content

About

一个终端的盯盘软件,可以添加自己需要的股票和基金代码

Topics

Resources

Stars

14 stars

Watchers

1 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

Live Trading


📖 English | 中文

Go Version License Go Report Card

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.

✨ Features

  • 🚀 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

🚀 Quick Start

Prerequisites

  • Go 1.20 or higher
  • Network connection (for fetching stock data)

Installation

  1. Clone the repository
git clone https://github.com/wanyuqin/live-trading.git
cd live-trading
  1. Build the project
go build -o live-trading main.go
  1. Run the program
./live-trading

Using Custom Configuration

./live-trading -c /path/to/your/config.yaml

📖 Usage Guide

Basic Operations

  • Add Stock: Press a key, input 6-digit stock code (e.g., 000001)
  • Delete Stock: Press x key to delete the currently selected stock
  • Exit Program: Press Ctrl+C

Stock Code Format

  • Shanghai Stock Exchange: 6-digit numbers starting with 6 or 5 (e.g., 600000)
  • Shenzhen Stock Exchange: 6-digit numbers starting with 0, 1, or 3 (e.g., 000001)
  • Indices: Support major market indices (000001, 399001, 399006)

Configuration

Default configuration file location: ~/.live_trading/trading.yaml

watchList:
  stock:
    - "000001"  # Shanghai Composite Index
    - "600000"  # SPD Bank
    - "000002"  # Vanke A

🏗️ Project Architecture

live-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

Tech Stack

  • Language: Go 1.20+
  • UI Framework: Bubble Tea
  • CLI Framework: Cobra
  • Configuration: YAML
  • Data Source: East Money API

🔧 Development

Local Development Environment

  1. Install dependencies
go mod download
  1. Run tests
go test ./...
  1. Build development version
go build -o live-trading-dev main.go

Project Structure Explanation

  • 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

📊 Data Source

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.

🤝 Contributing

Issues and Pull Requests are welcome!

Contribution Guide

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 Changelog

[Unreleased]

  • Optimize error handling mechanism
  • Implement smooth refresh when adding/deleting stocks
  • Add more technical indicators
  • Support historical data queries

[Current Version]

  • Delete stock code functionality
  • Market monitoring
  • Restart monitoring via context
  • Custom configuration file support
  • Basic TUI interface

📄 License

This project is licensed under the MIT License - see the LICENSE file for details

🙏 Acknowledgments

📞 Contact


⭐ If this project helps you, please give it a star!

About

一个终端的盯盘软件,可以添加自己需要的股票和基金代码

Topics

Resources

Stars

14 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages