Deriv API - api.contract problem

edited August 18 in General

Hello, I´m developing a bot with deriv api, but I can´t buy twice with the same contract options.

If the amount is doubled, it works, but if I try to create a new contract with the same amount, api.contract never returns and the bot keep locked.

This is my code:

while (total < take_profit && total > -stop_loss) {

const contract = await api.contract({
amount: amount,
basis: 'stake',
contract_type: 'CALL',
currency: 'USD',
duration: 3,
duration_unit: 't',
proposal: 1,
symbol: '1HZ100V',
product_type: 'basic'
});

const buy = await contract.buy();

await contract
.onUpdate()
.pipe(find(({ is_sold }) => is_sold))
.toPromise();

const { profit, status } = contract;

if (status == 'won') {
total += Number(profit.display);
} else {
total -= Number(profit.display);
}

}

Any suggestion?

Tks.

Tagged:

Comments

Sign In or Register to comment.