Using pwp
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use pulse_wire::terminal::{ActivePosition, Signal, WatchListItem};
|
||||
|
||||
pub mod terminal;
|
||||
|
||||
#[tokio::main]
|
||||
@@ -17,6 +19,86 @@ async fn main() -> tokio::io::Result<()> {
|
||||
|
||||
loop {
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(1500)).await;
|
||||
|
||||
terminal_server
|
||||
.broadcast(
|
||||
pulse_wire::terminal::TerminalServerMessage::WatchListUpdated(vec![
|
||||
WatchListItem {
|
||||
symbol: "BTC".to_string(),
|
||||
price: 118_402.12,
|
||||
trend: 0.82,
|
||||
},
|
||||
WatchListItem {
|
||||
symbol: "ETH".to_string(),
|
||||
price: 3_912.48,
|
||||
trend: -0.41,
|
||||
},
|
||||
WatchListItem {
|
||||
symbol: "SOL".to_string(),
|
||||
price: 182.91,
|
||||
trend: 2.18,
|
||||
},
|
||||
WatchListItem {
|
||||
symbol: "XRP".to_string(),
|
||||
price: 2.84,
|
||||
trend: 1.22,
|
||||
},
|
||||
]),
|
||||
)
|
||||
.await?;
|
||||
|
||||
terminal_server
|
||||
.broadcast(
|
||||
pulse_wire::terminal::TerminalServerMessage::PositionsUpdated(vec![
|
||||
ActivePosition {
|
||||
symbol: "BTC".to_string(),
|
||||
profit: 125.50,
|
||||
amount: 0.25,
|
||||
},
|
||||
ActivePosition {
|
||||
symbol: "SOL".to_string(),
|
||||
profit: 84.20,
|
||||
amount: 5.0,
|
||||
},
|
||||
ActivePosition {
|
||||
symbol: "ETH".to_string(),
|
||||
profit: -32.75,
|
||||
amount: 1.0,
|
||||
},
|
||||
ActivePosition {
|
||||
symbol: "XRP".to_string(),
|
||||
profit: 12.30,
|
||||
amount: 0.75,
|
||||
},
|
||||
]),
|
||||
)
|
||||
.await?;
|
||||
|
||||
terminal_server
|
||||
.broadcast(pulse_wire::terminal::TerminalServerMessage::SignalsUpdated(
|
||||
vec![
|
||||
Signal {
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: pulse_wire::terminal::SignalParameter::Lim,
|
||||
price: 118_800.0,
|
||||
},
|
||||
Signal {
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: pulse_wire::terminal::SignalParameter::Tap,
|
||||
price: 120_000.0,
|
||||
},
|
||||
Signal {
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: pulse_wire::terminal::SignalParameter::Stl,
|
||||
price: 118_000.0,
|
||||
},
|
||||
],
|
||||
))
|
||||
.await?;
|
||||
|
||||
terminal_server
|
||||
.broadcast(pulse_wire::terminal::TerminalServerMessage::AddLog(
|
||||
pulse_wire::terminal::EventLog {
|
||||
@@ -26,6 +108,7 @@ async fn main() -> tokio::io::Result<()> {
|
||||
},
|
||||
))
|
||||
.await?;
|
||||
|
||||
println!("Ok");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@ impl TerminalServer {
|
||||
if let Err(e) = clients[i].write(&msg).await {
|
||||
clients.remove(i);
|
||||
println!("{e:?}");
|
||||
} else if let Err(e) = clients[i].flush().await {
|
||||
clients.remove(i);
|
||||
println!("{e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-96
@@ -22,7 +22,7 @@ use pulse_ui::{
|
||||
use crate::formatting::{Formatted, apply_padding};
|
||||
|
||||
use pulse_wire::terminal::{
|
||||
ActivePosition, Alert, EventLog, InspectTarget, MarketOverview, Signal, Status, WatchListItem,
|
||||
ActivePosition, EventLog, InspectTarget, MarketOverview, Signal, Status, WatchListItem,
|
||||
};
|
||||
|
||||
pub struct PulseTradeApp {
|
||||
@@ -38,101 +38,7 @@ pub struct PulseTradeApp {
|
||||
}
|
||||
|
||||
impl App for PulseTradeApp {
|
||||
async fn init(&mut self, _ctx: &pulse_ui::state::Context) {
|
||||
let mut watch_list = self.watch_list.lock().await;
|
||||
|
||||
watch_list.push(WatchListItem {
|
||||
symbol: "BTC".to_string(),
|
||||
price: 118_402.12,
|
||||
trend: 0.82,
|
||||
});
|
||||
watch_list.push(WatchListItem {
|
||||
symbol: "ETH".to_string(),
|
||||
price: 3_912.48,
|
||||
trend: -0.41,
|
||||
});
|
||||
watch_list.push(WatchListItem {
|
||||
symbol: "SOL".to_string(),
|
||||
price: 182.91,
|
||||
trend: 2.18,
|
||||
});
|
||||
watch_list.push(WatchListItem {
|
||||
symbol: "XRP".to_string(),
|
||||
price: 2.84,
|
||||
trend: 1.22,
|
||||
});
|
||||
|
||||
let mut active_positions = self.active_positions.lock().await;
|
||||
|
||||
active_positions.push(ActivePosition {
|
||||
symbol: "BTC".to_string(),
|
||||
profit: 125.50,
|
||||
amount: 0.25,
|
||||
});
|
||||
active_positions.push(ActivePosition {
|
||||
symbol: "ETH".to_string(),
|
||||
profit: -32.75,
|
||||
amount: 1.0,
|
||||
});
|
||||
active_positions.push(ActivePosition {
|
||||
symbol: "SOL".to_string(),
|
||||
profit: 84.20,
|
||||
amount: 5.0,
|
||||
});
|
||||
active_positions.push(ActivePosition {
|
||||
symbol: "XRP".to_string(),
|
||||
profit: 12.30,
|
||||
amount: 0.75,
|
||||
});
|
||||
|
||||
let mut signals = self.signals.lock().await;
|
||||
|
||||
signals.push(Signal {
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: pulse_wire::terminal::SignalParameter::Lim,
|
||||
price: 118_800.0,
|
||||
});
|
||||
|
||||
signals.push(Signal {
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: pulse_wire::terminal::SignalParameter::Tap,
|
||||
price: 120_000.0,
|
||||
});
|
||||
|
||||
signals.push(Signal {
|
||||
kind: pulse_wire::terminal::SignalKind::Buy,
|
||||
symbol: "BTC".to_string(),
|
||||
param: pulse_wire::terminal::SignalParameter::Stl,
|
||||
price: 118_000.0,
|
||||
});
|
||||
|
||||
let mut logs = self.logs.lock().await;
|
||||
|
||||
logs.push(EventLog {
|
||||
kind: pulse_wire::terminal::LogKind::Warn,
|
||||
name: "pulse.init".to_string(),
|
||||
message: "We're still not done yet ;)".to_string(),
|
||||
});
|
||||
|
||||
let mut market_overview = self.market_overview.lock().await;
|
||||
|
||||
market_overview.alerts.push(Alert {
|
||||
level: pulse_wire::terminal::AlertLevel::High,
|
||||
message: "BTC funding rate elevated".to_string(),
|
||||
});
|
||||
|
||||
market_overview.alerts.push(Alert {
|
||||
level: pulse_wire::terminal::AlertLevel::Medium,
|
||||
message: "Market volatility increasing".to_string(),
|
||||
});
|
||||
|
||||
market_overview.alerts.push(Alert {
|
||||
level: pulse_wire::terminal::AlertLevel::Low,
|
||||
message: "ETH volatility returning to normal".to_string(),
|
||||
});
|
||||
}
|
||||
async fn init(&mut self, _ctx: &pulse_ui::state::Context) {}
|
||||
|
||||
async fn update(&mut self, ctx: &pulse_ui::state::Context, event: Box<dyn Any + Send + Sync>) {
|
||||
if let Some(Refresh) = event.downcast_ref() {
|
||||
|
||||
Reference in New Issue
Block a user