# 🤖 Stock Bot Trading System A comprehensive trading bot built with Bun and Turborepo, featuring a service-oriented architecture for real-time market data processing and strategy execution. ## 🚀 Quick Start ### Prerequisites - [Bun](https://bun.sh/) runtime - Node.js 18+ (for compatibility) ### Installation ```bash # Clone and install dependencies git clone cd stock-bot bun install ``` ### Running the System #### Option 1: VS Code Tasks (Recommended) 1. Open the project in VS Code 2. Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac) 3. Type "Tasks: Run Task" and select it 4. Choose "Start All Services" #### Option 2: Manual Startup ```bash # Terminal 1: Start Market Data Gateway cd apps/core-services/market-data-gateway bun run dev # Terminal 2: Start Trading Dashboard cd apps/interface-services/trading-dashboard bun run dev ``` ### Access Points - **Trading Dashboard**: http://localhost:5173 - **Market Data API**: http://localhost:3001 - **Health Check**: http://localhost:3001/health ## 📊 Dashboard Features ### Real-time Market Data - Live price feeds for AAPL, GOOGL, MSFT, TSLA, AMZN - WebSocket connections for real-time updates - Service health monitoring ### Professional UI Components - Built with Tremor UI for financial visualizations - Interactive charts and metrics - Responsive design for all devices ### Dashboard Tabs 1. **Market Data**: Live prices, volume, bid/ask spreads 2. **Portfolio**: Holdings allocation and performance 3. **Charts**: Price and volume analysis 4. **Performance**: Trading metrics and statistics ## 🏗️ Architecture ### Service-Oriented Design ``` apps/ ├── core-services/ │ └── market-data-gateway/ # Market data ingestion ├── interface-services/ │ └── trading-dashboard/ # React dashboard ├── data-services/ # (Future) Data processing ├── execution-services/ # (Future) Order management ├── intelligence-services/ # (Future) Strategy engine ├── platform-services/ # (Future) Infrastructure └── integration-services/ # (Future) External APIs ``` ### Shared Packages ``` packages/ ├── shared-types/ # TypeScript definitions ├── config/ # Configuration management ├── database/ # (Future) Database utilities └── trading-core/ # (Future) Core trading logic ``` ## 🔧 Development ### Project Structure - **Turborepo**: Monorepo management - **Bun**: Package manager and runtime - **TypeScript**: Type safety across all services - **React + Vite**: Modern frontend development - **Tremor UI**: Financial dashboard components ### Key Technologies - **Backend**: Hono framework, WebSockets, Redis - **Frontend**: React, TypeScript, Tremor UI - **Data**: QuestDB (planned), PostgreSQL (planned) - **Deployment**: Docker, Kubernetes (planned) ## 📈 Current Status ### ✅ Completed - [x] Monorepo setup with Turborepo - [x] Market Data Gateway service - [x] Real-time WebSocket connections - [x] Professional React dashboard - [x] Tremor UI integration - [x] TypeScript type system - [x] Service health monitoring ### 🚧 In Progress - [ ] Strategy execution engine - [ ] Risk management system - [ ] Portfolio tracking - [ ] Real broker integration ### 🔮 Planned - [ ] Advanced charting - [ ] Backtesting framework - [ ] Machine learning signals - [ ] Multi-broker support - [ ] Mobile application ## 🛠️ API Endpoints ### Market Data Gateway (Port 3001) ``` GET /health # Service health check GET /api/market-data/:symbol # Current market data GET /api/ohlcv/:symbol # Historical OHLCV data WS ws://localhost:3001 # Real-time data stream ``` ### Data Format ```typescript interface MarketData { symbol: string; price: number; bid: number; ask: number; volume: number; timestamp: string; } ``` ## 🔧 Configuration Environment variables are managed in `.env`: ```bash # Database Configuration DATABASE_URL=postgresql://... QUESTDB_URL=http://localhost:9000 # External APIs ALPHA_VANTAGE_API_KEY=your_key_here ALPACA_API_KEY=your_key_here # Service Configuration NODE_ENV=development LOG_LEVEL=info ``` ## 🤝 Contributing 1. Fork the repository 2. Create a feature branch: `git checkout -b feature/amazing-feature` 3. Commit changes: `git commit -m 'Add amazing feature'` 4. Push to branch: `git push origin feature/amazing-feature` 5. Open a Pull Request ## 📝 License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## 🙏 Acknowledgments - [Tremor UI](https://tremor.so/) for beautiful financial components - [Bun](https://bun.sh/) for fast runtime and package management - [Turborepo](https://turbo.build/) for monorepo tooling