extern crate lazy_static;
use crate::model::config::Config;
use ini::{Ini, Properties};
use kucoin_api::client::Credentials;
use std::sync::Arc;
lazy_static::lazy_static! {
static ref INI: Ini = Ini::load_from_file("config.ini").expect("config file not found");
pub static ref SEC_CRED: Properties = INI.section(Some("KuCoin Credentials")).unwrap().clone();
pub static ref SEC_BEHV: Properties = INI.section(Some("Behaviour")).unwrap().clone();
pub static ref CONFIG: Arc<Config> = Arc::new(load_ini());
}
pub fn load_ini() -> Config {
let interval_str = SEC_BEHV.get("monitor_interval_sec").unwrap();
Config {
monitor_interval_sec: interval_str.parse::<u64>().unwrap(),
api_key: SEC_CRED.get("api_key").unwrap(),
secret_key: SEC_CRED.get("secret_key").unwrap(),
passphrase: SEC_CRED.get("passphrase").unwrap(),
}
}
pub fn credentials() -> Credentials {
Credentials::new(CONFIG.api_key, CONFIG.secret_key, CONFIG.passphrase)
}