Skip to content

Add OrderBook module for managing bid portfolios#6

Merged
tommed merged 2 commits into
mainfrom
feat/add-bids-module
Mar 13, 2026
Merged

Add OrderBook module for managing bid portfolios#6
tommed merged 2 commits into
mainfrom
feat/add-bids-module

Conversation

@tommed

@tommed tommed commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the orders.py module - an immutable order book/portfolio container for managing collections of bids for European power market auctions.

New functionality:

  • OrderBook: Frozen Pydantic v2 model with automatic validation
  • Collection management: Add, remove, and filter bids immutably
  • Querying: Filter by zone, direction, status, type, and time period
  • Aggregation: Count bids, calculate volumes, generate summaries
  • Status updates: Single and bulk bid status management
  • DataFrame export: Convert to pandas for analysis

Key design decisions:

  • Copy-on-write immutability (all operations return new instances)
  • Uses validate_bid_collection() from bids module for consistency
  • Special handling for ExclusiveGroupBid (group_id and member access)
  • Rejects naive datetimes throughout

Files changed:

  • src/nexa_bidkit/orders.py - 254 lines of implementation
  • tests/test_orders.py - 49 tests with 100% coverage
  • src/nexa_bidkit/__init__.py - Exports for OrderBook and all functions
  • README.md - Usage examples added

Test plan

  • All 198 tests pass (49 new tests for orders module)
  • 100% code coverage on orders.py (overall 98%)
  • Type checking: poetry run mypy src - zero errors
  • Linting: poetry run ruff check src tests - all checks passed
  • Formatting: poetry run ruff format src tests - code formatted
  • Manual verification of OrderBook creation, querying, and export
  • Validated immutability behaviour (original instances unchanged)
  • Tested duplicate detection and parent reference validation

🤖 Generated with Claude Code

tommed and others added 2 commits March 13, 2026 18:39
Implement immutable order book container with comprehensive bid
management capabilities. Enables traders to organise, query, and
analyse collections of SimpleBid, BlockBid, LinkedBlockBid, and
ExclusiveGroupBid instances for submission to EUPHEMIA auctions.

Key features:
- Immutable operations with copy-on-write pattern
- Automatic validation of bid collections (duplicates, parent refs)
- Rich querying: by zone, direction, status, type, time period
- Aggregation: volume totals, bid counts, comprehensive summaries
- Status management: single and bulk updates
- pandas DataFrame export for analysis

All functions include Google-style docstrings, full type hints,
and 100% test coverage (49 tests, 254 lines of implementation).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Mar 13, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@tommed tommed merged commit 148836e into main Mar 13, 2026
3 checks passed
@tommed tommed deleted the feat/add-bids-module branch March 13, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant