Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with closing STC positions on XTB #25

Closed
Rudy-Dev opened this issue Dec 30, 2021 · 2 comments
Closed

Issue with closing STC positions on XTB #25

Rudy-Dev opened this issue Dec 30, 2021 · 2 comments

Comments

@Rudy-Dev
Copy link

Hi there, the issue only occur when trying to close STC position doesn't happen when trying to close CRT position. I'm using XTB demo account.

code:

  try {
    await x.Socket.send
      .tradeTransaction({
        order: <POSITION_ID>,
        symbol: "RBLX.US",
        type: TYPE_FIELD.CLOSE,
        price: 0,
        volume: 1,
      })
      .then(() => {
        console.log("done");
      });
  } catch (err) {
    logError(err);
  }

also here is error dump:

 JsonError
    at Socket.sendCommand (C:\Users\mazep\Desktop\Projects\TS\TradeBot\node_modules\xapi-node\build\core\Socket\SocketConnection.js:60:23)
    at C:\Users\mazep\Desktop\Projects\TS\TradeBot\node_modules\xapi-node\build\core\Socket\Socket.js:119:33
    at new Promise (<anonymous>)
    at Object.tradeTransaction (C:\Users\mazep\Desktop\Projects\TS\TradeBot\node_modules\xapi-node\build\core\Socket\Socket.js:103:24)
    at Object.g2 (C:\Users\mazep\Desktop\Projects\TS\TradeBot\dist\index.js:93:14) {
  params: {
    reason: { code: 'BE11', explain: 'Position not found (#<POSITION_ID>)' },
    transaction: {
      command: 'tradeTransaction',
      type: 'Socket',
      request: [Object],
      response: [Object],
      transactionId: '164089816808500060',
      createdAt: [Time],
      status: 3,
      transactionPromise: [Object],
      urgent: true,
      stack: 'Error\n' +
        '    at Socket.sendCommand (C:\\Users\\mazep\\Desktop\\Projects\\TS\\TradeBot\\node_modules\\xapi-node\\build\\core\\Socket\\SocketConnection.js:60:23)\n' +
        '    at C:\\Users\\mazep\\Desktop\\Projects\\TS\\TradeBot\\node_modules\\xapi-node\\build\\core\\Socket\\Socket.js:119:33\n' +
        '    at new Promise (<anonymous>)\n' +
        '    at Object.tradeTransaction (C:\\Users\\mazep\\Desktop\\Projects\\TS\\TradeBot\\node_modules\\xapi-node\\build\\core\\Socket\\Socket.js:103:24)\n' +
        '    at Object.g2 (C:\\Users\\mazep\\Desktop\\Projects\\TS\\TradeBot\\dist\\index.js:93:14)'
    }
  }
}
@peterszombati
Copy link
Owner

for stocks I think you dont have to close positions you have to sell stocks for closing position but after market open I will give a try

@Rudy-Dev
Copy link
Author

Rudy-Dev commented Jan 4, 2022

Hi, I got it working however I cannot specify orderId, It is closing the first order on the list.
This is the code that I used:

  .tradeTransaction({
        cmd: CMD_FIELD.SELL,
        customComment: null,
        expiration: 0,
        offset: 0,
        order: 0,
        price: 1,
        symbol: "LBW.PL",
        tp: 0,
        sl: 0,
        type: TYPE_FIELD.OPEN,
        volume: 500,
      })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants