peterszombati / xapi-node

xStation5 Trading API for NodeJS/JS
https://peterszombati.github.io/xapi-node/
Other
58 stars 19 forks source link

Invalid parameters when close or delete position #21

Closed apoutchika closed 3 years ago

apoutchika commented 3 years ago

Hello,

I can not close a position after open it :

  x.positions.map((pos) => {
    x.Socket.send
      .tradeTransaction({
        order: pos.order,
        type: TYPE_FIELD.DELETE,
      })
      .then(console.log)
      .catch(console.error);
  });

I have this error :

{
  reason: { code: 'EX000', explain: 'Invalid parameters' },
  transaction: {
    command: 'tradeTransaction',
    type: 'Socket',
    request: {
      json: '{"command":"tradeTransaction","arguments":{"tradeTransInfo":{"customComment":"x163211469666300080","order":304233558,"type":4}},"customTag":"tradeTransaction_163211469666300080"}',
      arguments: [Object],
      sent: [Time]
    },
    response: { status: false, received: [Time], json: [Object] },
    transactionId: '163211469666300080',
    createdAt: Time { unit: [Array], UTCTimestamp: 1632114696663 },
    status: 3,
    transactionPromise: { resolve: null, reject: null },
    urgent: true
  }
}

I have the same error with CLOSE type.

Thank you for you'r help :pray:

peterszombati commented 3 years ago

Hi @apoutchika try this

        x.Socket.send.tradeTransaction({
          order: number,
          type: TYPE_FIELD.CLOSE,
          volume: number, // volume in lot
          symbol: string, // position symbol
          price: 1, // it doesnt matter but required :)
        })

also please try solve these kind of issues by yourself with reading docs. for me I did same :)