Skip to content

Ash-seah/tsetmc-datafetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TSETMC Market Data Service

🚀 Quick Start

Single Command Deployment:

# Windows
start.bat

# Linux/Mac  
./start.sh

# Manual
docker compose up -d

Access the application:

✨ Features

  • Unified Deployment: Single Dockerfile deployment
  • Real-time WebSocket: Live stock data updates (5-second intervals)
  • REST API: Complete market data with 2-minute caching
  • Market Hours Awareness: Automatic polling during market hours (9:00 AM - 12:30 PM Tehran time)
  • Redis Caching: fast API responses
  • PostgreSQL Persistence: Historical data storage

🏗️ Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Frontend      │    │   Backend        │    │   Database      │
│   (React)       │◄──►│   (FastAPI)      │◄──►│   (PostgreSQL)  │
│   Port 80       │    │   Port 8000      │    │   Port 5432     │
└─────────────────┘    └─────────────────┘    └─────────────────┘
         │                       │                       │
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Nginx         │    │   Redis         │    │   WebSocket     │
│   (Reverse      │    │   (Cache)       │    │   (Real-time)   │
│    Proxy)       │    │   Port 6379     │    │   Updates)      │
└─────────────────┘    └─────────────────┘    └─────────────────┘

📊 API Endpoints

REST API

  • GET /api/health - Service health check
  • GET /api/market/status - Current market status
  • GET /api/market/all - Complete market data
  • GET /api/websocket/stats - WebSocket connection statistics

WebSocket

  • ws://localhost/market/{ins_code}/realtime - Real-time stock data

🔧 Commands

# Start services
docker compose up -d

# View logs
docker compose logs -f tsetmc-app

# Stop services
docker compose down

# Restart services
docker compose restart

# Check Redis cache
docker compose exec redis redis-cli

# Access database
docker compose exec postgres psql -U tsetmc_user -d tsetmc_market

📈 Market Hours

The Iranian stock market operates:

  • Days: Sunday to Thursday (Friday and Saturday are weekends)
  • Hours: 9:00 AM to 12:30 PM Tehran time
  • Timezone: Asia/Tehran

🗄️ Data Persistence

  • PostgreSQL: postgres_data volume
  • Redis: redis_data volume
  • Logs: ./logs/ directory

🌐 Environment Variables

  • DATABASE_URL: PostgreSQL connection string
  • REDIS_URL: Redis connection string
  • LOG_LEVEL: Logging level (INFO, DEBUG, ERROR)

📝 WebSocket Testing

Test real-time stock data in browser console:

const ws = new WebSocket('ws://localhost/market/778253364357513/realtime');
ws.onmessage = (event) => console.log(JSON.parse(event.data));

🔍 Monitoring


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published