feat(stock-pool): unify target execution, durable intent state and ETF rules

This commit is contained in:
boris
2026-09-12 03:55:00 +08:00
parent 29eafc79e2
commit 6ffa0346aa
26 changed files with 7223 additions and 38 deletions
+11
View File
@@ -676,6 +676,7 @@ pub struct PortfolioState {
cash_receivables: Vec<CashReceivable>,
pending_cash_flows: Vec<PendingCashFlow>,
day_sold_symbols: BTreeSet<String>,
stock_pool_states: std::collections::BTreeMap<String,crate::stock_pool_state::StockPoolExecutionState>,
}
#[derive(Debug, Clone)]
@@ -712,6 +713,7 @@ impl PortfolioState {
cash_receivables: Vec::new(),
pending_cash_flows: Vec::new(),
day_sold_symbols: BTreeSet::new(),
stock_pool_states: std::collections::BTreeMap::new(),
}
}
@@ -721,6 +723,15 @@ impl PortfolioState {
self.initial_cash.to_f64()
}
pub(crate) fn stock_pool_execution_state(&self,pool_id:&str)->crate::stock_pool_state::StockPoolExecutionState{
self.stock_pool_states.get(pool_id).cloned().unwrap_or_default()
}
pub(crate) fn set_stock_pool_execution_state(&mut self,pool_id:&str,state:crate::stock_pool_state::StockPoolExecutionState)->Result<(),String>{
if pool_id.trim().is_empty(){return Err("stock_pool_state_identity_missing".into())}
state.validate()?;self.stock_pool_states.insert(pool_id.into(),state);Ok(())
}
pub fn initial_cash(&self) -> f64 {
self.initial_cash.to_f64()
}