added name into Strategy trait
This commit is contained in:
parent
f6702f22e6
commit
f707f62ce3
@ -8,6 +8,7 @@ use crate::managers::PositionManager;
|
|||||||
use crate::models::{Position, PositionProfitState};
|
use crate::models::{Position, PositionProfitState};
|
||||||
|
|
||||||
pub trait PositionStrategy: DynClone {
|
pub trait PositionStrategy: DynClone {
|
||||||
|
fn name(&self) -> String;
|
||||||
fn on_new_tick(
|
fn on_new_tick(
|
||||||
&self,
|
&self,
|
||||||
position: &Position,
|
position: &Position,
|
||||||
@ -17,7 +18,7 @@ pub trait PositionStrategy: DynClone {
|
|||||||
|
|
||||||
impl Debug for dyn PositionStrategy {
|
impl Debug for dyn PositionStrategy {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
||||||
write!(f, "PositionStrategy")
|
write!(f, "{}", self.name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,10 @@ impl TrailingStop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PositionStrategy for TrailingStop {
|
impl PositionStrategy for TrailingStop {
|
||||||
|
fn name(&self) -> String {
|
||||||
|
"Trailing stop".into()
|
||||||
|
}
|
||||||
|
|
||||||
fn on_new_tick(
|
fn on_new_tick(
|
||||||
&self,
|
&self,
|
||||||
position: &Position,
|
position: &Position,
|
||||||
|
Loading…
Reference in New Issue
Block a user