{"id":29102854,"url":"https://github.com/antoniandre/stock-trader-sim","last_synced_at":"2026-02-16T05:32:43.721Z","repository":{"id":300849779,"uuid":"1007373522","full_name":"antoniandre/stock-trader-sim","owner":"antoniandre","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-04T08:14:49.000Z","size":1662,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-02T10:10:01.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antoniandre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-23T22:34:18.000Z","updated_at":"2026-01-04T08:14:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"c294be05-5d4b-4505-84ba-5caf25d3a0c9","html_url":"https://github.com/antoniandre/stock-trader-sim","commit_stats":null,"previous_names":["antoniandre/stock-trader-sim"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/antoniandre/stock-trader-sim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniandre%2Fstock-trader-sim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniandre%2Fstock-trader-sim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniandre%2Fstock-trader-sim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniandre%2Fstock-trader-sim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antoniandre","download_url":"https://codeload.github.com/antoniandre/stock-trader-sim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniandre%2Fstock-trader-sim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29500832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T03:57:51.541Z","status":"ssl_error","status_checked_at":"2026-02-16T03:55:59.854Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-28T22:07:39.859Z","updated_at":"2026-02-16T05:32:43.705Z","avatar_url":"https://github.com/antoniandre.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stock Trading Simulator\n\nA real-time stock trading application with live market data integration using Alpaca API and WebSocket streaming.\n\n## 🚀 Features\n\n- **Real-time Market Data**: Live stock prices via Alpaca WebSocket streaming\n- **Trading Interface**: Buy/sell orders with portfolio tracking\n- **Simulation Mode**: Mock trading with realistic price movements\n- **Live Mode**: Real trading with Alpaca API integration\n- **WebSocket Updates**: Real-time frontend updates\n- **Clean Architecture**: Modular, scalable codebase\n\n## 🏗️ Architecture\n\n### Backend (`api/`)\n- **Express.js** server with REST API endpoints\n- **WebSocket** server for real-time communication\n- **Alpaca API** integration for live trading\n- **State Management** with centralized data store\n- **Error Handling** with graceful fallbacks\n\n### Frontend (`frontend/`)\n- **Vue 3** with Composition API\n- **Tailwind CSS** for styling\n- **WebSocket** client for real-time updates\n- **Responsive Design** with dark theme\n\n## 📋 Prerequisites\n\n- Node.js 18+\n- pnpm (recommended) or npm\n- Alpaca API account (for live trading)\n\n## 🛠️ Setup\n\n### 1. Clone and Install\n\n```bash\ngit clone \u003crepository-url\u003e\ncd stock-trader-sim\n```\n\n### 2. Backend Setup\n\n```bash\ncd api\npnpm install\n```\n\nCreate `.env` file:\n```env\n# Alpaca API Configuration\nALPACA_KEY=your_api_key_here\nALPACA_SECRET=your_api_secret_here\nALPACA_BASE_URL=https://paper-api.alpaca.markets\nALPACA_DATA_STREAM=wss://stream.data.alpaca.markets/v2/iex\n\n# Application Mode\nSIMULATION=false\n\n# Server Configuration (optional)\nPORT=3000\n```\n\n### 3. Frontend Setup\n\n```bash\ncd frontend\npnpm install\n```\n\n### 4. Start Development\n\n**Terminal 1 - Backend:**\n```bash\ncd api\npnpm dev\n```\n\n**Terminal 2 - Frontend:**\n```bash\ncd frontend\npnpm dev\n```\n\n## 🔧 Configuration\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `ALPACA_KEY` | Your Alpaca API key | Required |\n| `ALPACA_SECRET` | Your Alpaca API secret | Required |\n| `ALPACA_BASE_URL` | Alpaca trading API URL | `https://api.alpaca.markets` |\n| `ALPACA_DATA_STREAM` | Alpaca WebSocket URL | `wss://stream.data.alpaca.markets/v2/iex` |\n| `SIMULATION` | Enable simulation mode | `false` |\n| `PORT` | Server port | `3000` |\n\n### Trading Modes\n\n#### Simulation Mode (`SIMULATION=true`)\n- Uses mock data with realistic price movements\n- No real money involved\n- Perfect for testing and development\n- Runs every 5 seconds with demo trading logic\n\n#### Live Mode (`SIMULATION=false`)\n- Connects to Alpaca WebSocket for real-time data\n- Real trading capabilities\n- Requires valid Alpaca API credentials\n- Supports paper trading and live trading\n\n## 📡 API Endpoints\n\n### REST API\n- `GET /api/portfolio` - Get current portfolio and trade history\n- `GET /api/health` - Health check with connection status\n\n### WebSocket Events\n- `market-update` - Stock price updates\n- `trade` - Trade execution notifications\n- `price` - Individual price updates\n\n## 🏛️ Project Structure\n\n```\nstock-trader-sim/\n├── api/\n│   ├── stockBot.js          # Main server with WebSocket and API\n│   ├── package.json\n│   └── .env                 # Environment configuration\n├── frontend/\n│   ├── src/\n│   │   ├── views/\n│   │   │   └── dashboard.vue # Main trading interface\n│   │   ├── components/\n│   │   │   ├── ticker-card.vue\n│   │   │   ├── portfolio-chart.vue\n│   │   │   └── trade-history.vue\n│   │   └── api/\n│   │       └── index.js     # API client\n│   └── package.json\n└── README.md\n```\n\n## 🔄 Data Flow\n\n1. **Market Data**: Alpaca WebSocket → Backend → Frontend\n2. **Trading**: Frontend → Backend → Alpaca API → Portfolio Update\n3. **Real-time Updates**: WebSocket broadcasts to all connected clients\n\n## 🚨 Error Handling\n\n- **WebSocket Disconnection**: Automatic reconnection every 5 seconds\n- **API Failures**: Graceful fallback to mock data\n- **Rate Limiting**: Handled with exponential backoff\n- **Invalid Orders**: Proper error responses\n\n## 🔒 Security\n\n- Environment variables for sensitive data\n- CORS configuration for development\n- Input validation on all endpoints\n- No hardcoded credentials\n\n## 🧪 Testing\n\n### Simulation Mode\nPerfect for testing without real money:\n```bash\n# Set in .env\nSIMULATION=true\n```\n\n### Live Mode Testing\nUse Alpaca's paper trading environment:\n```bash\n# Set in .env\nALPACA_BASE_URL=https://paper-api.alpaca.markets\nSIMULATION=false\n```\n\n## 📈 Scaling Considerations\n\nThe current architecture supports scaling through:\n\n- **Modular Design**: Easy to add new features\n- **State Management**: Centralized data store\n- **WebSocket Efficiency**: Real-time updates without polling\n- **Error Resilience**: Graceful degradation\n- **Configuration**: Environment-based settings\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Test thoroughly\n5. Submit a pull request\n\n## 📄 License\n\nThis project is licensed under the MIT License.\n\n## ⚠️ Disclaimer\n\nThis is a trading application for educational purposes. Always test thoroughly before using with real money. The authors are not responsible for any financial losses.\n\n---\n\n**Happy Trading! 📈**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniandre%2Fstock-trader-sim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoniandre%2Fstock-trader-sim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniandre%2Fstock-trader-sim/lists"}