Updated EngineConfig
This commit is contained in:
@@ -92,7 +92,7 @@ impl Engine {
|
||||
|
||||
self.terminal_server
|
||||
.broadcast(TerminalServerMessage::ConfigUpdated(
|
||||
self.get_config_status().await,
|
||||
self.get_config_status().await?,
|
||||
))
|
||||
.await?;
|
||||
} else {
|
||||
@@ -235,7 +235,7 @@ impl Engine {
|
||||
|
||||
self.terminal_server
|
||||
.broadcast(TerminalServerMessage::ConfigUpdated(
|
||||
self.get_config_status().await,
|
||||
self.get_config_status().await?,
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -102,11 +102,18 @@ impl Engine {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_config_status(&self) -> EngineConfig {
|
||||
EngineConfig {
|
||||
preset: self.config.lock().await.preset.clone(),
|
||||
pub async fn get_config_status(&self) -> tokio::io::Result<EngineConfig> {
|
||||
let manager = self.config.lock().await;
|
||||
let config = manager.get_ref()?;
|
||||
|
||||
Ok(EngineConfig {
|
||||
preset: manager.preset.clone(),
|
||||
strategy: self.strategy_engine.strategy.lock().await.manifest.clone(),
|
||||
}
|
||||
|
||||
risk_per_trade: config.risk.risk_per_trade,
|
||||
max_daily_loss: config.risk.max_daily_loss,
|
||||
max_open_positions: config.risk.max_open_positions,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn update_status(&self) -> tokio::io::Result<()> {
|
||||
|
||||
@@ -91,7 +91,7 @@ impl TerminalServer {
|
||||
|
||||
self.send_to(
|
||||
id,
|
||||
TerminalServerMessage::ConfigUpdated(engine.get_config_status().await),
|
||||
TerminalServerMessage::ConfigUpdated(engine.get_config_status().await?),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -219,9 +219,13 @@ impl Formatted for EngineConfig {
|
||||
Triple(
|
||||
"\x1b[2mPreset\x1b[0m",
|
||||
"\x1b[2mStrategy\x1b[0m",
|
||||
"\x1b[2m..\x1b[0m",
|
||||
"\x1b[2mRisk\x1b[0m",
|
||||
),
|
||||
Triple(
|
||||
&self.preset,
|
||||
&self.strategy.name,
|
||||
&self.risk_per_trade.to_string(),
|
||||
),
|
||||
Triple(&self.preset, &self.strategy.name, ".."),
|
||||
]
|
||||
.get_formatted()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user