Expert assistant for THSAutoTrader, an automated trading tool for THS (同花顺) client with GUI automation, web API, and dual interface (Tkinter + Vue.js)
Expert assistant for developing and maintaining THSAutoTrader, an automated trading tool for the THS (同花顺) client that provides programmatic trading operations through GUI automation.
THSAutoTrader is a Windows-only automated trading tool that:
- `flask_service.py` - HTTP API server (port 5000)
- `window_service.py` - Windows automation and GUI control
- `trading_service.py` - Trading operations
- `position_service.py` - Position and balance management
When working with this project, use these commands:
```bash
poetry install # Install dependencies
poetry run dev # Run with hot reload (uses hupper)
poetry run start # Run normally
poetry run build # Build standalone executable
```
```bash
cd front
npm install # Install dependencies
npm run dev # Development server
npm run build # Build for production (outputs to ../html/)
```
When modifying or testing API functionality:
1. **Backend Changes**:
- Follow MVC pattern - business logic in controller, automation in services
- Use the logger utility in `src/util/logger.py` for consistent logging
- Test with `poetry run dev` for hot reload during development
- Consider Windows-specific behavior (this is Windows-only)
2. **Frontend Changes**:
- Work in `front/` directory with Vue 3 composition API
- Run `npm run dev` for live development
- Build with `npm run build` before testing integration
- Frontend files must be in `../html/` for Python backend to serve them
3. **GUI Automation**:
- All automation is based on THS client window class names and control IDs
- OCR fallback is available when needed (pytesseract)
- Test thoroughly as GUI automation can be fragile
4. **Building Executables**:
- PyInstaller bundles everything into `dist/下单辅助程序.exe`
- Required bundled directories: `html/`, `Tesseract-OCR/`, `config/`
- Icon located at `static/icon.ico`
**Adding a new trading operation**:
1. Add business logic to `src/controller/automation_controller.py`
2. Create service methods in appropriate service file (`trading_service.py`, etc.)
3. Add Flask route in `src/services/flask_service.py`
4. Update Vue frontend if UI changes needed
5. Test via API endpoint first, then through UI
**Modifying GUI automation**:
1. Locate relevant code in `src/services/window_service.py`
2. Test window class names and control IDs still match THS client
3. Consider OCR fallback if element detection fails
4. Log all automation steps for debugging
**Updating the frontend**:
1. Make changes in `front/src/`
2. Test with `npm run dev`
3. Build with `npm run build`
4. Restart Python backend to serve updated files
5. Test integration through `http://localhost:5000`
```python
positions = self.position_service.get_positions()
```
```python
@app.route('/new_endpoint')
def new_endpoint():
result = controller.some_operation()
return jsonify(result)
```
```javascript
// In Vue component
axios.get('http://localhost:5000/position')
.then(response => {
// Handle response
})
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/ths-auto-trader-development-assistant/raw