Send strategy manifest to clients
This commit is contained in:
+26
-5
@@ -59,17 +59,38 @@ impl TerminalServer {
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_client(
|
||||
self: &Arc<Self>,
|
||||
id: &usize,
|
||||
mut reader: OwnedReadHalf,
|
||||
) -> tokio::io::Result<()> {
|
||||
async fn initialize_client(self: &Arc<Self>, id: &usize) -> tokio::io::Result<()> {
|
||||
let engine = self.get_engine();
|
||||
let pair = engine.strategy.pair.lock().await;
|
||||
|
||||
self.send_to(
|
||||
id,
|
||||
pulse_wire::terminal::TerminalServerMessage::StrategyUpdated(Strategy {
|
||||
strategy: pair.strategy_manifest.lock().await.clone(),
|
||||
risk: pair.risk_manifest.lock().await.clone(),
|
||||
mode: Mode::Auto,
|
||||
state: ItemState::Running,
|
||||
cooldown: TimeFrame::M15,
|
||||
}),
|
||||
)
|
||||
.await?;
|
||||
|
||||
self.send_to(
|
||||
id,
|
||||
pulse_wire::terminal::TerminalServerMessage::SetLogs(self.logs.lock().await.clone()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_client(
|
||||
self: &Arc<Self>,
|
||||
id: &usize,
|
||||
mut reader: OwnedReadHalf,
|
||||
) -> tokio::io::Result<()> {
|
||||
self.initialize_client(id).await?;
|
||||
|
||||
loop {
|
||||
let mut len_buf = [0u8; size_of::<usize>()];
|
||||
let size = reader.read_exact(&mut len_buf).await?;
|
||||
|
||||
+1
-26
@@ -181,32 +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(Some(Strategy {
|
||||
strategy: StrategyManifest {
|
||||
name: "Liquidity Sweep".to_string(),
|
||||
description:
|
||||
"Detects liquidity grabs around key support and resistance levels."
|
||||
.to_string(),
|
||||
author: "Klesty Selimaj".to_string(),
|
||||
version: "1.0.0".to_string(),
|
||||
|
||||
timeframes: vec![TimeFrame::M5, TimeFrame::M15, TimeFrame::H1],
|
||||
},
|
||||
|
||||
risk: RiskManifest {
|
||||
name: "Aggressive".to_string(),
|
||||
description: "High-risk profile with larger position sizing.".to_string(),
|
||||
author: "Klesty Selimaj".to_string(),
|
||||
version: "1.0.0".to_string(),
|
||||
|
||||
max_loss: 5,
|
||||
cooldown: TimeFrame::M15,
|
||||
},
|
||||
|
||||
mode: Mode::Auto,
|
||||
state: ItemState::Running,
|
||||
cooldown: TimeFrame::M15,
|
||||
})),
|
||||
strategy: ctx.use_state(None),
|
||||
status: ctx.use_state(None),
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user