feat: add decision-scoped buy denials to broker submission
This commit is contained in:
@@ -977,6 +977,7 @@ fn safe_ratio(numerator: f64, denominator: f64) -> f64 {
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct StrategyDecision {
|
||||
pub buy_denials: BTreeMap<String, String>,
|
||||
pub rebalance: bool,
|
||||
pub target_weights: BTreeMap<String, f64>,
|
||||
pub exit_symbols: BTreeSet<String>,
|
||||
@@ -988,6 +989,7 @@ pub struct StrategyDecision {
|
||||
|
||||
impl StrategyDecision {
|
||||
pub fn merge_from(&mut self, mut other: StrategyDecision) {
|
||||
self.buy_denials.append(&mut other.buy_denials);
|
||||
self.rebalance |= other.rebalance;
|
||||
self.target_weights.append(&mut other.target_weights);
|
||||
self.exit_symbols.append(&mut other.exit_symbols);
|
||||
@@ -998,7 +1000,8 @@ impl StrategyDecision {
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
!self.rebalance
|
||||
self.buy_denials.is_empty()
|
||||
&& !self.rebalance
|
||||
&& self.target_weights.is_empty()
|
||||
&& self.exit_symbols.is_empty()
|
||||
&& self.order_intents.is_empty()
|
||||
@@ -1569,6 +1572,7 @@ impl Strategy for CnSmallCapRotationStrategy {
|
||||
if self.config.in_skip_window(ctx.decision_date) {
|
||||
self.last_gross_exposure = Some(0.0);
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: true,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: ctx.portfolio.positions().keys().cloned().collect(),
|
||||
@@ -1590,6 +1594,7 @@ impl Strategy for CnSmallCapRotationStrategy {
|
||||
if message.contains("signal series insufficient") =>
|
||||
{
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -1765,6 +1770,7 @@ impl Strategy for CnSmallCapRotationStrategy {
|
||||
self.last_gross_exposure = Some(gross_exposure);
|
||||
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance,
|
||||
target_weights,
|
||||
exit_symbols,
|
||||
@@ -2773,6 +2779,7 @@ impl Strategy for OmniMicroCapStrategy {
|
||||
let lagged_execution = ctx.is_lagged_execution();
|
||||
if self.config.in_skip_window(signal_date) {
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: ctx.portfolio.positions().keys().cloned().collect(),
|
||||
@@ -2803,6 +2810,7 @@ impl Strategy for OmniMicroCapStrategy {
|
||||
if message.contains("insufficient benchmark") =>
|
||||
{
|
||||
return Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols: BTreeSet::new(),
|
||||
@@ -3013,6 +3021,7 @@ impl Strategy for OmniMicroCapStrategy {
|
||||
];
|
||||
|
||||
Ok(StrategyDecision {
|
||||
buy_denials: Default::default(),
|
||||
rebalance: false,
|
||||
target_weights: BTreeMap::new(),
|
||||
exit_symbols,
|
||||
|
||||
Reference in New Issue
Block a user