# Code Style & Conventions ## Python - Django app: all business logic in `api/stock/`, not in views - views.py is thin forwarding layer: extract params -> call function -> return Response - Double import pattern for standalone scripts: try relative import first, fall back to absolute - Use `viewFunc_tsCodeAndDate()` wrapper for ts_code + date_range endpoints - Use `viewFunc_singleParam()` wrapper for single-param endpoints - DRF `@api_view(['GET'])` + `@extend_schema` on all views - DRF `Response` (not `JsonResponse`) — no `safe=False` parameter - Configuration split: config.py (token) / strategy_config.py / scan_config.py ## Constraints - `api/video/` is protected — do NOT modify unless user explicitly asks - No python-dotenv dependency — use stdlib env loaders only - Backward compatibility: keep re-exports when splitting modules - Server `.env` file manages all secrets; uwsgi.ini only has DJANGO_SETTINGS_MODULE ## Secrets - All API keys/tokens/passwords via os.getenv() - Local: .env file (not committed) - Server: /home/simon/myquant/djapi/.env - Django loads via djapi/env_loader.py, video loads via api/video/env.py