feat: add decision-scoped buy denials to broker submission
This commit is contained in:
@@ -90,6 +90,7 @@ impl Strategy for BuyAndHoldStrategy {
|
||||
ctx: &StrategyContext<'_>,
|
||||
) -> Result<StrategyDecision, fidc_core::BacktestError> {
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
|
||||
@@ -37,6 +37,7 @@ impl Strategy for DecisionQuoteReader {
|
||||
self.day_count += 1;
|
||||
if self.day_count == 1 {
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Value {
|
||||
symbol: "000001.SZ".to_string(),
|
||||
value: 5_000.0,
|
||||
@@ -626,6 +627,7 @@ impl Strategy for MultiTimeDecisionQuoteReader {
|
||||
self.day_count += 1;
|
||||
if self.day_count == 1 {
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Value {
|
||||
symbol: "000001.SZ".to_string(),
|
||||
value: 5_000.0,
|
||||
|
||||
@@ -24,6 +24,7 @@ impl Strategy for BuyThenHoldStrategy {
|
||||
) -> Result<StrategyDecision, fidc_core::BacktestError> {
|
||||
if ctx.decision_date == d(2025, 1, 2) && ctx.portfolio.position("000001.SZ").is_none() {
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
|
||||
@@ -295,6 +295,7 @@ impl Strategy for HookProbeStrategy {
|
||||
.borrow_mut()
|
||||
.push(format!("on_day:{}", ctx.execution_date));
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -334,6 +335,7 @@ impl Strategy for AuctionOrderStrategy {
|
||||
_ctx: &StrategyContext<'_>,
|
||||
) -> Result<StrategyDecision, fidc_core::BacktestError> {
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -377,6 +379,7 @@ impl Strategy for FuturesOrderStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -413,6 +416,7 @@ impl Strategy for FuturesLimitOrderStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Futures {
|
||||
intent: FuturesOrderIntent::limit_open(
|
||||
"IF2501",
|
||||
@@ -444,6 +448,7 @@ impl Strategy for FuturesInvalidTickLimitStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Futures {
|
||||
intent: FuturesOrderIntent::limit_open(
|
||||
"IF2501",
|
||||
@@ -475,6 +480,7 @@ impl Strategy for FuturesClosedPhaseOrderStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Futures {
|
||||
intent: FuturesOrderIntent::open(
|
||||
"IF2501",
|
||||
@@ -506,6 +512,7 @@ impl Strategy for FuturesAboveUpperLimitStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Futures {
|
||||
intent: FuturesOrderIntent::limit_open(
|
||||
"IF2501",
|
||||
@@ -537,6 +544,7 @@ impl Strategy for FuturesDepthLimitOrderStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Futures {
|
||||
intent: FuturesOrderIntent::limit_open(
|
||||
"IF2501",
|
||||
@@ -720,6 +728,7 @@ impl Strategy for LimitCarryStrategy {
|
||||
}
|
||||
self.issued = true;
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -803,6 +812,7 @@ impl Strategy for UniverseDirectiveStrategy {
|
||||
_ => Vec::new(),
|
||||
};
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -844,6 +854,7 @@ impl Strategy for MinuteProbeStrategy {
|
||||
_ctx: &StrategyContext<'_>,
|
||||
) -> Result<StrategyDecision, fidc_core::BacktestError> {
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -885,6 +896,7 @@ impl Strategy for MinuteProbeStrategy {
|
||||
}
|
||||
self.ordered = true;
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -987,6 +999,7 @@ impl Strategy for OrderInspectionStrategy {
|
||||
_ctx: &StrategyContext<'_>,
|
||||
) -> Result<StrategyDecision, fidc_core::BacktestError> {
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1030,6 +1043,7 @@ impl Strategy for AccountFlowStrategy {
|
||||
return Ok(StrategyDecision::default());
|
||||
}
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4134,6 +4148,7 @@ impl Strategy for BuyMissingRowThenHoldStrategy {
|
||||
) -> Result<StrategyDecision, fidc_core::BacktestError> {
|
||||
if ctx.execution_date == d(2025, 5, 26) {
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
|
||||
@@ -209,6 +209,7 @@ fn execute_single_value_order(
|
||||
&mut portfolio,
|
||||
data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -399,6 +400,7 @@ fn broker_executes_explicit_order_value_buy() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -557,6 +559,7 @@ fn broker_delayed_limit_open_sell_uses_minute_price() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -687,6 +690,7 @@ fn broker_executes_order_shares_and_order_lots() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -806,6 +810,7 @@ fn broker_executes_target_shares_like_order_to() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -981,6 +986,7 @@ fn broker_executes_target_portfolio_smart_with_custom_prices() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1139,6 +1145,7 @@ fn broker_executes_target_portfolio_smart_with_algo_order_style() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1254,6 +1261,7 @@ fn broker_executes_order_percent_and_target_percent() {
|
||||
&mut percent_portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1278,6 +1286,7 @@ fn broker_executes_order_percent_and_target_percent() {
|
||||
&mut target_percent_portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1380,6 +1389,7 @@ fn broker_uses_day_open_price_for_open_auction_matching() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1487,6 +1497,7 @@ fn broker_open_auction_uses_auction_volume_without_quote_liquidity() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1590,6 +1601,7 @@ fn broker_cancels_buy_when_open_hits_upper_limit() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1707,6 +1719,7 @@ fn broker_applies_price_ratio_slippage_on_snapshot_fills() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1812,6 +1825,7 @@ fn broker_applies_dynamic_slippage_on_snapshot_fills() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1933,6 +1947,7 @@ fn broker_applies_tick_size_slippage_on_intraday_last_fills() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2039,6 +2054,7 @@ fn broker_rejects_intraday_last_order_without_execution_quotes() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2163,6 +2179,7 @@ fn broker_executes_intraday_last_on_start_quote_with_trade_delta() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2282,6 +2299,7 @@ fn broker_cancels_market_order_remainder_when_intraday_quote_liquidity_exhausted
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2398,6 +2416,7 @@ fn broker_cancels_market_buy_when_minute_has_no_volume() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2534,6 +2553,7 @@ fn broker_splits_intraday_quote_fills_and_tracks_commission_by_order() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2707,6 +2727,7 @@ fn broker_aggregates_intraday_quote_fills_into_vwap_leg() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -2888,6 +2909,7 @@ fn broker_executes_algo_vwap_value_with_time_window() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -3036,6 +3058,7 @@ fn broker_executes_algo_twap_percent_across_window_quotes() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -3172,6 +3195,7 @@ fn broker_uses_best_own_price_for_intraday_matching() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -3290,6 +3314,7 @@ fn broker_uses_best_counterparty_price_for_intraday_matching() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -3461,6 +3486,7 @@ fn rebalance_optimizer_skips_unfunded_buy_when_existing_position_cannot_sell() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: true,
|
||||
target_weights: BTreeMap::from([("000002.SZ".to_string(), 1.0)]),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -3657,6 +3683,7 @@ fn rebalance_uses_day_open_for_open_auction_valuation() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: true,
|
||||
target_weights: BTreeMap::from([
|
||||
("000001.SZ".to_string(), 0.5),
|
||||
@@ -3841,6 +3868,7 @@ fn rebalance_optimizer_prioritizes_higher_target_weight_when_cash_is_tight() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: true,
|
||||
target_weights: BTreeMap::from([
|
||||
("000001.SZ".to_string(), 0.2),
|
||||
@@ -4025,6 +4053,7 @@ fn rebalance_optimizer_does_not_scale_targets_above_requested_weight() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: true,
|
||||
target_weights: BTreeMap::from([
|
||||
("000001.SZ".to_string(), 0.48),
|
||||
@@ -4139,6 +4168,7 @@ fn broker_uses_board_specific_min_quantity_and_step_size_for_buy_sizing() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4244,6 +4274,7 @@ fn broker_allows_bjse_quantities_above_minimum_without_round_lot_step() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4350,6 +4381,7 @@ fn broker_allows_full_odd_lot_sell_when_liquidating_position() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4483,6 +4515,7 @@ fn same_day_sell_then_rebuy_is_rejected_by_default() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4627,6 +4660,7 @@ fn same_day_sell_then_rebuy_can_be_allowed_by_policy() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4680,6 +4714,7 @@ fn broker_configured_policy_can_allow_upper_limit_buy() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4726,6 +4761,7 @@ fn broker_configured_policy_can_allow_lower_limit_sell() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4901,6 +4937,7 @@ fn broker_expires_day_limit_buy_at_market_close() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4941,6 +4978,7 @@ fn broker_expires_day_limit_buy_at_market_close() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -4976,6 +5014,7 @@ fn broker_ioc_limit_order_fills_available_quantity_and_cancels_remainder() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5014,6 +5053,7 @@ fn broker_persists_daily_volume_consumption_across_execute_calls() {
|
||||
.with_liquidity_limit(false);
|
||||
let mut portfolio = PortfolioState::new(1_000_000.0);
|
||||
let decision = || StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Shares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
quantity: 100,
|
||||
@@ -5061,6 +5101,7 @@ fn broker_persists_quote_depth_until_fresh_level_data_arrives() {
|
||||
.with_liquidity_limit(true);
|
||||
let mut portfolio = PortfolioState::new(1_000_000.0);
|
||||
let decision = |quantity| StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Shares {
|
||||
symbol: symbol.to_string(),
|
||||
quantity,
|
||||
@@ -5078,6 +5119,7 @@ fn broker_persists_quote_depth_until_fresh_level_data_arrives() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::Shares {
|
||||
symbol: symbol.to_string(),
|
||||
@@ -5182,6 +5224,7 @@ fn broker_persists_quote_volume_participation_until_next_quote() {
|
||||
.with_liquidity_limit(false);
|
||||
let mut portfolio = PortfolioState::new(1_000_000.0);
|
||||
let decision = |quantity| StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::Shares {
|
||||
symbol: symbol.to_string(),
|
||||
quantity,
|
||||
@@ -5264,6 +5307,7 @@ fn broker_day_market_order_cancels_remainder_without_creating_invalid_open_order
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::Shares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5305,6 +5349,7 @@ fn broker_fok_order_is_atomic_when_liquidity_is_insufficient() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::Shares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5351,6 +5396,7 @@ fn broker_fok_order_fills_when_full_quantity_is_available() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::Shares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5388,6 +5434,7 @@ fn broker_gtc_limit_order_survives_close_and_fills_next_day() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5439,6 +5486,7 @@ fn broker_gtc_partial_fills_preserve_cumulative_order_and_commission_state() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5503,6 +5551,7 @@ fn broker_modifies_gtc_limit_order_without_changing_order_identity() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5524,6 +5573,7 @@ fn broker_modifies_gtc_limit_order_without_changing_order_identity() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::ModifyOrder {
|
||||
order_id,
|
||||
new_total_quantity: Some(400),
|
||||
@@ -5591,6 +5641,7 @@ fn broker_modifies_partially_filled_gtc_total_and_preserves_commission_state() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5614,6 +5665,7 @@ fn broker_modifies_partially_filled_gtc_total_and_preserves_commission_state() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::ModifyOrder {
|
||||
order_id,
|
||||
new_total_quantity: Some(200),
|
||||
@@ -5668,6 +5720,7 @@ fn broker_rejected_modify_has_zero_side_effects() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5691,6 +5744,7 @@ fn broker_rejected_modify_has_zero_side_effects() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::ModifyOrder {
|
||||
order_id,
|
||||
new_total_quantity: Some(100),
|
||||
@@ -5728,6 +5782,7 @@ fn broker_accepted_modify_resets_queue_priority_but_reduction_preserves_it() {
|
||||
);
|
||||
let mut portfolio = PortfolioState::new(1_000_000.0);
|
||||
let create = |reason: &str| StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::LimitShares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5758,6 +5813,7 @@ fn broker_accepted_modify_resets_queue_priority_but_reduction_preserves_it() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::ModifyOrder {
|
||||
order_id: initial_ids[0],
|
||||
new_total_quantity: Some(200),
|
||||
@@ -5787,6 +5843,7 @@ fn broker_accepted_modify_resets_queue_priority_but_reduction_preserves_it() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![OrderIntent::ModifyOrder {
|
||||
order_id: initial_ids[0],
|
||||
new_total_quantity: None,
|
||||
@@ -5828,6 +5885,7 @@ fn broker_rejects_gtc_for_market_order() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
order_intents: vec![
|
||||
OrderIntent::Shares {
|
||||
symbol: "000002.SZ".to_string(),
|
||||
@@ -5867,6 +5925,7 @@ fn broker_uses_limit_price_slippage_for_limit_orders() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -5905,6 +5964,7 @@ fn broker_rejects_limit_buy_when_final_execution_price_reaches_upper_limit() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -5949,6 +6009,7 @@ fn broker_executes_limit_value_and_limit_percent_intents() {
|
||||
&mut value_portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -5974,6 +6035,7 @@ fn broker_executes_limit_value_and_limit_percent_intents() {
|
||||
&mut percent_portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -6010,6 +6072,7 @@ fn broker_cancels_open_order_by_order_id() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -6033,6 +6096,7 @@ fn broker_cancels_open_order_by_order_id() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -6080,6 +6144,7 @@ fn broker_emits_cancellation_reject_for_unknown_order() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -6188,6 +6253,7 @@ fn broker_reserves_sellable_quantity_for_open_limit_sells() {
|
||||
&mut portfolio,
|
||||
&data,
|
||||
&StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
|
||||
Reference in New Issue
Block a user