Added system

This commit is contained in:
2026-07-15 08:19:21 -04:00
parent 5a138aecde
commit 4f9a498f41
3 changed files with 40 additions and 12 deletions
+13 -1
View File
@@ -1,4 +1,4 @@
use crate::types::{Account, ActivePosition, WatchListItem};
use crate::types::{Account, ActivePosition, System, WatchListItem};
pub trait Formatted {
fn get_formatted(&self) -> Vec<String>;
@@ -55,6 +55,18 @@ impl Formatted for Account {
}
}
impl Formatted for System {
fn get_formatted(&self) -> Vec<String> {
vec![
Property("Feed", format!("{:?}", self.feed)),
Property("Exchange", self.exchange.clone()),
Property("DEX", self.dex.clone()),
Property("Latency", format!("{} ms", self.latency)),
]
.get_formatted()
}
}
impl Formatted for Property {
fn get_formatted(&self) -> Vec<String> {
vec![format!("\x1b[91m{}\x1b[0m", self.0), self.1.clone()]
+12 -11
View File
@@ -18,7 +18,7 @@ use pulse_ui::{
use crate::{
formatting::{Formatted, apply_padding},
types::{Account, ActivePosition, WatchListItem},
types::{Account, ActivePosition, System, WatchListItem},
};
pub struct PulseTradeApp {
@@ -26,6 +26,7 @@ pub struct PulseTradeApp {
watch_list: State<Vec<WatchListItem>>,
active_positions: State<Vec<ActivePosition>>,
account: State<Account>,
system: State<System>,
}
impl App for PulseTradeApp {
@@ -178,16 +179,10 @@ impl App for PulseTradeApp {
),
(
LayoutItem::Widget(Size::Flex(1)),
Box::new(
vec![
" SYSTEM",
" Feed: Connected",
" Exchange: Binance",
" DEX: DEX SCREENER",
" Latency: 18 ms",
]
.join("\n"),
),
Box::new(format![
" SYSTEM\n{}",
apply_padding(self.system.lock().await.get_formatted()).join("\n")
]),
),
]),
);
@@ -209,6 +204,12 @@ async fn main() {
realized: 2_182.49,
margin: 0.0,
}),
system: ctx.use_state(System {
feed: types::Feed::Connected,
exchange: "Binance".to_string(),
dex: "DEX SCREENER".to_string(),
latency: 18,
}),
})
.await;
}
+15
View File
@@ -17,3 +17,18 @@ pub struct Account {
pub realized: f64,
pub margin: f64,
}
#[derive(Debug, Clone, Copy)]
pub enum Feed {
Connected,
Disconnected,
Connecting,
Failed,
}
pub struct System {
pub feed: Feed,
pub exchange: String,
pub dex: String,
pub latency: u16,
}