if (this.newAccount.model_settings !== "{}") {
this.objForPost = `-n ${this.newAccount.account_name} -d ${this.newAccount.start_deposit} -c ${this.newAccount.client_name} -b ${this.newAccount.ib_account_number} -l ${this.newAccount.leverage} -e ${this.newAccount.description} -r ${this.newAccount.rebalance_model} -m "${this.newAccount.model_settings}"`;
} else if (this.newAccount.target_weights !== "{}") {
this.objForPost = `-n ${this.newAccount.account_name} -d ${this.newAccount.start_deposit} -c ${this.newAccount.client_name} -b ${this.newAccount.ib_account_number} -l ${this.newAccount.leverage} -e ${this.newAccount.description} -r ${this.newAccount.rebalance_model} -s ${this.newAccount.selected_systems} -w "${this.newAccount.target_weights}"`;
} else if (this.newAccount.model_settings !== "{}" && this.newAccount.target_weights !== "{}") {
this.objForPost = `-n ${this.newAccount.account_name} -d ${this.newAccount.start_deposit} -c ${this.newAccount.client_name} -b ${this.newAccount.ib_account_number} -l ${this.newAccount.leverage} -e ${this.newAccount.description} -r ${this.newAccount.rebalance_model} -s ${this.newAccount.selected_systems} -w "${this.newAccount.target_weights}" -m "${this.newAccount.model_settings}"`;
}
const map = {
n: "account_name",
d: "start_deposit",
c: "client_name",
b: "ib_account_number",
l: "leverage",
e: "description",
r: "rebalance_model",
m: "model_settings",
s: "selected_systems",
w: "target_weights",
}
let key = "ndcbler";
const hasSettings = this.newAccount.model_settings !== "{}";
const hasWeights = this.newAccount.target_weights !== "{}";
if (hasSettings && hasWeights) {
key += "swm";
} else if (hasSettings) {
key += "m";
} else if (hasWeights) {
key += "sw";
// } else { // что делаем, если ни того ни того нет?
// key = "";
}
this.objForPost = key.split("")
.map((key) => `-${key} ${this.newAccount[map[key]]}`)
.join(" ");
const с = `-n ${this.newAccount.account_name}`
+ ` -d ${this.newAccount.start_deposit}`
+ ` -c ${this.newAccount.client_name}`
+ ` -b ${this.newAccount.ib_account_number}`
+ ` -l ${this.newAccount.leverage}`
+ ` -e ${this.newAccount.description}`
+ ` -r ${this.newAccount.rebalance_model}`;
if (this.newAccount.model_settings !== "{}") {
this.objForPost = с
+ ` -m "${this.newAccount.model_settings}"`;
} else if (this.newAccount.target_weights !== "{}") {
this.objForPost = c
+ ` -s ${this.newAccount.selected_systems}`
+ ` -w "${this.newAccount.target_weights}"`;
} else if (this.newAccount.model_settings !== "{}"
&& this.newAccount.target_weights !== "{}"
) {
this.objForPost = с
+ ` -s ${this.newAccount.selected_systems}`
+ ` -w "${this.newAccount.target_weights}"`
+ ` -m "${this.newAccount.model_settings}"`;
}
let {
account_name,
start_deposit,
client_name,
ib_account_number,
leverage,
description,
rebalance_model,
model_settings,
selected_systems,
target_weights,
} = this.newAccount;
const с = `-n ${account_name}`
+ ` -d ${start_deposit}`
+ ` -c ${client_name}`
+ ` -b ${ib_account_number}`
+ ` -l ${leverage}`
+ ` -e ${description}`
+ ` -r ${rebalance_model}`;
if (model_settings !== "{}") {
this.objForPost = с + ` -m "${model_settings}"`;
} else if (target_weights !== "{}") {
this.objForPost = c + ` -s ${selected_systems} -w "${target_weights}"`;
} else if (model_settings !== "{}" && target_weights !== "{}") {
this.objForPost = с + ` -s ${selected_systems} -w "${target_weights}" -m "${model_settings}"`;
}