Skip to content

Latest commit

 

History

History
98 lines (75 loc) · 2.4 KB

File metadata and controls

98 lines (75 loc) · 2.4 KB

Trade360Lab Python Parser

FastAPI сервис для импорта рыночных свечей в PostgreSQL.

Стек

Python FastAPI Uvicorn Psycopg PostgreSQL Requests

Структура

backend/python/
|-- parser/
|   |-- main.py
|   |-- config.py
|   |-- db.py
|   |-- schema.sql
|   |-- exchanges/
|   |   `-- binance/
|   |-- repositories/
|   `-- services/
|-- requirements.txt
`-- run_local_postgres.ps1

API

  • GET /health
  • POST /internal/import/candles

Пример запроса:

{
  "exchange": "binance",
  "symbol": "BTCUSDT",
  "interval": "1h",
  "from": "2024-01-01T00:00:00Z",
  "to": "2024-01-10T00:00:00Z"
}

Переменные окружения

Создай .env в backend/python на основе .env.example.

Ключевые переменные:

  • DB_HOST
  • DB_PORT
  • DB_NAME
  • DB_USER
  • DB_PASSWORD
  • BINANCE_BASE_URL
  • BINANCE_API_KEY
  • BINANCE_API_SECRET
  • PYTHON_SERVICE_PORT

Запуск локально

cd backend/python
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
uvicorn parser.main:app --host 0.0.0.0 --port 8000

При старте сервис применяет parser/schema.sql.

Локальный PostgreSQL (опционально)

cd backend/python
powershell -ExecutionPolicy Bypass -File .\run_local_postgres.ps1

Скрипт поднимает кластер на localhost:55432:

  • БД: tradelab
  • Пользователь: postgres
  • Пароль: postgres

Docker

docker build -t tradelab-python ./backend/python