pub struct MarketState {
pub symbol: String,
pub order_book: Option<OrderBook>,
pub position: Option<Position>,
pub active_orders: Vec<Order>,
pub available_cash: Decimal,
pub timestamp: DateTime<Utc>,
pub last_price: Option<Decimal>,
pub currency: String,
}Expand description
Market state provided to the strategy for decision making.
Fields§
§symbol: StringThe instrument being traded.
order_book: Option<OrderBook>Current order book (if available).
position: Option<Position>Current position (if any).
active_orders: Vec<Order>Active orders.
available_cash: DecimalAvailable cash for trading.
timestamp: DateTime<Utc>Current timestamp.
last_price: Option<Decimal>Last price of the instrument.
currency: StringCurrency of the instrument.
Implementations§
Source§impl MarketState
impl MarketState
Sourcepub fn new(symbol: impl Into<String>, currency: impl Into<String>) -> Self
pub fn new(symbol: impl Into<String>, currency: impl Into<String>) -> Self
Creates a new market state.
Sourcepub fn with_order_book(self, order_book: OrderBook) -> Self
pub fn with_order_book(self, order_book: OrderBook) -> Self
Sets the order book.
Sourcepub fn with_position(self, position: Position) -> Self
pub fn with_position(self, position: Position) -> Self
Sets the position.
Sourcepub fn with_last_price(self, price: Decimal) -> Self
pub fn with_last_price(self, price: Decimal) -> Self
Sets the last price.
Sourcepub fn position_lots(&self) -> u32
pub fn position_lots(&self) -> u32
Returns the current position quantity in lots.
Trait Implementations§
Source§impl Clone for MarketState
impl Clone for MarketState
Auto Trait Implementations§
impl Forget for MarketState
impl Freeze for MarketState
impl Move for MarketState
impl RefUnwindSafe for MarketState
impl Send for MarketState
impl Sync for MarketState
impl Unpin for MarketState
impl UnsafeUnpin for MarketState
impl UnwindSafe for MarketState
Blanket Implementations§
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