polymarket-hft 0.0.7

A high-frequency trading system for Polymarket with built-in API clients (Data API, CLOB, CLOB WebSocket, Gamma, RTDS) and CLI
Documentation
use clap::{Parser, Subcommand};
use tracing_subscriber::EnvFilter;

mod cli;

use cli::ds;

#[derive(Parser)]
#[command(name = "polymarket")]
#[command(about = "A CLI for Polymarket HFT", long_about = None)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Data source commands (Polymarket and external APIs)
    #[command(subcommand)]
    Ds(ds::DsCommands),
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize tracing subscriber with env-filter support
    // Set RUST_LOG=trace to see HTTP request/response logs
    tracing_subscriber::fmt()
        .with_env_filter(EnvFilter::from_default_env())
        .init();

    let cli = Cli::parse();

    match &cli.command {
        Commands::Ds(ds_cmd) => {
            ds::handle(ds_cmd).await?;
        }
    }

    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    use cli::data;

    #[test]
    fn parses_health_command() {
        let cli = Cli::parse_from(["polymarket", "ds", "data", "health"]);
        match cli.command {
            Commands::Ds(ds::DsCommands::Data(data::DataCommands::Health)) => {}
            _ => panic!("expected health command"),
        }
    }
}