Market Data Service is a high-performance financial data API that provides comprehensive Symbol prices of different markets through both RESTful endpoints and real-time WebSocket connections.
|
|
hai 4 meses | |
|---|---|---|
| MT5 | hai 4 meses | |
| src | hai 4 meses | |
| .gitignore | hai 4 meses | |
| README.md | hai 4 meses | |
| package-lock.json | hai 4 meses | |
| package.json | hai 4 meses | |
| schema.sql | hai 4 meses |
A high-performance financial data API that provides comprehensive market data for various financial instruments including cryptocurrencies, stocks, forex, and commodities through both RESTful endpoints and real-time WebSocket connections.
The service includes an MT5 Expert Advisor (EA) that automatically sends historical candle data and live tick prices to the API.
MT5/Experts/MarketDataSender.mq5 to your MT5 Experts directoryConfigure EA settings:
ApiBaseUrl: Your API endpoint (e.g., http://your-server:3000)ApiKey: Optional authentication keyHistoricalCandleCount: Number of historical candles to send (default: 1000)HistoricalTimeframe: Timeframe for historical data (default: H1)Attach the EA to any MT5 chart
The EA will:
EXCHANGE_SYMBOL)market-data-service/
├── src/
│ ├── config/
│ │ └── database.js # Database configuration
│ ├── controllers/
│ │ ├── symbolController.js # Symbol CRUD operations
│ │ ├── candleController.js # Candle data operations
│ │ └── livePriceController.js # Live price operations
│ ├── middleware/
│ │ ├── errorHandler.js # Global error handling
│ │ └── validation.js # Request validation
│ ├── models/
│ │ ├── Symbol.js # Symbol model
│ │ ├── Candle1h.js # 1-hour candle model
│ │ ├── LivePrice.js # Live price model
│ │ └── index.js # Model associations
│ ├── routes/
│ │ ├── symbols.js # Symbol routes
│ │ ├── candles.js # Candle routes
│ │ └── livePrices.js # Live price routes
│ ├── utils/
│ │ └── logger.js # Logging utility
│ ├── app.js # Express app configuration
│ └── server.js # Server startup
├── tests/ # Test files
├── schema.sql # Database schema
├── .env # Environment variables
├── .gitignore # Git ignore rules
├── package.json # Dependencies and scripts
└── README.md # This file
Clone the repository
git clone https://git.mqldevelopment.com/muhammad.uzair/market-data-service.git
cd market-data-service
Install dependencies
npm install
Set up environment variables
cp .env.example .env
Edit .env with your database credentials and other configuration.
Set up the database ```bash
createdb market_data
# Run the schema psql -d market_data -f schema.sql
5. **Start the development server**
```bash
npm run dev
The server will start on http://localhost:3000
Create a .env file in the root directory with the following variables:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=market_data
DB_USER=your_username
DB_PASSWORD=your_password
# Server Configuration
PORT=3000
NODE_ENV=development
# JWT Configuration (if needed for authentication)
JWT_SECRET=your_jwt_secret_key
# API Keys (if needed for external services)
# BINANCE_API_KEY=your_api_key
# BINANCE_API_SECRET=your_api_secret
# CORS Configuration
CORS_ORIGIN=*
GET /health - Check service healthGET /api/symbols - Get all symbols (with filtering)GET /api/symbols/search - Search symbols by nameGET /api/symbols/:id - Get symbol by IDPOST /api/symbols - Create new symbolPUT /api/symbols/:id - Update symbolDELETE /api/symbols/:id - Delete symbol (soft delete)GET /api/candles - Get candles with filteringGET /api/candles/ohlc - Get OHLC dataGET /api/candles/:symbolId/latest - Get latest candle for symbolPOST /api/candles - Create new candlePOST /api/candles/bulk - Bulk create candlesGET /api/live-prices - Get all live pricesGET /api/live-prices/exchange/:exchange - Get live prices by exchangeGET /api/live-prices/type/:type - Get live prices by instrument typeGET /api/live-prices/:symbolId - Get live price for symbolPOST /api/live-prices - Create/update live pricePOST /api/live-prices/bulk - Bulk update live pricesDELETE /api/live-prices/:symbolId - Delete live priceThe service uses three main tables:
See schema.sql for complete table definitions.
npm start - Start production servernpm run dev - Start development server with auto-reloadnpm test - Run testsnpm run test:watch - Run tests in watch modenpm run lint - Run ESLintnpm run lint:fix - Fix ESLint issuesThis project uses ESLint for code linting. Run npm run lint to check for issues and npm run lint:fix to automatically fix them.
Tests are written using Jest. Add your test files in the tests/ directory.
NODE_ENV=production in your environmentnpm start to start the production serverISC License - see LICENSE file for details.
For support or questions, please contact the development team.