Cryptocurrency K-Line data collection and management platform, supporting Binance spot market data.
- Multiple trading pairs (BTCUSDT, ETHUSDT, BNBUSDT, etc.)
- Multiple K-Line intervals (1m, 5m, 15m, 1h, 4h, 1d, etc.)
- Automatic gap detection and backfilling
- Real-time task progress monitoring
- View collected data statistics
- Filter by trading pair and K-Line interval
- Display data time range
- TradingView lightweight-charts rendering
- 13 Technical indicators:
- Volume (VOL)
- MACD
- RSI
- KDJ
- Bollinger Bands (BOLL)
- CCI
- Williams %R (WR)
- ATR
- ADX
- SAR
- OBV
- MFI
- Stochastic (Stoch)
- Toggle MA5/MA10/MA20/MA60 moving averages
- Jump to specific time
- Light/Dark theme toggle
- Chinese/English language switch
- Responsive layout
- React 18 + TypeScript
- Ant Design 5
- TradingView lightweight-charts v5
- dayjs for date handling
- FastAPI (Python 3.10+)
- SQLAlchemy + asyncpg (async database)
- PostgreSQL database
- Redis (optional, for caching)
- Node.js 18+
- Python 3.10+
- PostgreSQL 14+
- npm or yarn
git clone <repository-url>
cd CryptoDataSetcd frontend
npm installcd backend
pip install -r requirements.txtCreate PostgreSQL database:
CREATE DATABASE crypto_kline;Set environment variable or modify backend/app/core/config.py:
DATABASE_URL = "postgresql+asyncpg://postgres:postgres@localhost:5432/crypto_kline"cd backend
python -c "from app.core.database import engine, Base; import asyncio; asyncio.run(Base.metadata.create_all(engine))"cd backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd frontend
npm startVisit http://localhost:3000 to view the application.
CryptoDataSet/
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── DataCollection.tsx # Data collection
│ │ │ ├── DataManagement.tsx # Data management
│ │ │ └── KlineChart.tsx # K-Line chart
│ │ ├── contexts/ # React Context
│ │ │ └── ThemeContext.tsx # Theme context
│ │ ├── i18n/ # Internationalization
│ │ │ ├── locales.ts # Language files
│ │ │ └── LanguageContext.tsx # Language context
│ │ ├── App.tsx # Main app component
│ │ └── App.css # Global styles
│ └── package.json
├── backend/
│ ├── app/
│ │ ├── api/
│ │ │ └── routes.py # API routes
│ │ ├── core/
│ │ │ ├── config.py # Configuration
│ │ │ ├── database.py # Database connection
│ │ │ ├── middleware.py # Middleware (logging, monitoring)
│ │ │ └── rate_limit.py # Rate limiting
│ │ ├── services/
│ │ │ ├── binance_service.py # Binance API
│ │ │ ├── kline_service.py # K-Line service
│ │ │ └── task_manager.py # Task management
│ │ └── main.py # FastAPI entry point
│ └── requirements.txt
└── README.md
After starting the backend server:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Path | Description |
|---|---|---|
| GET | /api/config |
Get config (symbols, intervals list) |
| GET | /api/tasks |
Get task list |
| POST | /api/kline/collect |
Trigger data collection |
| GET | /api/kline/{symbol}/{interval}/info |
Get data statistics |
| GET | /api/kline/{symbol}/{interval}/previous |
Get historical K-Lines |
| GET | /api/kline/{symbol}/{interval}/next |
Get future K-Lines |
| GET | /health |
Health check |
| GET | /metrics |
Monitoring metrics |
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
PostgreSQL database connection string | postgresql+asyncpg://postgres:postgres@localhost:5432/crypto_kline |
BINANCE_PROXY |
Binance API proxy address (required in some regions like mainland China) | http://127.0.0.1:1080 |
Configure in backend/.env file:
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/crypto_kline
BINANCE_PROXY=http://127.0.0.1:1080Modify CONFIG_SYMBOLS in backend/app/api/routes.py:
CONFIG_SYMBOLS = [
"BTCUSDT", "ETHUSDT", "BNBUSDT", "SOLUSDT", "XRPUSDT",
"ADAUSDT", "DOGEUSDT", "AVAXUSDT", "DOTUSDT", "MATICUSDT",
]Modify CONFIG_INTERVALS in backend/app/api/routes.py:
CONFIG_INTERVALS = ["1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w", "1M"]curl http://localhost:8000/healthcurl http://localhost:8000/metricsBackend logs are output to console, including:
- Request logs (method, path, status code, response time)
- Collection progress logs
- Error logs
MIT License