Skip to main content

BarBroker

Struct BarBroker 

Source
pub struct BarBroker<F: FillModel> { /* private fields */ }

Implementations§

Source§

impl<F: FillModel> BarBroker<F>

Source

pub fn new(fills: F, initial_capital: f64) -> Self

Source

pub fn with_commission(self, commission: Commission) -> Self

Source

pub fn with_sizing(self, sizing: Sizing) -> Self

Source

pub fn with_mintick(self, mintick: f64) -> Self

Source

pub fn with_pyramiding(self, pyramiding: usize) -> Self

Trait Implementations§

Source§

impl<F: FillModel> Broker for BarBroker<F>

Source§

fn submit(&mut self, order: Order)

Submit an order, replacing any pending one with the same id.
Source§

fn set_risk(&mut self, rule: RiskRule)

Apply a risk-management rule (from a strategy.risk.* call).
Source§

fn submit_exit(&mut self, exit: Exit)

Submit a stop-loss / take-profit bracket, replacing any with the same id.
Source§

fn cancel(&mut self, id: &str)

Cancel a pending order by id; a filled order is unaffected.
Source§

fn cancel_all(&mut self)

Cancel every pending order.
Source§

fn advance(&mut self, bar: &Bar)

Fill whatever bar allows, updating the position and trade log.
Source§

fn position(&self) -> Position

The current net position.
Source§

fn initial_capital(&self) -> f64

The capital the account started with, before any trade or commission.
Source§

fn equity(&self, price: f64) -> f64

Account value: capital plus realised and unrealised profit, marked at price (typically the latest close).
Source§

fn open_trades(&self) -> Vec<&Trade>

Trades still open, oldest first.
Source§

fn closed_trades(&self) -> &[Trade]

Trades already closed, in the order they closed.
Source§

fn halted_bar(&self) -> Option<u64>

The bar the run halted on if a rest-of-run risk rule fired (max_drawdown, max_cons_loss_days), else None.

Auto Trait Implementations§

§

impl<F> Freeze for BarBroker<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for BarBroker<F>
where F: RefUnwindSafe,

§

impl<F> Send for BarBroker<F>
where F: Send,

§

impl<F> Sync for BarBroker<F>
where F: Sync,

§

impl<F> Unpin for BarBroker<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for BarBroker<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for BarBroker<F>
where F: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.