diff --git a/src/main.rs b/src/main.rs index 1ca705c..f87dda7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,12 +15,11 @@ use tokio::{ use crate::bot::Bot; -async fn shutdown_listener(bot: Arc, tx: watch::Sender) -> anyhow::Result<()> { +async fn try_shutdown_listener(bot: Arc, tx: watch::Sender) -> anyhow::Result<()> { + let mut stdin = BufReader::new(io::stdin()); + let mut line = String::new(); + loop { - let mut stdin = BufReader::new(io::stdin()); - - let mut line = String::new(); - stdin.read_line(&mut line).await?; match line.to_lowercase().trim() { @@ -56,6 +55,12 @@ async fn shutdown_listener(bot: Arc, tx: watch::Sender) -> anyhow::Re } } +async fn shutdown_listener(bot: Arc, tx: watch::Sender) { + if let Err(e) = try_shutdown_listener(bot, tx).await { + log::error!("{e}"); + } +} + #[tokio::main] async fn main() -> anyhow::Result<()> { let mut builder = env_logger::Builder::from_default_env(); diff --git a/src/tradelog.rs b/src/tradelog.rs index 8634769..3b22b8f 100644 --- a/src/tradelog.rs +++ b/src/tradelog.rs @@ -14,16 +14,14 @@ pub struct TradeLog { pub opened_at: chrono::DateTime, pub closed_at: Option>, + pub duration: Option, pub entry_price_sol: f64, pub exit_price_sol: Option, pub pnl_percent: Option, - pub duration: Option, - pub exit_reason: Option, - // Conditions when entered pub unique_buyers: usize, pub net_sol_flow: f64, pub curve_sol: f64,