def set_params(self): period = self.cbx_period.currentText().strip() ema_fast = self.txt_ema_fast.toPlainText().strip() ema_slow = self.txt_ema_slow.toPlainText().strip() open_offset = self.txt_open_offset.toPlainText().strip() open_interval = self.txt_open_interval.toPlainText().strip() stop_earning_offset = self.txt_stop_earning_offset.toPlainText().strip( ) stop_loss_offset = self.txt_stop_loss_offset.toPlainText().strip() level_rate = self.txt_level_rate.toPlainText().strip() max_number = self.txt_max_num.toPlainText().strip() file = 'config.xml' config_helper = ConfigHelper(file) config_to_save = ConfigData() ret = config_helper.init_root() if ret: config_helper.parse(config_to_save) config_to_save._period = period config_to_save._ema_fast = ema_fast config_to_save._ema_slow = ema_slow config_to_save._open_offset = open_offset config_to_save._open_interval = open_interval config_to_save._stop_earning_offset = stop_earning_offset config_to_save._level_rate = level_rate config_to_save._max_open_number = max_number config_helper.save(config_to_save) else: QMessageBox.information(self, '提示', '配置文件config.xml出错')
def save_registration_info(self): registration_info = self.txt_registration_info.toPlainText().strip() if not registration_info: QMessageBox.information(self, '提示', '注册信息不完整') return file = 'config.xml' config_helper = ConfigHelper(file) config_to_save = ConfigData() ret = config_helper.init_root() if ret: config_helper.parse(config_to_save) config_to_save._qds_id = registration_info config_helper.save(config_to_save) QMessageBox.information(self, '提示', '信息已保存, 重启软件生效') else: QMessageBox.information(self, '警告', '配置文件config.xml出错')
def set_authorize(self): access_key = self.txt_access_key.toPlainText().strip() secret_key = self.txt_secret_key.toPlainText().strip() if not access_key or not secret_key: QMessageBox.information(self, '提示', '信息不完整') return file = 'config.xml' config_helper = ConfigHelper(file) config_to_save = ConfigData() ret = config_helper.init_root() if ret: config_helper.parse(config_to_save) config_to_save._access_key = access_key config_to_save._secret_key = secret_key config_helper.save(config_to_save) QMessageBox.information(self, '提示', '信息已保存,重启软件生效') else: QMessageBox.information(self, '提示', '配置文件config.xml出错')