Engine config status
This commit is contained in:
+22
-28
@@ -114,28 +114,8 @@ impl Formatted for Position {
|
||||
}
|
||||
}
|
||||
|
||||
struct Pair<'a>(&'a str, &'a str);
|
||||
|
||||
struct Triple<'a>(&'a str, &'a str, &'a str);
|
||||
|
||||
impl Formatted for Status {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
Pair("Feed", &format!("{:?}", self.feed)),
|
||||
Pair("Exchange", &self.exchange.clone()),
|
||||
Pair("DEX", &self.dex.clone()),
|
||||
Pair("Latency", &format!("{} ms", self.latency)),
|
||||
]
|
||||
.get_formatted()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Formatted for Pair<'a> {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![self.0.to_string(), self.1.to_string()]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Formatted for Triple<'a> {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![self.0.to_string(), self.1.to_string(), self.2.to_string()]
|
||||
@@ -206,19 +186,33 @@ impl<T: Formatted> Formatted for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Formatted for StrategyStatus {
|
||||
impl Formatted for EngineStatus {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
Triple(
|
||||
"\x1b[2mState\x1b[0m",
|
||||
"\x1b[2mMode\x1b[0m",
|
||||
"\x1b[2m..\x1b[0m",
|
||||
),
|
||||
Triple(
|
||||
&self.strategy_state.to_string(),
|
||||
&self.strategy_mode.to_string(),
|
||||
"..",
|
||||
),
|
||||
]
|
||||
.get_formatted()
|
||||
}
|
||||
}
|
||||
|
||||
impl Formatted for EngineConfig {
|
||||
fn get_formatted(&self) -> Vec<String> {
|
||||
vec![
|
||||
Triple(
|
||||
"\x1b[2mStrategy\x1b[0m",
|
||||
"\x1b[2mState\x1b[0m",
|
||||
"\x1b[2mMode\x1b[0m",
|
||||
),
|
||||
Triple(
|
||||
&format!("\x1b[97m{}\x1b[0m", self.strategy.name),
|
||||
&self.state.to_string(),
|
||||
&self.mode.to_string(),
|
||||
"\x1b[2m..\x1b[0m",
|
||||
"\x1b[2m..\x1b[0m",
|
||||
),
|
||||
Triple(&self.strategy.name, "..", ".."),
|
||||
]
|
||||
.get_formatted()
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ pub struct PulseTradeApp {
|
||||
command: State<InputState>,
|
||||
scroll: State<ScrollState<7>>,
|
||||
|
||||
strategy: State<Option<StrategyStatus>>,
|
||||
status: State<Option<Status>>,
|
||||
config: State<Option<EngineConfig>>,
|
||||
status: State<Option<EngineStatus>>,
|
||||
|
||||
watch_list: State<Vec<MarketItem>>,
|
||||
active_positions: State<Vec<Position>>,
|
||||
@@ -144,8 +144,7 @@ impl App for PulseTradeApp {
|
||||
(
|
||||
LayoutItem::Widget(Size::Flex(1)),
|
||||
Box::new(
|
||||
advanced_option_draw(&self.scroll, 3, "CONFIGURATION", &self.strategy)
|
||||
.await,
|
||||
advanced_option_draw(&self.scroll, 3, "CONFIGURATION", &self.config).await,
|
||||
),
|
||||
),
|
||||
(
|
||||
@@ -182,7 +181,7 @@ async fn main() -> tokio::io::Result<()> {
|
||||
signals: ctx.use_state(Vec::new()),
|
||||
logs: ctx.use_state(Vec::new()),
|
||||
inspect: ctx.use_state(InspectTarget::None),
|
||||
strategy: ctx.use_state(None),
|
||||
config: ctx.use_state(None),
|
||||
status: ctx.use_state(None),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -49,7 +49,7 @@ impl TerminalClient {
|
||||
let active_positions = app.active_positions.clone();
|
||||
let logs = app.logs.clone();
|
||||
let signals = app.signals.clone();
|
||||
let market_overview = app.strategy.clone();
|
||||
let market_overview = app.config.clone();
|
||||
let status = app.status.clone();
|
||||
let inspect = app.inspect.clone();
|
||||
|
||||
@@ -82,8 +82,8 @@ impl TerminalClient {
|
||||
active_positions: State<Vec<Position>>,
|
||||
logs: State<Vec<EventLog>>,
|
||||
signals: State<Vec<SignalStatus>>,
|
||||
market_overview: State<Option<StrategyStatus>>,
|
||||
status: State<Option<Status>>,
|
||||
config: State<Option<EngineConfig>>,
|
||||
status: State<Option<EngineStatus>>,
|
||||
inspect: State<InspectTarget>,
|
||||
) -> tokio::io::Result<()> {
|
||||
loop {
|
||||
@@ -111,8 +111,8 @@ impl TerminalClient {
|
||||
*active_positions.lock().await = v;
|
||||
}
|
||||
|
||||
TerminalServerMessage::StrategyUpdated(v) => {
|
||||
*market_overview.lock().await = Some(v);
|
||||
TerminalServerMessage::ConfigUpdated(v) => {
|
||||
*config.lock().await = Some(v);
|
||||
}
|
||||
|
||||
TerminalServerMessage::SignalsUpdated(v) => {
|
||||
|
||||
Reference in New Issue
Block a user