A Full-Stack Investment Simulation Platform featuring Hybrid AI Analysis
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.
-
Risk-Free Paper Trading Users sign in securely via Google and instantly receive a $100,000 virtual portfolio to practice trading strategies without financial risk.
-
Real-Time Market Data Fetches live pricing and historical data using Yahoo Finance and Finnhub APIs.
-
Hybrid Intelligence Engine
- Quantitative: A dedicated C++ microservice calculates complex technical indicators (RSI, SMA, Bollinger Bands) in real-time.
- Qualitative: Google Gemini (GenAI) acts as a "Portfolio Manager," synthesizing news headlines with the C++ hard math to make human-like trading decisions.
-
AI-Powered Insights Returns clear textual analysis with a structured Buy / Sell / Hold signal and reasoning.
-
Microservices Architecture Fully containerized using Docker and Docker Compose.
The application is split into three distinct services communicating via HTTP and TCP sockets:
- Frontend (React) – User interaction, portfolio management, secure authentication via Firebase (Google Sign-In).
- Backend (Node.js/Express) – Orchestrator: fetches data, talks to C++ engine, feeds results + news into Gemini.
- CPP-Algos (C++) – High-performance TCP server for technical indicator calculations.
mock-market/
├── backend/ # Node.js Express Server (API & Orchestration)
├── cpp-algos/ # C++ Quantitative Analysis Engine
├── frontend/ # React Client Application
├── docker-compose.yml
└── README.md
- Node.js (v16 or higher)
- C++ Compiler (MinGW for Windows or GCC/Clang for Linux/macOS)
- Docker Desktop (recommended for easy deployment)
- API Keys:
- Finnhub API Key →
finnhub.io - Google Gemini API Key →
Google AI Studio
- Finnhub API Key →
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>).
-
Clone the repository:
git clone [https://github.com/yourusername/mock-market.git](https://github.com/yourusername/mock-market.git) cd mock-market -
Create
.envin thebackend/directory:PORT=5000 FINNHUB_API_KEY=your_finnhub_key_here GEMINI_API_KEY=your_gemini_key_here
-
Build and run:
docker-compose up --build
- Frontend →
http://localhost:80 - Backend →
http://localhost:5000
- Frontend →
-
Start the C++ Engine
cd cpp-algos g++ src/main.cpp -o algo_service.exe -lws2_32 -static ./algo_service.exe→ Listens on port 8080
-
Start the Backend
cd backend npm install # Make sure .env exists with your keys node server.js
→ Listens on port 5000
-
Start the Frontend
cd frontend npm install npm start→ Opens at http://localhost:3000
When a user searches for a stock (e.g., AAPL):
- Data Fetch – Backend pulls last 60 days of price data (Yahoo Finance) + recent news (Finnhub).
- Quant Analysis – Price array sent to C++ engine (TCP port 8080).
- Math Calculation – C++ returns RSI, SMA, Bollinger Bands, etc.
- AI Synthesis – Backend sends technical string + news headlines to Google Gemini.
- Decision – Gemini returns structured JSON:
{ "signal": "BUY", "confidence": 0.82, "reasoning": "Strong upward momentum..." }
Current cpp-algos/src/main.cpp uses <winsock2.h> → Windows-only.
- To run inside Docker (Linux): replace with standard POSIX sockets.
- Local Windows development works out-of-the-box.
Contributions are welcome! Feel free to open issues or submit Pull Requests.
This project is licensed under the ISC License – see the LICENSE file for details.

