pub enum Action {
Buy(u8),
None,
Sell(u8),
}
Expand description
Action is basic type of Indicator’s signals
It may be positive (means Buy some amount). It may be negative (means Sell some amount). Or there may be no signal at all.
You can convert Action
to analog i8
value using analog()
method, where:
1
means buy;-1
means sell;0
means no signal.
You can convert Action
to digital Option<f64>
value using ratio()
method with internal value in range [-1.0
; 1.0
], where:
- negative value means sell some portion;
- positive value means buy some potion;
- zero value means there is no distinct decision;
None
means no signal.
Variants§
Implementations§
source§impl Action
impl Action
sourcepub fn from_analog(value: i8) -> Self
pub fn from_analog(value: i8) -> Self
Create instance from analog signal (which can be only -1
, 0
or 1
)
Any positive number converts to BUY_ALL
Any negative number converts to SELL_ALL
Zero converts to None
sourcepub fn analog(self) -> i8
pub fn analog(self) -> i8
Returns a sign (1
or -1
) of internal value if value exists and not zero.
Otherwise returns 0
.
sourcepub fn sign(self) -> Option<i8>
pub fn sign(self) -> Option<i8>
Returns a sign of internal value if value exists
Otherwise returns None
Trait Implementations§
source§impl<'de> Deserialize<'de> for Action
impl<'de> Deserialize<'de> for Action
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Action
impl Ord for Action
source§impl PartialEq for Action
impl PartialEq for Action
source§impl PartialOrd for Action
impl PartialOrd for Action
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Action
impl Eq for Action
Auto Trait Implementations§
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnwindSafe for Action
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