Instructions for working with the HTX (Huobi) trading analytics platform - a FastAPI async backend with React frontend, SQLAlchemy 2.0, and 3Commas/HTX integrations.
Instructions for GitHub Copilot when working with the HTX (Huobi) trading analytics platform.
This is a multi-component trading analytics platform for HTX (Huobi) and 3Commas, featuring:
**Core Files:**
**Legacy/CLI:**
**Data & Scripts:**
Standard React application structure with npm/yarn workflows.
**Windows:**
```bash
scripts/setup_env.bat
```
This creates a virtual environment, installs dependencies, and starts the backend.
**Manual Setup:**
```bash
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Unix
pip install -r requirements.txt
```
From the `backend/` directory:
```bash
python -m uvicorn app.main:app --host 127.0.0.1 --port 8004
```
The API will be available at `http://127.0.0.1:8004`
From the `backend/` directory:
```bash
pytest
```
Tests are located in `backend/tests/`
**Formatting:**
```bash
black .
```
**Linting:**
```bash
flake8 .
```
**Type Checking:**
```bash
mypy .
```
Alembic is used for database migrations:
**Create a new migration:**
```bash
cd backend
alembic revision --autogenerate -m "Description"
```
**Apply migrations:**
```bash
alembic upgrade head
```
Standard React workflow:
```bash
cd frontend
npm install
npm run dev
```
All backend imports use absolute paths from `app.`:
```python
from app.core.config import settings
from app.models.trade import Trade
from app.services.threecommas import ThreeCommasService
```
The codebase uses async/await throughout:
```python
@router.get("/trades")
async def get_trades(db: AsyncSession = Depends(get_db)):
result = await db.execute(select(Trade))
return result.scalars().all()
```
All endpoints are versioned under `/api/v1/`:
```python
app.include_router(trades_router, prefix="/api/v1/trades")
```
Files are uploaded via `/api/v1/files/upload`:
1. Create a new router file in `api/v1/endpoints/`:
```python
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from app.db.session import get_db
router = APIRouter()
@router.get("/example")
async def get_example(db: AsyncSession = Depends(get_db)):
# Implementation
return {"status": "ok"}
```
2. Register the router in `main.py`:
```python
from app.api.v1.endpoints import example
app.include_router(example.router, prefix="/api/v1/example", tags=["example"])
```
1. Create a service file in `services/`:
```python
from app.core.config import settings
class ExampleService:
def __init__(self):
self.config = settings
async def perform_action(self):
# Implementation
pass
```
2. Inject via endpoint dependency:
```python
@router.get("/action")
async def action(service: ExampleService = Depends()):
result = await service.perform_action()
return result
```
1. Define model in `models/`:
```python
from sqlalchemy import Column, Integer, String
from app.db.base_class import Base
class Example(Base):
__tablename__ = "examples"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, nullable=False)
```
2. Create and apply migration:
```bash
cd backend
alembic revision --autogenerate -m "Add example table"
alembic upgrade head
```
1. **Input:** CSV/Excel files uploaded via API
2. **Parsing:** Files parsed and validated
3. **Storage:** Data stored in database (SQLite/PostgreSQL)
4. **Analysis:** PnL, cashflow, and other analytics computed
5. **API:** Results exposed via REST endpoints
6. **Integration:** 3Commas/HTX APIs used for sync and automation
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/htx-trading-analytics-platform/raw