Update database schema and configuration for Crypto Trading Bot Platform

- Added new SQLAlchemy models in `database/models.py` for market data, trades, bots, signals, and performance tracking.
- Updated `docker-compose.yml` to use TimescaleDB for PostgreSQL and configured shared preload libraries.
- Created new schema files: `schema.sql` for the complete database setup and `schema_clean.sql` for a simplified version without hypertables.
- Updated documentation in `setup.md` to reflect changes in database initialization and service setup.
This commit is contained in:
Vasily.onl
2025-05-30 17:45:57 +08:00
parent 692611d3ae
commit 8121ce0430
9 changed files with 1310 additions and 17 deletions

View File

@@ -3,6 +3,7 @@
- `app.py` - Main Dash application entry point and dashboard interface
- `bot_manager.py` - Bot lifecycle management and coordination
- `database/models.py` - PostgreSQL database models and schema definitions
- `database/schema.sql` - Complete database schema with all tables, indexes, and constraints
- `database/connection.py` - Database connection and query utilities
- `data/okx_collector.py` - OKX API integration for real-time market data collection
- `data/aggregator.py` - OHLCV candle aggregation and processing
@@ -16,7 +17,7 @@
- `config/strategies/` - Directory for JSON strategy parameter files
- `scripts/dev.py` - Development setup and management script
- `requirements.txt` - Python dependencies managed by UV
- `docker-compose.yml` - Docker services configuration
- `docker-compose.yml` - Docker services configuration with TimescaleDB support
- `tests/test_strategies.py` - Unit tests for strategy implementations
- `tests/test_bot_manager.py` - Unit tests for bot management functionality
- `tests/test_data_collection.py` - Unit tests for data collection and aggregation
@@ -33,10 +34,10 @@
- [ ] 1.0 Database Foundation and Schema Setup
- [x] 1.1 Install and configure PostgreSQL with Docker
- [ ] 1.2 Create database schema following the PRD specifications (market_data, bots, signals, trades, bot_performance tables)
- [x] 1.2 Create database schema following the PRD specifications (market_data, bots, signals, trades, bot_performance tables)
- [ ] 1.3 Implement database connection utility with connection pooling
- [ ] 1.4 Create database models using SQLAlchemy or similar ORM
- [ ] 1.5 Add proper indexes for time-series data optimization
- [x] 1.5 Add proper indexes for time-series data optimization
- [ ] 1.6 Setup Redis for pub/sub messaging
- [ ] 1.7 Create database migration scripts and initial data seeding
- [ ] 1.8 Unit test database models and connection utilities
@@ -150,4 +151,13 @@
- [ ] 12.6 Prepare for production deployment
- [ ] 12.7 Create maintenance and support procedures
- [ ] 13.0 Performance Optimization and Scaling (Future Enhancement)
- [ ] 13.1 Implement TimescaleDB hypertables for time-series optimization
- [ ] 13.2 Optimize database schema for hypertable compatibility (composite primary keys)
- [ ] 13.3 Add database query performance monitoring and analysis
- [ ] 13.4 Implement advanced connection pooling optimization
- [ ] 13.5 Add caching layer for frequently accessed market data
- [ ] 13.6 Optimize data retention and archival strategies
- [ ] 13.7 Implement horizontal scaling for high-volume trading scenarios