|
1 | | -# Mock Market 📈 |
2 | | - |
3 | | -**A Full-Stack Investment Simulation Platform featuring Hybrid AI Analysis.** |
| 1 | +# Mock Market 📈 |
| 2 | +**A Full-Stack Investment Simulation Platform featuring Hybrid AI Analysis** |
4 | 3 |
|
5 | 4 | Mock Market is a trading simulation application that bridges the gap between traditional quantitative finance and modern Generative AI. It utilizes a high-performance **C++ engine** for technical indicator calculations and **Google Gemini** for qualitative market sentiment analysis, providing users with a comprehensive "Buy/Sell/Hold" decision for any given stock. |
6 | 5 |
|
7 | | - |
8 | | - |
9 | | - |
| 6 | + |
| 7 | + |
| 8 | + |
10 | 9 |
|
11 | 10 | ## 🚀 Key Features |
12 | 11 |
|
13 | | -* **Real-Time Market Data:** Fetches live pricing and historical data using Yahoo Finance and Finnhub APIs. |
14 | | -* **Hybrid Intelligence Engine:** |
15 | | - * **Quantitative:** A dedicated C++ microservice calculates complex technical indicators (RSI, SMA, Bollinger Bands) in real-time. |
16 | | - * **Qualitative:** Google Gemini (GenAI) acts as a "Portfolio Manager," synthesizing news headlines with the C++ hard math to make human-like trading decisions. |
17 | | -* **AI-Powered Insights:** Returns a clear textual analysis with a structured "Buy/Sell/Hold" signal and reasoning. |
18 | | -* **Microservices Architecture:** Fully containerized using Docker and Docker Compose. |
| 12 | +- **Risk-Free Paper Trading** |
| 13 | + Users sign in securely via **Google** and instantly receive a **$100,000** virtual portfolio to practice trading strategies without financial risk. |
| 14 | + |
| 15 | +- **Real-Time Market Data** |
| 16 | + Fetches live pricing and historical data using **Yahoo Finance** and **Finnhub** APIs. |
| 17 | + |
| 18 | +- **Hybrid Intelligence Engine** |
| 19 | + - **Quantitative**: A dedicated C++ microservice calculates complex technical indicators (RSI, SMA, Bollinger Bands) in real-time. |
| 20 | + - **Qualitative**: Google Gemini (GenAI) acts as a "Portfolio Manager," synthesizing news headlines with the C++ hard math to make human-like trading decisions. |
| 21 | + |
| 22 | +- **AI-Powered Insights** |
| 23 | + Returns clear textual analysis with a structured **Buy / Sell / Hold** signal and reasoning. |
| 24 | + |
| 25 | +- **Microservices Architecture** |
| 26 | + Fully containerized using Docker and Docker Compose. |
| 27 | + |
| 28 | +## 🛠 Architecture Overview |
| 29 | + |
| 30 | +The application is split into three distinct services communicating via HTTP and TCP sockets: |
| 31 | + |
| 32 | +1. **Frontend (React)** – User interaction, portfolio management, secure authentication via **Firebase (Google Sign-In)** |
| 33 | +2. **Backend (Node.js/Express)** – Orchestrator: fetches data, talks to C++ engine, feeds results + news into Gemini |
| 34 | +3. **CPP-Algos (C++)** – High-performance TCP server for technical indicator calculations |
| 35 | + |
| 36 | +## 📂 Project Structure |
| 37 | + |
| 38 | +```text |
| 39 | +mock-market/ |
| 40 | +├── backend/ # Node.js Express Server (API & Orchestration) |
| 41 | +├── cpp-algos/ # C++ Quantitative Analysis Engine |
| 42 | +├── frontend/ # React Client Application |
| 43 | +├── docker-compose.yml |
| 44 | +└── README.md |
| 45 | +⚙️ Prerequisites |
| 46 | +
|
| 47 | +Node.js (v16 or higher) |
| 48 | +C++ Compiler (MinGW for Windows or GCC/Clang for Linux/macOS) |
| 49 | +Docker Desktop (recommended for easy deployment) |
| 50 | +API Keys: |
| 51 | +Finnhub API Key → finnhub.io |
| 52 | +Google Gemini API Key → Google AI Studio |
| 53 | +
|
| 54 | +
|
| 55 | +🔧 Installation & Setup |
| 56 | +Method 1: Docker (Recommended) |
| 57 | +Note: The current C++ code uses winsock2.h. For Docker (Linux containers), refactor socket code to standard BSD sockets (<sys/socket.h>, <netinet/in.h>). |
| 58 | +Bashgit clone https://github.com/yourusername/mock-market.git |
| 59 | +cd mock-market |
| 60 | +Create .env in the backend/ directory: |
| 61 | +envPORT=5000 |
| 62 | +FINNHUB_API_KEY=your_finnhub_key_here |
| 63 | +GEMINI_API_KEY=your_gemini_key_here |
| 64 | +Build and run: |
| 65 | +Bashdocker-compose up --build |
| 66 | +
|
| 67 | +Frontend → http://localhost:80 |
| 68 | +Backend → http://localhost:5000 |
| 69 | +
|
| 70 | +Method 2: Manual Setup (Local Development – Windows) |
| 71 | +1. Start the C++ Engine |
| 72 | +Bashcd cpp-algos |
| 73 | +g++ src/main.cpp -o algo_service.exe -lws2_32 -static |
| 74 | +./algo_service.exe |
| 75 | +→ Listens on port 8080 |
| 76 | +2. Start the Backend |
| 77 | +Bashcd backend |
| 78 | +npm install |
| 79 | +# Make sure .env exists with your keys |
| 80 | +node server.js |
| 81 | +→ Listens on port 5000 |
| 82 | +3. Start the Frontend |
| 83 | +Bashcd frontend |
| 84 | +npm install |
| 85 | +npm start |
| 86 | +→ Opens at http://localhost:3000 |
| 87 | +💡 How It Works – The "Signal" Endpoint |
| 88 | +When a user searches for a stock (e.g., AAPL): |
| 89 | +
|
| 90 | +Data Fetch – Backend pulls last 60 days of price data (Yahoo Finance) + recent news (Finnhub) |
| 91 | +Quant Analysis – Price array sent to C++ engine (TCP port 8080) |
| 92 | +Math Calculation – C++ returns RSI, SMA, Bollinger Bands, etc. |
| 93 | +AI Synthesis – Backend sends technical string + news headlines to Google Gemini |
| 94 | +Decision – Gemini returns structured JSON:JSON{ "signal": "BUY", "confidence": 0.82, "reasoning": "Strong upward momentum..." } |
| 95 | +
|
| 96 | +🚧 Cross-Platform Note |
| 97 | +
|
| 98 | +Current cpp-algos/src/main.cpp uses <winsock2.h> → Windows-only |
| 99 | +To run inside Docker (Linux): replace with standard POSIX sockets |
| 100 | +Local Windows development works out-of-the-box |
| 101 | +
|
| 102 | +🤝 Contributing |
| 103 | +Contributions are welcome! Feel free to open issues or submit Pull Requests. |
| 104 | +📄 License |
| 105 | +This project is licensed under the ISC License – see the LICENSE file for details. |
0 commit comments