Deriv API - api.contract problem
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.
Comments
HI, if the server does not respond to you, perhaps the matter is in the websocket, try to walk and output each request to the console, perhaps the repeated request takes incorrect data. Sending via Json Newtonsoft?
I think it is a matter in deriv api:
https://github.com/binary-com/deriv-api
Are you able to see the JSON response from the server in developer tools?