updated some docs and removed some

This commit is contained in:
Bojan Kucera 2025-06-08 20:06:35 -04:00
parent 2aaeba2f6c
commit fe96cf6679
7 changed files with 109 additions and 734 deletions

View file

@ -1,54 +1,97 @@
# Stock Trading Bot - Simplified Combined Architecture
# Stock Bot - System Architecture
> **Updated**: June 2025
## Overview
A TypeScript-based simplified microservices architecture for automated stock trading with integrated multi-mode backtesting capabilities. The system combines live trading and backtesting functionality into unified services while supporting live, event-driven, and vectorized backtesting modes.
TypeScript microservices architecture for automated stock trading with real-time data processing and multi-database storage.
## Architecture Diagram
## Core Services
```
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Data Service │ │Processing Service│ │Strategy Service │
│ │ │ │ │ │
│ • Live APIs │────▶│ • Indicators │────▶│ • Live Mode │
│ • Historical │ │ • Processing │ │ • Event Mode │
│ • QuestDB │ │ • Validation │ │ • Vector Mode │
│ • Unified API │ │ • Utils Lib │ │ • Backtesting │
│ • Market Data │────▶│ • Indicators │────▶│ • Strategies │
│ • Providers │ │ • Analytics │ │ • Backtesting │
│ • QuestDB │ │ • Validation │ │ • Signal Gen │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ ┌─────────────────┐ │
│ │ Event Bus │ │
└──────────────▶│ (Dragonfly) │◀─────────────┘
└──────────────▶│ Event Bus │◀─────────────┘
│ (Dragonfly) │
└─────────────────┘
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│Execution Service│ │Portfolio Service│ │ Dashboard │
│ │ │ │ │ │
│ • Live Brokers │ │ • Positions │ │ • Angular UI │
│ • Simulation │ │ • Risk Mgmt │ │ • Real-time │
│ • Mode Switch │ │ • P&L Tracking │ │ • Backtest UI │
│ • Unified API │ │ • Performance │ │ • Reports │
│ • Order Mgmt │ │ • Positions │ │ • Angular UI │
│ • Risk Control │ │ • Risk Mgmt │ │ • Real-time │
│ • Execution │ │ • Performance │ │ • Analytics │
└─────────────────┘ └─────────────────┘ └─────────────────┘
```
## Simplified Service Structure
### 6 Core Services (Instead of 12)
## Services Structure
```
stock-bot/
├── apps/
│ ├── data-service/ # Combined data ingestion & historical
│ │ ├── src/
│ │ │ ├── providers/ # Live & historical data providers
│ │ │ │ ├── live/ # Real-time APIs (WebSocket, REST)
│ │ │ │ ├── historical/ # Historical data (Yahoo, Alpha Vantage)
│ │ │ │ └── unified.ts # Unified data interface
│ │ │ ├── storage/ # QuestDB time-series storage
│ │ │ ├── services/
│ │ │ └── index.ts
│ │ └── package.json
│ │
│ ├── data-service/ # Market data ingestion & storage
│ ├── execution-service/ # Order execution & broker integration
│ ├── portfolio-service/ # Position & risk management
│ ├── processing-service/ # Data processing & indicators
│ ├── strategy-service/ # Trading strategies & backtesting
│ └── dashboard/ # Angular UI (port 4200)
├── libs/ # Shared libraries
│ ├── logger/ # Centralized logging w/ Loki
│ ├── config/ # Configuration management
│ ├── event-bus/ # Event system
│ ├── mongodb-client/ # MongoDB operations
│ ├── postgres-client/ # PostgreSQL operations
│ ├── questdb-client/ # Time-series data
│ ├── http/ # HTTP client w/ proxy support
│ ├── cache/ # Caching layer
│ └── utils/ # Common utilities
└── database/ # Database configurations
├── mongodb/init/
└── postgres/init/
```
## Technology Stack
| Component | Technology | Purpose |
|-----------|------------|---------|
| **Runtime** | Bun | Fast JavaScript runtime |
| **Language** | TypeScript | Type-safe development |
| **Databases** | PostgreSQL, MongoDB, QuestDB | Multi-database architecture |
| **Caching** | Dragonfly (Redis) | Event bus & caching |
| **Frontend** | Angular 18 | Modern reactive UI |
| **Monitoring** | Prometheus, Grafana, Loki | Observability stack |
## Quick Start
```bash
# Install dependencies
bun install
# Start infrastructure
bun run infra:up
# Start services
bun run dev
# Access dashboard
# http://localhost:4200
```
## Key Features
- **Real-time Trading**: Live market data & order execution
- **Multi-Database**: PostgreSQL, MongoDB, QuestDB for different data types
- **Event-Driven**: Asynchronous communication via Dragonfly
- **Monitoring**: Full observability with metrics, logs, and tracing
- **Modular**: Shared libraries for common functionality
- **Type-Safe**: Full TypeScript coverage
│ ├── processing-service/ # Combined processing & indicators
│ │ ├── src/
│ │ │ ├── indicators/ # Technical indicators (uses @stock-bot/utils)