Unknown contract proposal

edited June 2020 in General

hi
i'm trying the deriv-api for first time
i tried the example bot it works fine
https://github.com/binary-com/deriv-api/blob/master/examples/a_simple_bot.js

but i want to buy another contract if the first contract is loss

so i've added this

if (status === "lost") {

    const contract2 = await api.contract({
        contract_type: 'CALL',
        amount: 10,
        duration: 5,
        currency:'USD',
        duration_unit: 't',
        symbol: 'frxEURJPY',
        basis: 'stake',
    });

    const buy2 = await contract2.buy();

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

    const { profit, status } = contract2;

    console.log(`You ${status}: ${profit.currency} ${profit.display}`);

}

but i get error like this

{
  echo_req: {
    buy: '30927f91-3623-98c1-4244-58ed4862ef16',
    price: 10,
    req_id: 12
  },
  error: {
    code: 'InvalidContractProposal',
    message: 'Unknown contract proposal'
  },
  msg_type: 'buy',
  req_id: 12
}

but when i change any of the paramas in contract it buys the contract but i don't want to change the params
what am i doin wrong here

Comments

Sign In or Register to comment.