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}"`;
}
const arr = await getStartEndDateInTradePage.findAll(
{
attributes: ['open_date', 'close_date'],
where: {
close_date: {
[Op.ne]: '-'
}
}
}
)
type: DataTypes.ENUM("foo",'bar")
type: Sequelize.ENUM("foo",'bar")
const a = {
ticker: 'SPY',
strategy: 'OLD',
broker: 'OOH'
};
const b = {
ticker: 'SPY',
strategy: 'LOG',
broker: 'FOR'
};
const c = {
ticker: 'HG',
strategy: 'KIP',
broker: 'LOOP'
};
const obj = {
ticker: "SPY",
strategy: "LOG",
broker: ""
};
const objs = [a, b, c];
let out = [];
for (let i = 0; i < objs.length; i++) {
if (objs[i].ticker === obj.ticker && objs[i].strategy === obj.strategy) {
out.push(objs[i]);
}
}
console.log(out);
const arr = [
{
value: 'aaa'
},
{
value: 'bbb'
},
{
value: 'ccc'
},
{
value: 'ddd'
},
]
let arr2 = [];
arr.forEach(el => {
arr2.push(el.value)
})
console.log(arr2)
Object.keys(a).forEach(n => b.hasOwnProperty(n) && (a[n] = b[n]));
for (const [ k, v ] of Object.entries(b)) {
if (a.hasOwnProperty(k)) {
a[k] = v;
}
}
router.get('/', controller.getArrSelectDataType);
router.post('/', controller.getArrSelectTicker);
router.post('/', controller.getArrSelectSource);
router.get('/get-arr-select-data-type', controller.getArrSelectDataType);
router.post('/get-arr-select-data-ticker', controller.getArrSelectTicker);
router.post('/get-arr-select-data-source', controller.getArrSelectSource);
const index = arr.findIndex(n => n.id === newObj.id);
if (index !== -1) {
arr[index] = newObj;
} else {
arr.push(newObj);
}
const obj = arr.find(n => n.id === newObj.id);
if (obj) {
Object.assign(obj, newObj);
} else {
arr.push(newObj);
}