burningtree / libbux

Un-official library for BUX trading platform (Node.js)
28 stars 9 forks source link

Open new trade with real money #6

Open dcparga opened 7 years ago

dcparga commented 7 years ago

Hi,

This is not an issue with the actual lib, but I'm not able to open a new position once I'm operating with real money. I receive this message:

{"message":"Unable to make a trade in another currency than the home currency","developerMessage":"Unable to make a trade in another currency than the home currency","errorCode":"CORE_011"}'

Any suggestion?

Thanks

bobvdvalk commented 7 years ago

Did you got this to work? I want to start using it as well but I am not sure the library still works?

dcparga commented 7 years ago

Hi @bobvdvalk,

Yes, it still works, and I achieved that as well. Basically you need to download the library and modify the file bux.js, and use this one instead of using npm package, and modify the function open from this:

BUX.prototype.open = function(trade, callback) {
      var data = {
        boostEffect: trade.multiplier.toString() || 1,
        homeCurrency: 'BUX',
        direction: trade.direction,
        productId: this.findProductBySymbol(trade.product) || trade.product,
        source: 'PRODUCTS_CURATED',
        tradeSize: trade.size.toString()
      };
      this.debug('Opening position: product=' + data.productId + ' dir=' + data.direction +
        ' size=' + data.tradeSize + ' multiplier=' + data.boostEffect);

      return this.post('users/me/trades', data, callback);
    };

to this:

BUX.prototype.open = function(trade, callback) {
      var data = {
        boostEffect: trade.multiplier.toString() || 1,
        homeCurrency: 'EUR',
        direction: trade.direction,
        productId: this.findProductBySymbol(trade.product) || trade.product,
        source: 'PRODUCTS_CURATED',
        tradeSize: trade.size.toString()
      };
      this.debug('Opening position: product=' + data.productId + ' dir=' + data.direction +
        ' size=' + data.tradeSize + ' multiplier=' + data.boostEffect);

      return this.post('users/me/trades', data, callback);
    };
bobvdvalk commented 7 years ago

Thanks for your awesome reply! 👍

bobvdvalk commented 7 years ago

BTW, do you use this library? I can't even get my open positions..?

dcparga commented 7 years ago

Yes, I'm using it :) To get your open positions just use the portfolio function, using the given token after being authenticated.