pub struct ExternalStrategy { /* private fields */ }Expand description
A strategy whose decisions are supplied externally (e.g. from Python).
Each tick it stores the latest Observation and drains any order requests
that were previously injected via set_pending_requests. This lets a
foreign caller:
- Call
engine.step()which internally callson_tick– the strategy captures the observation and pushes any pending requests. - Read
last_observation()to see what the agent observed. - Decide on orders, call
set_pending_requests(...). - Call
engine.step()again.
Implementations§
Source§impl ExternalStrategy
impl ExternalStrategy
pub fn new() -> Self
Sourcepub fn last_observation(&self) -> Option<&Observation>
pub fn last_observation(&self) -> Option<&Observation>
Snapshot of the most recent observation delivered to this strategy.
Sourcepub fn set_pending_requests(&mut self, requests: Vec<OrderRequest>)
pub fn set_pending_requests(&mut self, requests: Vec<OrderRequest>)
Queue order requests that will be submitted on the next on_tick.
Trait Implementations§
Source§impl Default for ExternalStrategy
impl Default for ExternalStrategy
Source§impl Strategy for ExternalStrategy
impl Strategy for ExternalStrategy
Source§fn on_tick(&mut self, obs: &Observation, requests: &mut Vec<OrderRequest>)
fn on_tick(&mut self, obs: &Observation, requests: &mut Vec<OrderRequest>)
Called each tick with the agent’s filtered observation.
Appends order requests (New, Cancel, CancelAll) to the provided buffer.
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Downcast helper — returns
self as &mut dyn Any.Auto Trait Implementations§
impl Freeze for ExternalStrategy
impl RefUnwindSafe for ExternalStrategy
impl Send for ExternalStrategy
impl Sync for ExternalStrategy
impl Unpin for ExternalStrategy
impl UnsafeUnpin for ExternalStrategy
impl UnwindSafe for ExternalStrategy
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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