This project is a basic options trading app simulation built with Next.js, React, and MongoDB. It allows users to simulate trading binary options, manage balances, and interact with an orderbook.
WhatsApp.Video.2024-10-11.at.15.23.56.mp4
- User authentication
- INR balance management (onramp and faucet)
- Stock balance management
- Place 'Yes' and 'No' orders
- Real-time orderbook updates using WebSockets
- Mint tokens for trading
- Matching engine for order execution
- Next.js 14
- React 18
- MongoDB
- Socket.IO for real-time updates
- Tailwind CSS for styling
- Framer Motion for animations
-
Clone the repository:
git clone https://github.com/your-username/options-trading-app.git cd options-trading-app
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env.local
file in the root directory and add the following:MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret
-
Run the development server:
npm run dev
-
Open http://localhost:3000 with your browser to see the result.
src/app
: Contains the main application pages and API routessrc/components
: React components used throughout the appsrc/lib
: Utility functions and database operationssrc/pages/api
: API routes for WebSocket initialization
/api/balance/inr/:userId
: Get INR balance/api/balance/stock/:userId
: Get stock balance/api/onramp/inr
: Onramp INR/api/faucet
: Use faucet to get free INR/api/order/yes
: Place a 'Yes' order/api/order/no
: Place a 'No' order/api/orderbook/:stockSymbol
: Get orderbook for a stock/api/trade/mint/:stockSymbol
: Mint new tokens