Refactored types
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
use pulse_wire::terminal::{
|
||||
ActivePosition, Alert, AlertLevel, EventLog, InspectItem, InspectTarget, LogKind,
|
||||
MarketOverview, Signal, SignalKind, Status, WatchListItem,
|
||||
Alert, AlertLevel, InspectItem, InspectTarget, MarketItem, MarketOverview, Status,
|
||||
};
|
||||
|
||||
use pulse_wire::general::{Direction, EventLog, LogKind, Position, Signal};
|
||||
|
||||
pub trait Formatted {
|
||||
fn get_formatted(&self) -> Vec<String>;
|
||||
}
|
||||
@@ -64,19 +65,18 @@ impl Formatted for EventLog {
|
||||
impl Formatted for Signal {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
if matches!(self.kind, SignalKind::Buy) {
|
||||
if matches!(self.kind, Direction::Buy) {
|
||||
format!("\x1b[32m{}\x1b[0m", self.kind)
|
||||
} else {
|
||||
format!("\x1b[31m{}\x1b[0m", self.kind)
|
||||
},
|
||||
format!("\x1b[35m{}\x1b[0m", self.symbol),
|
||||
format!("\x1b[34m{}\x1b[0m", self.param),
|
||||
format_f64(self.price),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl Formatted for WatchListItem {
|
||||
impl Formatted for MarketItem {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
format!("\x1b[35m{}\x1b[0m", self.symbol),
|
||||
@@ -95,7 +95,7 @@ impl Formatted for WatchListItem {
|
||||
}
|
||||
}
|
||||
|
||||
impl Formatted for ActivePosition {
|
||||
impl Formatted for Position {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
format!("\x1b[35m{}\x1b[0m", self.symbol),
|
||||
|
||||
+13
-8
@@ -21,8 +21,9 @@ use pulse_ui::{
|
||||
|
||||
use crate::formatting::{Formatted, apply_padding};
|
||||
|
||||
use pulse_wire::terminal::{
|
||||
ActivePosition, EventLog, InspectTarget, MarketOverview, Signal, Status, WatchListItem,
|
||||
use pulse_wire::{
|
||||
general::{EventLog, Position, Signal},
|
||||
terminal::{InspectTarget, MarketItem, MarketOverview, Status},
|
||||
};
|
||||
|
||||
pub struct PulseTradeApp {
|
||||
@@ -34,8 +35,8 @@ pub struct PulseTradeApp {
|
||||
market_overview: State<Option<MarketOverview>>,
|
||||
status: State<Option<Status>>,
|
||||
|
||||
watch_list: State<Vec<WatchListItem>>,
|
||||
active_positions: State<Vec<ActivePosition>>,
|
||||
watch_list: State<Vec<MarketItem>>,
|
||||
active_positions: State<Vec<Position>>,
|
||||
logs: State<Vec<EventLog>>,
|
||||
signals: State<Vec<Signal>>,
|
||||
inspect: State<InspectTarget>,
|
||||
@@ -130,15 +131,19 @@ impl App for PulseTradeApp {
|
||||
(
|
||||
LayoutItem::Widget(Size::Flex(1)),
|
||||
Box::new(
|
||||
advanced_draw(&self.scroll, 1, "ACTIVE POSITIONS", &self.active_positions)
|
||||
.await,
|
||||
advanced_draw(&self.scroll, 1, "POSITIONS", &self.active_positions).await,
|
||||
),
|
||||
),
|
||||
(
|
||||
LayoutItem::Widget(Size::Flex(1)),
|
||||
Box::new(
|
||||
advanced_option_draw(&self.scroll, 2, "MARKET OVERVIEW", &self.market_overview)
|
||||
.await,
|
||||
advanced_option_draw(
|
||||
&self.scroll,
|
||||
2,
|
||||
"MARKET OVERVIEW",
|
||||
&self.market_overview,
|
||||
)
|
||||
.await,
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user