feat: Blotter System for Trade Documentation and Order Book Management#474
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a Blotter system for trade documentation and order book management (#457).
Changes
New:
BlotterAbstract Base Classplace_order(order_data, context)— abstract method for order placementbatch_order(orders, context)— sequential batch order placementcancel_order(order_id, context)— abstract method for order cancellationget_open_orders(context)— delegates to contextrecord_transaction(transaction)/get_transactions()/clear_transactions()— transaction ledgerprune_orders(context)— hook for stale order cleanupNew:
SimulationBlotterSlippageModel:NoSlippage,PercentageSlippage,FixedSlippageCommissionModel:NoCommission,PercentageCommission,FixedCommissionTransactionobjects with full cost breakdownNew:
TransactionData Classto_dict()and__repr__()for serialization/debuggingIntegration
App.set_blotter(blotter)/App.get_blotter()— configure blotter on the appContext.batch_order(orders)— routes through blotter if set, otherwise creates orders directlyContext.get_transactions()— returns transaction ledger from blotterTests
Closes #457