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