Skip to main content

AgentState

Struct AgentState 

Source
pub struct AgentState {
Show 31 fields pub agent_id: String, pub last_tick: Option<DateTime<Utc>>, pub trades_today: u32, pub trades_day: Option<NaiveDate>, pub rolls_today: u32, pub open_positions: HashMap<String, TrackedPosition>, pub last_actions: Vec<AgentAction>, pub pending_order_ids: Vec<String>, pub pending_orders: Vec<PendingOrder>, pub tick_count: u64, pub last_llm_review_tick: Option<u64>, pub llm_review_count: u64, pub last_llm_summary: Option<Value>, pub last_session: Option<String>, pub regular_tick_count: u64, pub last_overnight_digest_at: Option<DateTime<Utc>>, pub open_playbook: Option<Value>, pub last_market_open: Option<bool>, pub last_auth_reminder_level: Option<String>, pub last_auth_reminder_at: Option<DateTime<Utc>>, pub last_telegram_llm_at: Option<DateTime<Utc>>, pub last_telegram_llm_digest_key: Option<String>, pub sim: Option<SimLedger>, pub redeploy_signal: Option<RedeploySignal>, pub recent_stop_loss_exits: Vec<StopLossExitRecord>, pub last_entry_attempts: HashMap<String, DateTime<Utc>>, pub entry_proceed_cache: Option<EntryProceedCache>, pub last_regime: Option<Value>, pub sleeve_peak_equity_usd: f64, pub cumulative_realized_pnl_usd: f64, pub trading_halted_reason: Option<String>,
}

Fields§

§agent_id: String§last_tick: Option<DateTime<Utc>>§trades_today: u32§trades_day: Option<NaiveDate>§rolls_today: u32

Successful defensive rolls today (reset with trades_day).

§open_positions: HashMap<String, TrackedPosition>§last_actions: Vec<AgentAction>§pending_order_ids: Vec<String>§pending_orders: Vec<PendingOrder>§tick_count: u64§last_llm_review_tick: Option<u64>§llm_review_count: u64§last_llm_summary: Option<Value>§last_session: Option<String>§regular_tick_count: u64§last_overnight_digest_at: Option<DateTime<Utc>>§open_playbook: Option<Value>§last_market_open: Option<bool>

Last EQO regular-session open flag from agent tick (Schwab hours).

§last_auth_reminder_level: Option<String>§last_auth_reminder_at: Option<DateTime<Utc>>§last_telegram_llm_at: Option<DateTime<Utc>>

Last LLM review pushed to Telegram (for digest dedup).

§last_telegram_llm_digest_key: Option<String>§sim: Option<SimLedger>

Paper-trading ledger when running with –simulate (separate state file).

§redeploy_signal: Option<RedeploySignal>

Set after a thesis-driven exit — optional redeploy cooldown on that underlying.

§recent_stop_loss_exits: Vec<StopLossExitRecord>

Recent stop-loss exits for re-entry cooldown.

§last_entry_attempts: HashMap<String, DateTime<Utc>>

Last live entry attempt per candidate position_id (limits retry spam).

§entry_proceed_cache: Option<EntryProceedCache>

Cached LLM proceed for current candidate fingerprints.

§last_regime: Option<Value>

Last options regime snapshot (strategy selection).

§sleeve_peak_equity_usd: f64

High-water mark for options sleeve equity (drawdown halt).

§cumulative_realized_pnl_usd: f64

Cumulative realized PnL for live (non-sim) closes. Sim uses sim.realized_pnl_usd.

§trading_halted_reason: Option<String>

When set, new entries are paused (exits continue). Cleared when condition recovers.

Implementations§

Source§

impl AgentState

Source

pub fn reset_daily_if_needed(&mut self, today: NaiveDate)

Source

pub fn record_action(&mut self, action: &str, detail: Value)

Source

pub fn count_open_for_strategy( &self, account_hash: &str, strategy: StrategyKind, ) -> u32

Source

pub fn count_open_for_underlying( &self, account_hash: &str, underlying: &str, ) -> u32

Source

pub fn count_open_in_symbol_set( &self, account_hash: &str, symbols: &[String], ) -> u32

Open positions whose underlying is in symbols (case-insensitive).

Source

pub fn pending_entry_count_in_symbol_set( &self, account_hash: &str, symbols: &[String], ) -> u32

Source

pub fn pending_entry_count_for_underlying( &self, account_hash: &str, underlying: &str, ) -> u32

Source

pub fn pending_entry_count(&self) -> u32

Source

pub fn pending_count(&self) -> usize

Source

pub fn trades_capacity_used(&self) -> u32

Source

pub fn open_risk_usd(&self) -> f64

Source

pub fn pending_entry_risk_usd(&self) -> f64

Source

pub fn reserved_risk_usd(&self) -> f64

Source

pub fn has_pending_position(&self, position_id: &str) -> bool

Source

pub fn add_pending_order(&mut self, pending: PendingOrder)

Source

pub fn remove_pending_order(&mut self, order_id: &str) -> Option<PendingOrder>

Source

pub fn clear_legacy_pending_ids(&mut self)

Source

pub fn total_contracts(&self) -> u32

Trait Implementations§

Source§

impl Clone for AgentState

Source§

fn clone(&self) -> AgentState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AgentState

Source§

fn default() -> AgentState

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AgentState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AgentState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more