Created
November 8, 2020 15:17
-
-
Save jayhuang75/cabf71cfe0186970cae76e5e6ef53ab8 to your computer and use it in GitHub Desktop.
tradingbot_main.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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