# Command Reference ## Common Command Failures **Critical: Learn from failures. Never repeat the same failed command without modification.** ### tea CLI (Gitea Command Line Tool) #### โŒ TTY Error - Interactive Confirmation Fails ```bash ~/bin/tea issues create --repo X --title "Y" --description "Z" # Error: huh: could not open a new TTY: open /dev/tty: no such device or address ``` **๐Ÿ’ก Reason:** tea tries to open `/dev/tty` for interactive confirmation prompts, which is unavailable in non-interactive environments. **โœ… Solution:** Use `YES=""` environment variable to bypass confirmation ```bash YES="" ~/bin/tea issues create --repo jihoson/The-Ouroboros --title "Title" --description "Body" YES="" ~/bin/tea issues edit --repo jihoson/The-Ouroboros --description "Updated body" YES="" ~/bin/tea pulls create --repo jihoson/The-Ouroboros --head feature-branch --base main --title "Title" --description "Body" ``` **๐Ÿ“ Notes:** - Always set default login: `~/bin/tea login default local` - Use `--repo jihoson/The-Ouroboros` when outside repo directory - tea is preferred over direct Gitea API calls for consistency #### โŒ Wrong Parameter Name ```bash tea issues create --body "text" # Error: flag provided but not defined: -body ``` **๐Ÿ’ก Reason:** Parameter is `--description`, not `--body`. **โœ… Solution:** Use correct parameter name ```bash YES="" ~/bin/tea issues create --description "text" ``` ### Gitea API (Direct HTTP Calls) #### โŒ Wrong Hostname ```bash curl http://gitea.local:3000/api/v1/... # Error: Could not resolve host: gitea.local ``` **๐Ÿ’ก Reason:** Gitea instance runs on `localhost:3000`, not `gitea.local`. **โœ… Solution:** Use correct hostname (but prefer tea CLI) ```bash curl http://localhost:3000/api/v1/repos/jihoson/The-Ouroboros/issues \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ -d '{"title":"...", "body":"..."}' ``` **๐Ÿ“ Notes:** - Prefer `tea` CLI over direct API calls - Only use curl for operations tea doesn't support ### Git Commands #### โŒ User Not Configured ```bash git commit -m "message" # Error: Author identity unknown ``` **๐Ÿ’ก Reason:** Git user.name and user.email not set. **โœ… Solution:** Configure git user ```bash git config user.name "agentson" git config user.email "agentson@localhost" ``` #### โŒ Permission Denied on Push ```bash git push origin branch # Error: User permission denied for writing ``` **๐Ÿ’ก Reason:** Repository access token lacks write permissions or user lacks repo write access. **โœ… Solution:** 1. Verify user has write access to repository (admin grants this) 2. Ensure git credential has correct token with `write:repository` scope 3. Check remote URL uses correct authentication ### Python/Pytest #### โŒ Module Import Error ```bash pytest tests/test_foo.py # ModuleNotFoundError: No module named 'src' ``` **๐Ÿ’ก Reason:** Package not installed in development mode. **โœ… Solution:** Install package with dev dependencies ```bash pip install -e ".[dev]" ``` #### โŒ Async Test Hangs ```python async def test_something(): # Hangs forever result = await async_function() ``` **๐Ÿ’ก Reason:** Missing pytest-asyncio or wrong configuration. **โœ… Solution:** Already configured in pyproject.toml ```toml [tool.pytest.ini_options] asyncio_mode = "auto" ``` No decorator needed for async tests. ## Build & Test Commands ```bash # Install all dependencies (production + dev) pip install -e ".[dev]" # Run full test suite with coverage (551 tests across 25 files) pytest -v --cov=src --cov-report=term-missing # Run a single test file pytest tests/test_risk.py -v # Run a single test by name pytest tests/test_brain.py -k "test_parse_valid_json" -v # Lint ruff check src/ tests/ # Type check (strict mode, non-blocking in CI) mypy src/ --strict # Run the trading agent python -m src.main --mode=paper # Run with dashboard enabled python -m src.main --mode=paper --dashboard # Docker docker compose up -d ouroboros # Run agent docker compose --profile test up test # Run tests in container ``` ## Dashboard The FastAPI dashboard provides read-only monitoring of the trading system. ### Starting the Dashboard ```bash # Via CLI flag python -m src.main --mode=paper --dashboard # Via environment variable DASHBOARD_ENABLED=true python -m src.main --mode=paper ``` Dashboard runs as a daemon thread on `DASHBOARD_HOST:DASHBOARD_PORT` (default: `127.0.0.1:8080`). ### API Endpoints | Endpoint | Description | |----------|-------------| | `GET /` | HTML dashboard UI | | `GET /api/status` | Daily trading status by market | | `GET /api/playbook/{date}` | Playbook for specific date (query: `market`) | | `GET /api/scorecard/{date}` | Daily scorecard from L6_DAILY context | | `GET /api/performance` | Performance metrics by market and combined | | `GET /api/context/{layer}` | Context data by layer L1-L7 (query: `timeframe`) | | `GET /api/decisions` | Decision log entries (query: `limit`, `market`) | | `GET /api/scenarios/active` | Today's matched scenarios | ## Telegram Commands When `TELEGRAM_COMMANDS_ENABLED=true` (default), the bot accepts these interactive commands: | Command | Description | |---------|-------------| | `/help` | List available commands | | `/status` | Show trading status (mode, markets, P&L) | | `/positions` | Display account summary (balance, cash, P&L) | | `/report` | Daily summary metrics (trades, P&L, win rate) | | `/scenarios` | Show today's playbook scenarios | | `/review` | Display recent scorecards (L6_DAILY layer) | | `/dashboard` | Show dashboard URL if enabled | | `/stop` | Pause trading | | `/resume` | Resume trading | Commands are only processed from the authorized `TELEGRAM_CHAT_ID`. ## KIS API TR_ID ์ฐธ์กฐ ๋ฌธ์„œ **TR_ID๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ˆ˜์ •ํ•  ๋•Œ ๋ฐ˜๋“œ์‹œ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋จผ์ € ํ™•์ธํ•  ๊ฒƒ.** ๊ณต์‹ ๋ฌธ์„œ: `docs/ํ•œ๊ตญํˆฌ์ž์ฆ๊ถŒ_์˜คํ”ˆAPI_์ „์ฒด๋ฌธ์„œ_20260221_030000.xlsx` > โš ๏ธ ์ปค๋ฎค๋‹ˆํ‹ฐ ๋ธ”๋กœ๊ทธ, GitHub ์˜ˆ์ œ ๋“ฑ ๋น„๊ณต์‹ ์ž๋ฃŒ์˜ TR_ID๋Š” ์˜ค๋ž˜๋˜๊ฑฐ๋‚˜ ํ‹€๋ฆด ์ˆ˜ ์žˆ์Œ. > ์‹ค์ œ๋กœ `VTTT1006U`(๋ฏธ๊ตญ ๋งค๋„ โ€” ์ž˜๋ชป๋จ)๊ฐ€ ์˜ค๋žซ๋™์•ˆ ์ฝ”๋“œ์— ๋‚จ์•„์žˆ๋˜ ์‚ฌ๋ก€๊ฐ€ ์žˆ์Œ (Issue #189). ### ์ฃผ์š” TR_ID ๋ชฉ๋ก | ๊ตฌ๋ถ„ | ๋ชจ์˜ํˆฌ์ž TR_ID | ์‹ค์ „ํˆฌ์ž TR_ID | ์‹œํŠธ๋ช… | |------|---------------|---------------|--------| | ํ•ด์™ธ์ฃผ์‹ ๋งค์ˆ˜ (๋ฏธ๊ตญ) | `VTTT1002U` | `TTTT1002U` | ํ•ด์™ธ์ฃผ์‹ ์ฃผ๋ฌธ | | ํ•ด์™ธ์ฃผ์‹ ๋งค๋„ (๋ฏธ๊ตญ) | `VTTT1001U` | `TTTT1006U` | ํ•ด์™ธ์ฃผ์‹ ์ฃผ๋ฌธ | ์ƒˆ๋กœ์šด TR_ID๊ฐ€ ํ•„์š”ํ•  ๋•Œ: 1. ์œ„ xlsx ํŒŒ์ผ์—์„œ ํ•ด๋‹น ๊ฑฐ๋ž˜ ์œ ํ˜•์˜ ์‹œํŠธ๋ฅผ ์ฐพ๋Š”๋‹ค. 2. ๋ชจ์˜ํˆฌ์ž(`VTTT`) / ์‹ค์ „ํˆฌ์ž(`TTTT`) ์ปฌ๋Ÿผ์„ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ •ํ™•ํ•œ ๊ฐ’์„ ์‚ฌ์šฉํ•œ๋‹ค. 3. ์ฝ”๋“œ์— ์ถœ์ฒ˜ ์ฃผ์„์„ ๋‚จ๊ธด๋‹ค: `# Source: ํ•œ๊ตญํˆฌ์ž์ฆ๊ถŒ_์˜คํ”ˆAPI_์ „์ฒด๋ฌธ์„œ โ€” '<์‹œํŠธ๋ช…>' ์‹œํŠธ` ## Environment Setup ```bash # Create .env file from example cp .env.example .env # Edit .env with your credentials # Required: KIS_APP_KEY, KIS_APP_SECRET, KIS_ACCOUNT_NO, GEMINI_API_KEY # Verify configuration python -c "from src.config import Settings; print(Settings())" ```