Skip to content

Instantly share code, notes, and snippets.

@jayhuang75
Created November 8, 2020 15:17
Show Gist options
  • Select an option

  • Save jayhuang75/cabf71cfe0186970cae76e5e6ef53ab8 to your computer and use it in GitHub Desktop.

Select an option

Save jayhuang75/cabf71cfe0186970cae76e5e6ef53ab8 to your computer and use it in GitHub Desktop.
tradingbot_main.rs
// inital the TradingBot for coinbase context
let mut coinbase_bot = bot::TradingBot::new(new_config, Box::new(bot::coinbase::Coinbase {}));
// set the interval for every 20s
let trading_cadence = env::var("TRADING_CADENCE").unwrap().parse::<u64>().unwrap();
let mut interval = time::interval(time::Duration::from_secs(trading_cadence));
loop {
// wait every 20s
interval.tick().await;
// trading start time
let start = Instant::now();
let now: Date<Local> = Local::now().date();
// trading kick off
info!("[TRADE] start at {:?}", now);
coinbase_bot.start().await.unwrap();
// trading end time
let duration = start.elapsed();
info!("[TRADE] end elapsed : {:?}", duration);
info!(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment