debugging

This commit is contained in:
2026-08-07 06:08:13 +02:00
parent e6db04f612
commit fc32026c86
2 changed files with 11 additions and 8 deletions
+11 -6
View File
@@ -16,10 +16,13 @@ use tokio::{
use crate::bot::Bot; use crate::bot::Bot;
async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Result<()> { async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Result<()> {
let stdin = BufReader::new(io::stdin()); loop {
let mut lines = stdin.lines(); let mut stdin = BufReader::new(io::stdin());
let mut line = String::new();
stdin.read_line(&mut line).await?;
while let Ok(Some(line)) = lines.next_line().await {
match line.to_lowercase().trim() { match line.to_lowercase().trim() {
"exit" | "shutdown" => { "exit" | "shutdown" => {
let _ = tx.send(true); let _ = tx.send(true);
@@ -33,9 +36,13 @@ async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Re
let filename = format!("sol-hun-{}.csv", formatted_time); let filename = format!("sol-hun-{}.csv", formatted_time);
let trade_log = bot.trade_log.lock().await;
log::info!("Saving {} trades", trade_log.len());
let mut writer = csv::Writer::from_path(&filename)?; let mut writer = csv::Writer::from_path(&filename)?;
for trade in bot.trade_log.lock().await.iter() { for trade in trade_log.iter() {
writer.serialize(trade)?; writer.serialize(trade)?;
} }
@@ -47,8 +54,6 @@ async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Re
_ => {} _ => {}
} }
} }
Ok(())
} }
#[tokio::main] #[tokio::main]
-2
View File
@@ -179,8 +179,6 @@ impl Strategy for MomentumVelocityStrategy {
if let Some(mut pos) = self.positions.remove(mint) { if let Some(mut pos) = self.positions.remove(mint) {
pos.trade.close(current_price, reason); pos.trade.close(current_price, reason);
info!("TRADE RESULT: {:?}", pos.trade);
bot.trade_log.lock().await.push(pos.trade); bot.trade_log.lock().await.push(pos.trade);
} }