Giter VIP home page Giter VIP logo

Comments (14)

bda2206 avatar bda2206 commented on June 14, 2024

thanks for fast response! just say the market goes up, and i want a new higher stop loss on my existing position?

from xapi-node.

peterszombati avatar peterszombati commented on June 14, 2024

Hi,

on new position (limit or market execution will be the same) you have to set "sl" parameter to the exact price like 1.07 for EURUSD or something like that.

x.Socket.send.tradeTransaction({
    cmd: CMD_FIELD.BUY_LIMIT,
    customComment: null,
    expiration: new Date().getTime() + 60000 * 60 * 24 * 365,
    offset: 0,
    order: 0,
    price: 21900,
    sl: 21000, // Here for example
    symbol: 'US30',
    tp: 26500,
    type: TYPE_FIELD.OPEN,// for Modifying this will be => "TYPE_FIELD.MODIFY"
    volume: 0.2
}).then(({order}) => {
    console.log('Success ' + order);
}).catch(e => {
    console.error('Failed');
    console.error(e);
});

for modifying will be the same but you have to change "order" parameter to order id.

You can find this function docs in WS how it works: https://peterszombati.github.io/xapi-node/#tradeTransaction

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

oh ok. just set the orderId and the rest as is..
I'll try that.
thanks heaps :)

from xapi-node.

peterszombati avatar peterszombati commented on June 14, 2024

@bda2206

in 2.3.1 I made simplier trade modifying you can try it.

x.Socket.send.tradeTransaction({
    order: 1234, // order / position number you can find it in (x.positions)
    type:TYPE_FIELD.MODIFY,
    sl:1.0 // add only what you want to modify
})

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

looks perfect, thanks heaps.

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

from xapi-node.

peterszombati avatar peterszombati commented on June 14, 2024

Hi @bda2206

problem will be "price" : 0
did you set it for it or module when added missing parameters?
are you sure did you use 2.3.1?

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

from xapi-node.

peterszombati avatar peterszombati commented on June 14, 2024

@bda2206 I added two log error in 2.3.2 which can describe if it not adding missing parameters why this do it

                if (type === TYPE_FIELD.MODIFY && position === undefined) {
                    if (!this.XAPI.isSubscribeTrades) {
                        Log.error('type === MODIFY in tradeTransaction will not work with missing parameters and subscribeTrades = false, you should set subscribeTrades = true in login config');
                    } else {
                        Log.error('type === MODIFY in tradeTransaction orderId = ' + order + ' not found, possible orderIds: ' + this.XAPI.positions.map(p => p.position).join(','))
                    }
                }

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

from xapi-node.

peterszombati avatar peterszombati commented on June 14, 2024

@bda2206 Try update to 2.3.3 with npm install xapi-node
and the problem is tradeTransaction request params required all params cmd, price, etc but xapi-node try to fill all missing params if it can't do it will be throw an Error and why it is not possible (in 2.3.3)

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

from xapi-node.

peterszombati avatar peterszombati commented on June 14, 2024

I dont see your image

from xapi-node.

bda2206 avatar bda2206 commented on June 14, 2024

from xapi-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.