Skip to content

Commit f789dff

Browse files
committed
update coilot instructions
1 parent 725e9ef commit f789dff

File tree

1 file changed

+72
-116
lines changed

1 file changed

+72
-116
lines changed

.github/copilot-instructions.md

Lines changed: 72 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,78 @@
1-
# Bitvavo API Upgraded - AI Coding Assistant Instructions
2-
3-
## Project Overview
4-
5-
This is a **typed, tested, and enhanced** Python wrapper for the Bitvavo cryptocurrency exchange API. It's an "upgraded" fork of the official Bitvavo SDK with comprehensive type hints, unit tests, and improved developer experience.
6-
7-
## Architecture & Key Components
8-
9-
### Core API Structure
10-
11-
- **Main class**: `Bitvavo` in `src/bitvavo_api_upgraded/bitvavo.py` - handles both REST and WebSocket operations
12-
- **Dual API pattern**: REST methods return dict/list data directly; WebSocket methods use callbacks
13-
- **WebSocket facade**: `WebSocketAppFacade` nested class provides WebSocket functionality with reconnection logic
14-
- **Settings system**: Pydantic-based configuration in `src/bitvavo_api_upgraded/settings.py`
15-
16-
### Project Layout (src-layout)
17-
18-
```
19-
src/bitvavo_api_upgraded/ # Source code
20-
├── __init__.py # Main exports
21-
├── bitvavo.py # Core API class (~3600 lines)
22-
├── settings.py # Pydantic settings
23-
├── helper_funcs.py # Utility functions
24-
└── type_aliases.py # Type definitions
25-
tests/ # Comprehensive test suite
26-
```
27-
28-
## Development Workflows
29-
30-
### Essential Commands
31-
32-
```bash
33-
# Development setup
34-
uv sync # Install all dependencies
35-
uv run tox # Run full test suite across Python versions
36-
37-
# Testing & Coverage
38-
uv run pytest # Run tests with debugging support
39-
uv run coverage run --source=src --module pytest # Coverage with proper src-layout
40-
uv run coverage report # View coverage results
41-
42-
# Code Quality
43-
uv run ruff format # Format code
44-
uv run ruff check # Lint code
45-
uv run mypy src/ # Type checking
46-
```
47-
48-
### Coverage Configuration Notes
49-
50-
- Uses `coverage.py` instead of `pytest-cov` (breaks VS Code debugging)
51-
- Requires `--source=src` for src-layout projects
52-
- `tox.ini` sets `PYTHONPATH={toxinidir}/src` for proper module resolution
53-
54-
## Project-Specific Patterns
55-
56-
### Testing Strategy
57-
58-
- **Defensive testing**: Many tests skip risky operations (`@pytest.mark.skipif` for trading methods)
59-
- **API flakiness**: Tests handle inconsistent Bitvavo API responses (see `conftest.py` market filtering)
60-
- **WebSocket challenges**: Entire `TestWebsocket` class skipped due to freezing issues
61-
- **Mock patterns**: Use `pytest-mock` for time functions and external dependencies
62-
63-
### Type System & Error Handling
64-
65-
- **Strict typing**: `mypy` configured with `disallow_untyped_defs=true`
66-
- **Return types**: Methods return `dict | list` for success, `errordict` for API errors
67-
- **Type aliases**: Custom types like `ms` (milliseconds), `anydict` in `type_aliases.py`
68-
69-
### Rate Limiting & Authentication
70-
71-
- **Weight-based limits**: Bitvavo uses 1000 points/minute, tracked in `rateLimitRemaining`
72-
- **Settings pattern**: Use `BitvavoSettings` for API config, `BitvavoApiUpgradedSettings` for extras
73-
- **Environment variables**: Load via `.env` file with `BITVAVO_APIKEY`/`BITVAVO_APISECRET`
74-
75-
### Versioning & Release
76-
77-
- **Semantic versioning**: Automated with `bump-my-version`
78-
- **Changelog-first**: Update `CHANGELOG.md` with `$UNRELEASED` token before version bumps
79-
- **GitHub Actions**: Automated publishing on tag creation
80-
81-
## Code Quality Standards
82-
83-
### Linting Configuration
84-
85-
- **Ruff**: Replaces black, isort, flake8 with `select = ["ALL"]` and specific ignores
86-
- **Line length**: 120 characters consistently across tools
87-
- **Test exemptions**: Tests ignore safety checks (`S101`), magic values (`PLR2004`)
88-
89-
### Documentation Patterns
90-
91-
- **Extensive docstrings**: WebSocket methods include JSON response examples
92-
- **Rate limit documentation**: Each method documents its weight cost
93-
- **API mirroring**: Maintains parity with official Bitvavo API documentation
1+
# Bitvavo API Upgraded – AI Coding Agent Instructions
2+
3+
This project is a **typed, modular, and tested Python SDK** for the Bitvavo cryptocurrency exchange, featuring both a legacy monolithic API and a modern, agent-based architecture. It is designed for reliability, extensibility, and developer ergonomics.
4+
5+
## Architecture Overview
6+
7+
- **Two main API entry points:**
8+
- `Bitvavo` (legacy, monolithic, in `src/bitvavo_api_upgraded/bitvavo.py`): REST & WebSocket, direct dict/list returns, callback-based WS.
9+
- `BitvavoClient` (modern, in `src/bitvavo_client/facade.py`): Modular, testable, supports dependency injection, orchestrates endpoint agents.
10+
- **Agent pattern:** Each major concern (public/private endpoints, transport, rate limiting, signing, settings, schema, DataFrame conversion) is a separate agent/module. See `AGENTS.md` for a full list and responsibilities.
11+
- **Settings:** Pydantic-based, loaded from `.env` or environment, with strict validation. See `src/bitvavo_api_upgraded/settings.py` and `src/bitvavo_client/core/settings.py`.
12+
- **Testing:** Defensive, with many tests skipped for risky or flaky API operations. See `tests/` and `tests/bitvavo_api_upgraded/conftest.py` for market filtering and skip logic.
13+
14+
## Key Developer Workflows
15+
16+
- **Install dependencies:**
17+
```bash
18+
uv sync
19+
```
20+
- **Run all tests (multi-version):**
21+
```bash
22+
uv run tox
23+
```
24+
- **Debug tests:**
25+
```bash
26+
uv run pytest
27+
```
28+
- **Check coverage:**
29+
```bash
30+
uv run coverage run --source=src --module pytest
31+
uv run coverage report
32+
```
33+
- **Lint/format/typecheck:**
34+
```bash
35+
uv run ruff format
36+
uv run ruff check --fix --unsafe-fixes
37+
uv run mypy src/
38+
```
39+
40+
**Coverage tip:** Always use `--source=src` and ensure `PYTHONPATH` is set to `src` (see `tox.ini`). Do not use `pytest-cov` (breaks VS Code debugging).
41+
42+
## Project-Specific Patterns & Conventions
43+
44+
- **Strict typing:** All code is type-checked with `mypy` (`disallow_untyped_defs=true`). Update `type_aliases.py` for new types.
45+
- **Return types:** REST methods return `dict | list` or error dicts; modern client uses Result types for functional error handling.
46+
- **Rate limiting:** Bitvavo uses a 1000 points/minute system. Always check `getRemainingLimit()` before trading. Managed by `RateLimitManager` agent.
47+
- **Testing:** Many tests are skipped for trading, withdrawals, or flaky endpoints. WebSocket tests are mostly skipped due to instability.
48+
- **DataFrames:** Unified DataFrame conversion via Narwhals, with schemas in `src/bitvavo_client/schemas/` and utils in `src/bitvavo_api_upgraded/dataframe_utils.py`.
49+
- **Settings:** Use Pydantic settings classes for all config. Environment variables: `BITVAVO_APIKEY`, `BITVAVO_APISECRET`, etc.
50+
- **Versioning:** Use `bump-my-version` and update `CHANGELOG.md` before bumping.
9451

