From 5ec0415e520269af5d300148dd40f6b08154b46a Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 25 Jul 2026 18:29:10 +0200 Subject: [PATCH] Improved strategy formatting --- src/terminal/formatting.rs | 53 ++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/src/terminal/formatting.rs b/src/terminal/formatting.rs index 0978493..43a6ffc 100644 --- a/src/terminal/formatting.rs +++ b/src/terminal/formatting.rs @@ -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 { 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 { + 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 Formatted for Vec { impl Formatted for Strategy { fn get_formatted(&self) -> Vec { 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()