Formatting
This commit is contained in:
@@ -53,8 +53,8 @@ impl Formatted for SignalStatus {
|
||||
} else {
|
||||
format!("\x1b[31mSELL\x1b[0m")
|
||||
},
|
||||
format!("\x1b[35m{}\x1b[0m", signal.symbol),
|
||||
signal.price.to_string(),
|
||||
format_symbol(&signal.symbol),
|
||||
format_usd(signal.price.as_f64()),
|
||||
format!("\x1b[33mAPR {}\x1b[0m", signal.confidence),
|
||||
]
|
||||
}
|
||||
@@ -67,8 +67,8 @@ impl Formatted for SignalStatus {
|
||||
} else {
|
||||
format!("\x1b[31mSELL\x1b[0m")
|
||||
},
|
||||
format!("\x1b[35m{}\x1b[0m", signal.symbol),
|
||||
signal.price.to_string(),
|
||||
format_symbol(&signal.symbol),
|
||||
format_usd(signal.price.as_f64()),
|
||||
format!("\x1b[33mAPR {}\x1b[0m", signal.confidence),
|
||||
]
|
||||
}
|
||||
@@ -79,9 +79,9 @@ impl Formatted for SignalStatus {
|
||||
impl Formatted for MarketItem {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
self.symbol.to_string(),
|
||||
self.price.to_string(),
|
||||
self.volume_24h.to_string(),
|
||||
format_symbol(&self.symbol),
|
||||
format_usd(self.price.as_f64()),
|
||||
format_usd(self.volume_24h.as_f64()),
|
||||
format!(
|
||||
"{} {}%",
|
||||
if self.trend.is_sign_positive() {
|
||||
@@ -98,7 +98,7 @@ impl Formatted for MarketItem {
|
||||
impl Formatted for Position {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
self.symbol.to_string(),
|
||||
format_symbol(&self.symbol),
|
||||
format_f64(self.size.as_f64()),
|
||||
self.entry_price.to_string(),
|
||||
format!(
|
||||
@@ -232,6 +232,18 @@ pub fn apply_padding(mut items: Vec<String>) -> Vec<String> {
|
||||
items
|
||||
}
|
||||
|
||||
pub fn format_symbol(value: &str) -> String {
|
||||
format!("\x1b[35m{value}\x1b[0m")
|
||||
}
|
||||
|
||||
pub fn format_usd(value: f64) -> String {
|
||||
if value.is_sign_positive() {
|
||||
format!("\x1b[32m${}\x1b[0m", format_f64(value))
|
||||
} else {
|
||||
format!("\x1b[31m${}\x1b[0m", format_f64(value))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_f64(value: f64) -> String {
|
||||
let abs = value.abs();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user