Add Redis connection utility for pub/sub messaging

- Introduced `database/redis_manager.py` to manage Redis connections, including synchronous and asynchronous clients.
- Implemented pub/sub messaging capabilities for real-time data distribution, with structured channel definitions for market data, bot signals, and system health.
- Added configuration options for Redis connection pooling and error handling, ensuring robust integration with the Crypto Trading Bot Platform.
This commit is contained in:
Vasily.onl
2025-05-30 18:27:32 +08:00
parent 73b7e8bb9d
commit dd75546508
2 changed files with 480 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
- `database/schema_clean.sql` - Clean database schema without hypertables (actively used, includes raw_trades table)
- `database/schema.sql` - Complete database schema with TimescaleDB hypertables (for future optimization)
- `database/connection.py` - Database connection utility with connection pooling, session management, and raw data utilities
- `database/redis_manager.py` - Redis connection utility with pub/sub messaging for real-time data distribution
- `database/init/init.sql` - Docker initialization script for automatic database setup
- `database/init/schema_clean.sql` - Copy of clean schema for Docker initialization
- `data/okx_collector.py` - OKX API integration for real-time market data collection
@@ -21,6 +22,7 @@
- `config/settings.py` - Centralized configuration settings using Pydantic
- `scripts/dev.py` - Development setup and management script
- `scripts/init_database.py` - Database initialization and verification script
- `scripts/test_models.py` - Test script for SQLAlchemy models integration verification
- `requirements.txt` - Python dependencies managed by UV
- `docker-compose.yml` - Docker services configuration with TimescaleDB support
- `tests/test_strategies.py` - Unit tests for strategy implementations
@@ -34,9 +36,9 @@
- [x] 1.1 Install and configure PostgreSQL with Docker
- [x] 1.2 Create database schema following the PRD specifications (market_data, bots, signals, trades, bot_performance tables)
- [x] 1.3 Implement database connection utility with connection pooling
- [ ] 1.4 Create database models using SQLAlchemy or similar ORM
- [x] 1.4 Create database models using SQLAlchemy or similar ORM
- [x] 1.5 Add proper indexes for time-series data optimization
- [ ] 1.6 Setup Redis for pub/sub messaging
- [x] 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