9552
## Integration Points
9653

97-
### External Dependencies
98-
99-
- **Bitvavo API**: REST at `api.bitvavo.com/v2`, WebSocket at `ws.bitvavo.com/v2/`
100-
- **Key libraries**: `requests` (REST), `websocket-client` (WS), `pydantic-settings` (config)
101-
- **Development tools**: `tox` (multi-version testing), `uv` (dependency management)
102-
103-
### Configuration Management
104-
105-
- **Pydantic settings**: Type-safe config loading from environment/`.env`
106-
- **Dual settings classes**: Separate original vs. enhanced functionality
107-
- **Validation**: Custom validators for log levels, rate limits
54+
- **Bitvavo API:** REST (`api.bitvavo.com/v2`), WebSocket (`ws.bitvavo.com/v2/`)
55+
- **Key libraries:** `requests`, `websocket-client`, `pydantic-settings`, `returns`, `tox`, `uv`, `ruff`, `mypy`
56+
- **Settings loading:** `.env` file or environment, validated by Pydantic
10857

10958
## Common Gotchas
11059

111-
1. **Coverage setup**: Must use `--source=src` and set `PYTHONPATH` for src-layout
112-
2. **WebSocket testing**: Currently unreliable, most WS tests are skipped
113-
3. **Market filtering**: Some API responses include broken markets that tests filter out
114-
4. **VS Code debugging**: Disable `pytest-cov` extension to avoid conflicts with `coverage.py`
115-
5. **Rate limiting**: Always check `getRemainingLimit()` before making API calls
116-
117-
## When Making Changes
118-
119-
- **Add tests**: Follow the defensive testing pattern, skip risky operations
120-
- **Update types**: Maintain strict typing, update `type_aliases.py` if needed
121-
- **Consider API changes**: This wrapper mirrors Bitvavo's API structure closely
122-
- **Version bumps**: Update `CHANGELOG.md` first, then use `bump-my-version`
60+
1. **Coverage:** Must use `--source=src` and set `PYTHONPATH` for src-layout
61+
2. **WebSocket tests:** Unreliable, mostly skipped
62+
3. **Market filtering:** Some API responses include broken markets; tests filter these
63+
4. **VS Code debugging:** Disable `pytest-cov` extension to avoid conflicts
64+
5. **Rate limiting:** Always check before trading
65+
66+
## Key Files & References
67+
68+
- `AGENTS.md`: Full agent/component breakdown
69+
- `src/bitvavo_api_upgraded/bitvavo.py`: Legacy API class
70+
- `src/bitvavo_client/facade.py`: Modern client facade
71+
- `src/bitvavo_client/endpoints/`: Public/private endpoint agents
72+
- `src/bitvavo_client/auth/`: Rate limiting & signing
73+
- `src/bitvavo_api_upgraded/settings.py`, `src/bitvavo_client/core/settings.py`: Settings
74+
- `src/bitvavo_api_upgraded/dataframe_utils.py`: DataFrame conversion
75+
- `tests/`: Defensive, skip-heavy test suite
76+
77+
---
78+
For more details, see `AGENTS.md` and in-code docstrings. When in doubt, mirror the structure and patterns of existing agents and tests.

0 commit comments

Comments
 (0)