Skip to content

Commit

Permalink
add live trading cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ryqdev committed May 18, 2024
1 parent d8781d6 commit c623981
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
19 changes: 19 additions & 0 deletions src/cmds/live.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
}
2 changes: 1 addition & 1 deletion src/cmds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ pub trait Command {

pub mod backtest;
pub mod paper;
mod live;
pub mod live;
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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!!!")),
}
}
6 changes: 0 additions & 6 deletions strategy/buy_and_hold.toml

This file was deleted.

0 comments on commit c623981

Please sign in to comment.