1 time buy success and stop if self , no "await contract.buy();" can get repeat balance how to fix?
https://github.com/binary-com/deriv-api/blob/master/examples/a_simple_bot.js
get account balance is working can repeat many time in loop.
async function main() {
while (1) {
const account = await api.account(token);
const { balance } = account;
console.log(Your current balance is: ${balance.currency} ${balance.display});
}
}
Out put
Your current balance is: USD 13,464.40
Your current balance is: USD 13,464.40
Your current balance is: USD 13,464.40
Your current balance is: USD 13,464.40
Your current balance is: USD 13,464.40
Your current balance is: USD 13,464.40
after add by contract only buy 1 time and stop.
async function main() {
while (1) {
const account = await api.account(token);
const { balance } = account; console.log(`Your current balance is: ${balance.currency} ${balance.display}`); const contract = await api.contract({ contract_type: 'CALL', currency: balance.currency, amount: 10, duration: 5, duration_unit: 't', symbol: 'R_10', basis: 'stake', }); const buy = await contract.buy();
}
}
out put only buy 1 time and stop
Your current balance is: USD 13,473.93
buy and loss
Your current balance is: USD 13,463.93
what im did wrong? all follow example script