pub struct MetaPortfolio<Repository, Allocator, RiskManager, Statistic> where
    Repository: PositionHandler + BalanceHandler + StatisticHandler<Statistic>,
    Allocator: OrderAllocator,
    RiskManager: OrderEvaluator,
    Statistic: Initialiser + PositionSummariser
{ /* private fields */ }
Expand description

Portfolio with state persisted in a repository. MarketUpdater, OrderGenerator, FillUpdater and PositionHandler.

Implementations

Constructs a new MetaPortfolio using the provided PortfolioLego components, and persists the initial MetaPortfolio state in the Repository.

Persist initial MetaPortfolio state in the repository. This includes initialised Statistics every market provided, as well as starting AvailableCash & TotalEquity.

Returns a MetaPortfolioBuilder instance.

Trait Implementations

Formats the value using the given formatter. Read more

Updates the Portfolio state using the input FillEvent. The FillEvent triggers a Position entry or exit, and the Portfolio updates key fields such as current_cash and current_value accordingly. Read more

Determines if the Portfolio has an open Position relating to the input MarketEvent. If so it updates it using the market data, and returns a PositionUpdate detailing the changes. Read more

May generate an OrderEvent after analysing an input advisory SignalEvent.

Generates an exit OrderEvent if there is an open [Position] associated with the input SignalForceExit’s [PositionId]. Read more

Upsert the open Position using it’s PositionId.

Get an open Position using the PositionId provided.

Get all open Positions associated with a Portfolio.

Remove the Position at the PositionId.

Append an exited Position to the Portfolio’s exited position list.

Get every exited Position associated with the engine_id.

Upsert the market statistics at the MarketId provided.

Get the market statistics using the MarketId provided.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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