Improved strategy formatting
This commit is contained in:
+42
-11
@@ -112,6 +112,8 @@ impl Formatted for Position {
|
||||
|
||||
struct Pair<'a>(&'a str, &'a str);
|
||||
|
||||
struct Triple<'a>(&'a str, &'a str, &'a str);
|
||||
|
||||
impl Formatted for MarketOverview {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
let mut o = vec![
|
||||
@@ -155,6 +157,12 @@ impl<'a> Formatted for Pair<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Formatted for Triple<'a> {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![self.0.to_string(), self.1.to_string(), self.2.to_string()]
|
||||
}
|
||||
}
|
||||
|
||||
fn visible_len(s: &str) -> usize {
|
||||
let mut len = 0;
|
||||
let mut chars = s.chars().peekable();
|
||||
@@ -222,17 +230,40 @@ impl<T: Formatted> Formatted for Vec<T> {
|
||||
impl Formatted for Strategy {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
Pair("", ""),
|
||||
Pair("\x1b[2mName\x1b[0m", "\x1b[2mRisk\x1b[0m"),
|
||||
Pair(&self.strategy.name.to_string(), &self.risk.name.to_string()),
|
||||
Pair("", ""),
|
||||
Pair("\x1b[2mMode\x1b[0m", "\x1b[2mState\x1b[0m"),
|
||||
Pair(&self.mode.to_string(), &self.state.to_string()),
|
||||
Pair("", ""),
|
||||
Pair("\x1b[2mCooldown\x1b[0m", "\x1b[2mTimeframes\x1b[0m"),
|
||||
Pair(
|
||||
&format!("{:?} ({:?} rec)", self.cooldown, self.risk.cooldown),
|
||||
&format!("{:?}", self.strategy.timeframes),
|
||||
Triple(
|
||||
"\x1b[2mName\x1b[0m",
|
||||
"\x1b[2mRisk\x1b[0m",
|
||||
"\x1b[2mStrat Ver\x1b[0m",
|
||||
),
|
||||
Triple(
|
||||
&format!("\x1b[97m{}\x1b[0m", self.strategy.name),
|
||||
&format!("\x1b[93m{}\x1b[0m", self.risk.name),
|
||||
&format!("\x1b[90m{}\x1b[0m", self.strategy.version),
|
||||
),
|
||||
Triple("", "", ""),
|
||||
Triple(
|
||||
"\x1b[2mMode\x1b[0m",
|
||||
"\x1b[2mState\x1b[0m",
|
||||
"\x1b[2mRisk Ver\x1b[0m",
|
||||
),
|
||||
Triple(
|
||||
&self.mode.to_string(),
|
||||
&self.state.to_string(),
|
||||
&format!("\x1b[90m{}\x1b[0m", self.risk.version),
|
||||
),
|
||||
Triple("", "", ""),
|
||||
Triple(
|
||||
"\x1b[2mCooldown\x1b[0m",
|
||||
"\x1b[2mTimeframes\x1b[0m",
|
||||
"\x1b[2mMax loss\x1b[0m",
|
||||
),
|
||||
Triple(
|
||||
&format!(
|
||||
"\x1b[96m{:?}\x1b[0m (\x1b[90m{:?} rec\x1b[0m)",
|
||||
self.cooldown, self.risk.cooldown
|
||||
),
|
||||
&format!("\x1b[96m{:?}\x1b[0m", self.strategy.timeframes),
|
||||
&format!("\x1b[93m{}%\x1b[0m", self.risk.max_loss),
|
||||
),
|
||||
]
|
||||
.get_formatted()
|
||||
|
||||
Reference in New Issue
Block a user