Documentation update

This commit is contained in:
2026-08-11 20:23:59 +03:00
parent 900b70d6df
commit c1c02e2b0d
7 changed files with 110 additions and 68 deletions
+23 -30
View File
@@ -1,30 +1,24 @@
# Manual Test Instructions
## IBKR Daily Fetcher
## Alpaca Daily Fetcher
This test checks the IBKR data fetcher and confirms it writes a symbol-named Parquet file.
This test checks the Alpaca data fetcher and confirms it writes a symbol-named Parquet file.
The fetcher currently requests:
- gateway: `127.0.0.1:4002`;
- client id: `101`;
- symbol: provided as a command line argument;
- end date: provided with `--end-date YYYYMMDD`, defaulting to yesterday;
- end date can also be derived with `--end-date-from-parquet`;
- duration: provided with `--duration`, defaulting to `1 W`;
- bar size: `1 day`;
- data type: `TRADES`;
- regular trading hours only;
- output: printed CSV-like rows and a Parquet file in `data/ibkr/daily/`.
- data source: Alpaca stock bars through `alpaca-py`;
- output: a Parquet file in `data/alpaca/daily/`.
## Prerequisites
1. Start IBKR Gateway.
2. Log in to the paper trading account.
3. Confirm API access is enabled in IBKR Gateway.
4. Confirm the API socket port is `4002`.
5. Confirm no other API client is already using client id `101`.
6. Sync Python dependencies:
1. Create or confirm Alpaca API credentials.
2. Provide credentials through `ALPACA_API_KEY` and `ALPACA_SECRET_KEY`, a local `.env`, or CLI arguments.
3. Sync Python dependencies:
```sh
mise exec -- uv sync
@@ -35,52 +29,51 @@ mise exec -- uv sync
From the repository root, run:
```sh
mise exec -- uv run python src/trading_bot/data/fetch_ibkr_daily.py SPY
mise exec -- uv run python src/trading_bot/data/fetch_alpaca_daily.py SPY
```
To fetch a specific IBKR range, pass an end date and duration:
To fetch a specific Alpaca range, pass an end date and duration:
```sh
mise exec -- uv run python src/trading_bot/data/fetch_ibkr_daily.py SPY --end-date 20250605 --duration "1 M"
mise exec -- uv run python src/trading_bot/data/fetch_alpaca_daily.py SPY --end-date 20250605 --duration "1 M"
```
To fetch backward from the oldest date already stored in `data/ibkr/daily/SPY.parquet`:
To fetch backward from the oldest date already stored in `data/alpaca/daily/SPY.parquet`:
```sh
mise exec -- uv run python src/trading_bot/data/fetch_ibkr_daily.py SPY --end-date-from-parquet
mise exec -- uv run python src/trading_bot/data/fetch_alpaca_daily.py SPY --end-date-from-parquet
```
`--end-date` and `--end-date-from-parquet` cannot be used together. If the symbol Parquet file does not exist or has no rows, `--end-date-from-parquet` uses today's US/Eastern date.
## Expected Output
The tool should first print the request range and connection target:
The tool should first print the request range:
```text
Fetching SPY daily candles ending 2025-06-05 for duration 1 M
Connecting to IBKR Gateway at 127.0.0.1:4002 with client id 101
Fetching SPY daily candles ending 2025-06-05 for duration 1 M via Alpaca API
```
If the request succeeds, it should then print a header and one row per returned trading day:
If the request succeeds, it should print how many candles were fetched and where the merged Parquet file was written:
```text
date,symbol,open,high,low,close,volume
2025-06-05,SPY,...
Fetched 21 daily candles for SPY.
Wrote 21 total daily rows to data/alpaca/daily/SPY.parquet
```
Exact prices and volume depend on what IBKR returns.
Exact row counts depend on the requested date range and market calendar.
The tool should then write or update:
```text
data/ibkr/daily/SPY.parquet
data/alpaca/daily/SPY.parquet
```
If the Parquet file already exists, rows from the latest fetch are merged into it. The trading date is used as the row key, so a symbol file keeps only one row for each date.
## Common Issues
- Connection refused: IBKR Gateway is not running, the port is not `4002`, or API access is disabled.
- Client id already in use: change `IBKR_CLIENT_ID` in the fetcher or disconnect the other client.
- No historical bars: confirm the account has market data permissions and that IBKR accepts the requested historical data range.
- Pacing or permission errors: note the IBKR error message before changing the request.
- Missing credentials: set `ALPACA_API_KEY` and `ALPACA_SECRET_KEY` or pass them with CLI flags.
- No historical bars: confirm the symbol, requested range, and Alpaca market data permissions.
- Authentication or entitlement errors: confirm the keys belong to the intended Alpaca account and data plan.
- Rate-limit errors: wait before retrying or reduce repeated requests.