Objective
Develop a volume-weighted pricing engine that computes a clearing price based on the weighted average of individual order prices. The engine should consider the volume of each order when calculating a uniform clearing price, providing a fairer distribution across large and small orders.
Tasks
- Create a new module
src/pricing/volume_weighted.rs that defines VolumeWeightedPricingEngine implementing the PricingEngine trait.
- In
compute_clearing_price(&[Order]) -> Option<Decimal>, calculate the weighted average of each order's implied price (buy_amount / sell_amount) using sell_amount as the weight.
- Return
None if there are fewer than two orders or if total sell volume is zero.
- Add unit tests that verify:
None is returned for zero or one order.
- The weighted average price is correct for multiple orders with varying sizes.
- Update
src/pricing/mod.rs to expose the volume_weighted module.
- Update documentation (README or relevant docs) to describe the new pricing strategy and how to select it via CLI or config.
Acceptance Criteria
- New module compiles without errors and is covered by tests.
Cargo test passes for all existing and new tests.
- Documentation reflects the new pricing engine and usage.
Closes #? (to be filled when opening PR).
Objective
Develop a volume-weighted pricing engine that computes a clearing price based on the weighted average of individual order prices. The engine should consider the volume of each order when calculating a uniform clearing price, providing a fairer distribution across large and small orders.
Tasks
src/pricing/volume_weighted.rsthat definesVolumeWeightedPricingEngineimplementing thePricingEnginetrait.compute_clearing_price(&[Order]) -> Option<Decimal>, calculate the weighted average of each order's implied price (buy_amount / sell_amount) using sell_amount as the weight.Noneif there are fewer than two orders or if total sell volume is zero.Noneis returned for zero or one order.src/pricing/mod.rsto expose thevolume_weightedmodule.Acceptance Criteria
Cargo testpasses for all existing and new tests.Closes #? (to be filled when opening PR).