Skip to content

feat: Blotter System for Trade Documentation and Order Book Management#474

Merged
MDUYN merged 4 commits into
devfrom
feature/blotter-system
Apr 23, 2026
Merged

feat: Blotter System for Trade Documentation and Order Book Management#474
MDUYN merged 4 commits into
devfrom
feature/blotter-system

Conversation

@MDUYN
Copy link
Copy Markdown
Collaborator

@MDUYN MDUYN commented Apr 23, 2026

Summary

Implements a Blotter system for trade documentation and order book management (#457).

Changes

New: Blotter Abstract Base Class

  • place_order(order_data, context) — abstract method for order placement
  • batch_order(orders, context) — sequential batch order placement
  • cancel_order(order_id, context) — abstract method for order cancellation
  • get_open_orders(context) — delegates to context
  • record_transaction(transaction) / get_transactions() / clear_transactions() — transaction ledger
  • prune_orders(context) — hook for stale order cleanup

New: SimulationBlotter

  • Configurable SlippageModel: NoSlippage, PercentageSlippage, FixedSlippage
  • Configurable CommissionModel: NoCommission, PercentageCommission, FixedCommission
  • Automatically applies slippage/commission on order placement
  • Records Transaction objects with full cost breakdown

New: Transaction Data Class

  • Fields: order_id, symbol, order_side, price, amount, cost, commission, slippage, timestamp
  • to_dict() and __repr__() for serialization/debugging

Integration

  • App.set_blotter(blotter) / App.get_blotter() — configure blotter on the app
  • Context.batch_order(orders) — routes through blotter if set, otherwise creates orders directly
  • Context.get_transactions() — returns transaction ledger from blotter

Tests

  • 43 unit tests covering all models, Transaction, Blotter ABC, SimulationBlotter, and imports

Closes #457

MDUYN added 4 commits April 23, 2026 18:15
…ement

- Add Blotter ABC with place_order, cancel_order, batch_order, and transaction recording
- Add SimulationBlotter with configurable slippage and commission models
- Add SlippageModel (NoSlippage, PercentageSlippage, FixedSlippage)
- Add CommissionModel (NoCommission, PercentageCommission, FixedCommission)
- Add Transaction data class for trade documentation
- Integrate blotter into App (set_blotter/get_blotter) and Context (batch_order/get_transactions)
- Add 43 unit tests

Closes #457
…e docs

- Add DefaultBlotter as pass-through blotter for live trading
- Refactor SimulationBlotter to call order_service.create() directly
- Route all Context order methods through the Blotter
- Refactor create_limit_buy/sell_order to delegate to create_limit_order
- Remove conditional blotter checks (always set via App)
- Auto-set DefaultBlotter (live) or SimulationBlotter (backtest)
- Remove unused OrderType import (flake8)
- Add Blotter documentation page (Advanced Concepts)
- Update sidebar navigation
- Update tests (48 passing)
…fix cancel_order - Delete dead BacktestOrderExecutor (was never called) - Route TradeOrderEvaluator SL/TP orders through blotter via _create_order() - Pass blotter+context to TradeOrderEvaluator in App and BacktestService - Fix cancel_order tests to match delegate-to-order_service pattern - Fix OrderBacktestService.cancel_order pre-existing bug - Clean up commented BacktestOrderExecutor refs in test_eventloop - 1423 passed, 42 skipped
- Move slippage/commission from order creation to fill time in
  SimulationBlotter, eliminating double-counting
- Add VolumeImpactSlippage model (power-law market impact)
- Add FillModel ABC with FullFill and VolumeBasedFill for partial
  fill simulation
- Refactor BacktestTradeOrderEvaluator to delegate to blotter
  methods (get_fill_price, get_fill_commission, get_fill_amount,
  on_fill) with TradingCost fallback
- Record transactions at fill time via blotter.on_fill()
- Clean test_eventloop.py: remove ~500 lines of commented-out code
- Update test_blotter.py for new fill-time architecture
@MDUYN MDUYN merged commit 0c01673 into dev Apr 23, 2026
6 checks passed
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