diff --git a/src/cmds/live.rs b/src/cmds/live.rs index e69de29..89880a6 100644 --- a/src/cmds/live.rs +++ b/src/cmds/live.rs @@ -0,0 +1,19 @@ +use async_trait::async_trait; +use clap::{ArgMatches, Command as ClapCommand}; +use crate::cmds::Command; + +pub struct LiveTradingCommand; + +#[async_trait] +impl Command for LiveTradingCommand { + fn usage() -> ClapCommand { + ClapCommand::new("live-trading") + .about("Live trading") + .visible_alias("l") + } + + async fn handler(m: &ArgMatches) -> anyhow::Result<()> { + log::info!("handle live trading"); + Ok(()) + } +} \ No newline at end of file diff --git a/src/cmds/mod.rs b/src/cmds/mod.rs index 81a575b..3a3a57f 100644 --- a/src/cmds/mod.rs +++ b/src/cmds/mod.rs @@ -12,4 +12,4 @@ pub trait Command { pub mod backtest; pub mod paper; -mod live; +pub mod live; diff --git a/src/main.rs b/src/main.rs index 3909110..09c47ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,8 @@ use std::io::Write; mod cmds; use crate::{cmds::{Command, backtest::BackTestCommand, - paper::PaperTradingCommand} + paper::PaperTradingCommand, + live::LiveTradingCommand} }; fn init_log() { @@ -31,12 +32,14 @@ async fn main() -> anyhow::Result<()> { let cmd = clap::Command::new("golden") .subcommands(vec![ BackTestCommand::usage().display_order(1), - PaperTradingCommand::usage().display_order(2) + PaperTradingCommand::usage().display_order(2), + LiveTradingCommand::usage().display_order(3) ]); match cmd.get_matches().subcommand() { Some(("backtest", sub_m)) => Ok(BackTestCommand::handler(sub_m).await?), Some(("paper-trading", sub_m)) => Ok(PaperTradingCommand::handler(sub_m).await?), + Some(("live-trading", sub_m)) => Ok(LiveTradingCommand::handler(sub_m).await?), _ => Err(anyhow::Error::msg("match error!!!")), } } diff --git a/strategy/buy_and_hold.toml b/strategy/buy_and_hold.toml deleted file mode 100644 index 5616986..0000000 --- a/strategy/buy_and_hold.toml +++ /dev/null @@ -1,6 +0,0 @@ -[config] -symbol = "TLT" -holding = 100 -start = "2024-04-09" -end = "2024-04-30" -