Engine status

This commit is contained in:
2026-07-31 04:20:32 +02:00
parent 7247319a38
commit 405dbdda2e
5 changed files with 82 additions and 44 deletions
+40
View File
@@ -16,6 +16,20 @@ pub enum LogKind {
Debug,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum ItemState {
Starting,
Running,
Stopped,
Error,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum Mode {
Auto,
Manual,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Signal {
pub symbol: String,
@@ -41,6 +55,12 @@ pub struct Position {
pub pnl: Decimal,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct EngineStatus {
pub strategy_mode: Mode,
pub strategy_state: ItemState,
}
impl std::fmt::Display for MarketTrend {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
@@ -61,3 +81,23 @@ impl std::fmt::Display for LogKind {
}
}
}
impl std::fmt::Display for Mode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Auto => write!(f, "\x1b[96mAUTO\x1b[0m"),
Self::Manual => write!(f, "\x1b[97mMANUAL\x1b[0m"),
}
}
}
impl std::fmt::Display for ItemState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Starting => write!(f, "\x1b[93mSTARTING\x1b[0m"),
Self::Running => write!(f, "\x1b[92mRUNNING\x1b[0m"),
Self::Stopped => write!(f, "\x1b[90mSTOPPED\x1b[0m"),
Self::Error => write!(f, "\x1b[91mERROR\x1b[0m"),
}
}
}
+1 -34
View File
@@ -1,6 +1,5 @@
use crate::{
general::{EventLog, Position, Signal},
strategy::StrategyManifest,
general::{EventLog, ItemState, Mode, Position, Signal}, strategy::StrategyManifest,
};
use hypersdk::{Decimal, hypercore::CandleInterval};
@@ -66,19 +65,6 @@ pub struct Status {
pub latency: u16,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum Mode {
Auto,
Manual,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum ItemState {
Running,
Stopped,
Error,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct StrategyStatus {
pub strategy: StrategyManifest,
@@ -87,22 +73,3 @@ pub struct StrategyStatus {
pub state: ItemState,
pub cooldown: CandleInterval,
}
impl std::fmt::Display for Mode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Auto => write!(f, "\x1b[96mAUTO\x1b[0m"),
Self::Manual => write!(f, "\x1b[97mMANUAL\x1b[0m"),
}
}
}
impl std::fmt::Display for ItemState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Running => write!(f, "\x1b[92mRUNNING\x1b[0m"),
Self::Stopped => write!(f, "\x1b[90mSTOPPED\x1b[0m"),
Self::Error => write!(f, "\x1b[91mERROR\x1b[0m"),
}
}
}