Trait barter::portfolio::repository::PositionHandler
source · [−]pub trait PositionHandler {
fn set_open_position(
&mut self,
position: Position
) -> Result<(), RepositoryError>;
fn get_open_position(
&mut self,
position_id: &PositionId
) -> Result<Option<Position>, RepositoryError>;
fn get_open_positions<'a, Markets: Iterator<Item = &'a Market>>(
&mut self,
engine_id: Uuid,
markets: Markets
) -> Result<Vec<Position>, RepositoryError>;
fn remove_position(
&mut self,
position_id: &PositionId
) -> Result<Option<Position>, RepositoryError>;
fn set_exited_position(
&mut self,
engine_id: Uuid,
position: Position
) -> Result<(), RepositoryError>;
fn get_exited_positions(
&mut self,
engine_id: Uuid
) -> Result<Vec<Position>, RepositoryError>;
}
Expand description
Handles the reading & writing of a Position
to/from the persistence layer.
Required methods
fn set_open_position(
&mut self,
position: Position
) -> Result<(), RepositoryError>
fn set_open_position(
&mut self,
position: Position
) -> Result<(), RepositoryError>
Upsert the open Position
using it’s PositionId
.
fn get_open_position(
&mut self,
position_id: &PositionId
) -> Result<Option<Position>, RepositoryError>
fn get_open_position(
&mut self,
position_id: &PositionId
) -> Result<Option<Position>, RepositoryError>
Get an open Position
using the PositionId
provided.
fn get_open_positions<'a, Markets: Iterator<Item = &'a Market>>(
&mut self,
engine_id: Uuid,
markets: Markets
) -> Result<Vec<Position>, RepositoryError>
fn get_open_positions<'a, Markets: Iterator<Item = &'a Market>>(
&mut self,
engine_id: Uuid,
markets: Markets
) -> Result<Vec<Position>, RepositoryError>
Get all open Position
s associated with a Portfolio.
fn remove_position(
&mut self,
position_id: &PositionId
) -> Result<Option<Position>, RepositoryError>
fn remove_position(
&mut self,
position_id: &PositionId
) -> Result<Option<Position>, RepositoryError>
Remove the Position
at the PositionId
.
fn set_exited_position(
&mut self,
engine_id: Uuid,
position: Position
) -> Result<(), RepositoryError>
fn set_exited_position(
&mut self,
engine_id: Uuid,
position: Position
) -> Result<(), RepositoryError>
Append an exited Position
to the Portfolio’s exited position list.
fn get_exited_positions(
&mut self,
engine_id: Uuid
) -> Result<Vec<Position>, RepositoryError>
fn get_exited_positions(
&mut self,
engine_id: Uuid
) -> Result<Vec<Position>, RepositoryError>
Get every exited Position
associated with the engine_id.