Working inspector

This commit is contained in:
2026-07-15 22:10:26 +02:00
parent a4f8e07be6
commit 278a660d5a
3 changed files with 105 additions and 5 deletions
+59 -2
View File
@@ -1,12 +1,69 @@
use crate::types::{
ActivePosition, Alert, AlertLevel, EventLog, LogKind, MarketOverview, Signal, SignalKind,
Status, WatchListItem,
ActivePosition, Alert, AlertLevel, EventLog, InspectTarget, LogKind, MarketOverview, Signal,
SignalKind, Status, WatchListItem,
};
pub trait Formatted {
fn get_formatted(&self) -> Vec<String>;
}
impl Formatted for InspectTarget {
fn get_formatted(&self) -> Vec<String> {
match self {
Self::None => vec!["\x1b[2mnothing to inspect\x1b[0m".to_string()],
Self::Symbol {
symbol,
price,
trend,
market_trend,
volatility,
pressure,
alerts,
} => vec![
Property("Symbol", format!("\x1b[35m{}\x1b[0m", symbol)),
Property("Price", format!("\x1b[96m{}\x1b[0m", format_f64(*price))),
Property("Trend", format!("{}", format_f64(*trend))),
Property("Market", format!("{:?}", market_trend)),
Property("Volatility", format!("{:?}", volatility)),
Property("Pressure", format!("{:+.2}%", pressure * 100.0)),
Property("Alerts", format!("{}", alerts.len())),
]
.get_formatted(),
Self::Position {
symbol,
profit,
amount,
} => vec![
Property("Symbol", format!("\x1b[35m{}\x1b[0m", symbol)),
Property("Profit", format!("{:+.2}", profit)),
Property("Amount", format!("{}", amount)),
]
.get_formatted(),
Self::Signal {
kind,
symbol,
param,
price,
} => vec![
Property("Type", format!("{:?}", kind)),
Property("Symbol", format!("\x1b[35m{}\x1b[0m", symbol)),
Property("Parameter", format!("{:?}", param)),
Property("Price", format!("\x1b[96m{}\x1b[0m", format_f64(*price))),
]
.get_formatted(),
Self::Alert { level, message } => vec![
Property("Level", format!("{:?}", level)),
Property("Message", message.clone()),
]
.get_formatted(),
}
}
}
impl Formatted for Alert {
fn get_formatted(&self) -> Vec<String> {
vec![