pub struct TurnoverOptimizer;Expand description
Finds the minimal set of trades that moves a portfolio from current weights
to target weights while keeping total execution cost low.
§Algorithm
- For each symbol in the union of current and target weights, compute the
weight delta
Δw = target - current. - If
|Δw| < tolerance, skip (already within band). - Otherwise add a
Tradewith the estimated cost for a unit-notional order sized proportionally to|Δw|. - Trades are sorted by
|Δw|descending (largest rebalance first).
Implementations§
Source§impl TurnoverOptimizer
impl TurnoverOptimizer
Sourcepub fn optimize(
current: &HashMap<String, f64>,
target: &HashMap<String, f64>,
cost_params: &CostParams,
tolerance: f64,
) -> Vec<Trade>
pub fn optimize( current: &HashMap<String, f64>, target: &HashMap<String, f64>, cost_params: &CostParams, tolerance: f64, ) -> Vec<Trade>
Generate the minimal set of trades to rebalance from current to target.
tolerance is the minimum absolute weight change that warrants a trade
(e.g. 0.005 = 50 bps). Smaller changes are ignored to avoid excessive
round-trip cost.
cost_params are used to estimate the cost of each trade assuming a
unit notional of $1, with shares = |Δw| / price where price is set
to 1.0 for weight-space estimation.
Auto Trait Implementations§
impl Freeze for TurnoverOptimizer
impl RefUnwindSafe for TurnoverOptimizer
impl Send for TurnoverOptimizer
impl Sync for TurnoverOptimizer
impl Unpin for TurnoverOptimizer
impl UnsafeUnpin for TurnoverOptimizer
impl UnwindSafe for TurnoverOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more