pub enum Trade {
New(NewTrade),
Opened(OpenedTrade),
Closed(ClosedTrade),
}Expand description
Group of orders and operations with one position.
§ru
Отдельные ордера и операции по ним объединяются в трейд. Трейд считается открытым, когда совершается первая сделка по бумаге. Этот трейд будет закрыт, когда на счету будет ноль бумаг. Трейд суммирует все операции между открытием и закрытием позиции.
Статус трейда реализован идиоматичным для Rust путем - через отдельные типы. Этим не очень удобно пользоваться, зато компилятор следит за корректностью работы с трейдами. Например нельзя добавить стоп или тейк к закрытому трейду. Получить результат трейда можно только когда он закрыт и тп.
В реализации трейдов возможны изменения, поэтому подробной документации по методам пока нет.
Variants§
Implementations§
Source§impl Trade
impl Trade
pub fn new(ts_nanos: i64, strategy: &str, kind: TradeKind, iid: Iid) -> NewTrade
pub fn as_new(self) -> Option<NewTrade>
pub fn as_opened(self) -> Option<OpenedTrade>
pub fn as_closed(self) -> Option<ClosedTrade>
pub fn is_new(&self) -> bool
pub fn is_opened(&self) -> bool
pub fn is_closed(&self) -> bool
Trait Implementations§
impl<'__de> Decode<'__de> for Tradewhere
'__de:,
impl Encode for Trade
impl StructuralPartialEq for Trade
Auto Trait Implementations§
impl Freeze for Trade
impl RefUnwindSafe for Trade
impl Send for Trade
impl Sync for Trade
impl Unpin for Trade
impl UnwindSafe for Trade
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.