//! Deterministic stock-pool target planning shared by historical and online execution.
//! Account, quote and fill facts are supplied by the caller; this module has no I/O.
use chrono::NaiveDate;
use rust_decimal::{Decimal, RoundingStrategy};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::{BTreeMap, BTreeSet, HashMap};
pub const STOCK_POOL_SCHEMA_VERSION: u32 = 1;
pub const POOL_TRIGGER_FIRST_TICK: &str = "first_tick_after_open";
pub const POOL_TRIGGER_TIME_WINDOW: &str = "time_window";
pub const POOL_TRIGGER_CONDITION: &str = "condition";
pub const POOL_TRIGGER_SCHEDULED_BAR: &str = "scheduled_bar";
pub const POOL_PRICE_FIRST_TICK: &str = "first_tick";
pub const POOL_PRICE_OPENING_AUCTION: &str = "opening_auction";
pub const POOL_PRICE_FIXED_LIMIT: &str = "fixed_limit";
pub const POOL_PRICE_FORMULA_LIMIT: &str = "formula_limit";
pub const POOL_PRICE_CONDITION_THEN_LIMIT: &str = "condition_then_limit";
pub const POOL_PRICE_CONDITION_THEN_MARKET: &str = "condition_then_market";
pub const POOL_SELL_TARGET_DELTA: &str = "target_delta";
pub const POOL_SELL_CONDITION: &str = "condition";
pub const STOCK_POOL_CURRENT_SNAPSHOT_TOLERANCE_SECONDS: u64 = 120;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum OrderSide {
Buy,
Sell,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "snake_case")]
pub enum QuoteConditionScope {
#[default]
PerSymbol,
AllTargets,
AnyTarget,
}
pub fn stock_pool_target_holding_count(policy: &Value) -> Result