Author Topic: Jolly fucked up bug  (Read 3015 times)

0 Members and 1 Guest are viewing this topic.

Offline Methodise

Thanks doods.  +5%

I'll endeavour to direct further bug reports directly to the github.



BTS: methodise

Offline svk

Worker: dev.bitsharesblocks

Offline svk

My problem is, I've elected to buy 10 USD at a price of 0.003875. The computer says naah and counter-offers me 0.0038. If that isn't a feature, it's a bug.

My confirmation dialogue is expressing the price inversely to my writing it, which is slightly frustrating - that confirmation figure isn't something i can work with unless I fetch a calculator. But when I do so, I realise all of my precision orders have been rounded down. However, orders to 6 decimals do appear in the order book, and so far as I can tell I have been able to generate some of them myself, perhaps only when the interface is orientated the other way, (BTS:USD /  USD:BTS).

While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.

You're right, there's a new bug here that occurs when a price is entered with an amount of decimals that exceeds the precision of the asset you're using to define the price. In this case, USD precision is 4 decimals, so the parts of the price beyond that were truncated. I'll push a fix for it using a function find the correct integer ratio.

If you don't like the market direction used for the price display, you can click on it to flip it. That setting will then be applied to and remembered for that market pair. Due to the way prices are represented there's no way to know the "correct" direction for an order so it just has to be that way.
Worker: dev.bitsharesblocks

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Default transfer fee was 30 BTS if you transfer without a memo. If you have a memo, there will be an additional data-size fee (x per kb). See https://cryptofresh.com/fees
I asked the same thing last week when I paid more in fees than what was stated as the transfer fee. The memo field needs to explain this otherwise it looks like an overcharge to every user.
Please submit an issue or pull request to github https://github.com/cryptonomex/graphene-ui/issues if you have good practical suggestions. For example: place what text at what position of what page. Best a screenshot or visual page design. Thanks!
BitShares committee member: abit
BitShares witness: in.abit

Offline mint chocolate chip

While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Default transfer fee was 30 BTS if you transfer without a memo. If you have a memo, there will be an additional data-size fee (x per kb). See https://cryptofresh.com/fees
I asked the same thing last week when I paid more in fees than what was stated as the transfer fee. The memo field needs to explain this otherwise it looks like an overcharge to every user.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
Default transfer fee was 30 BTS if you transfer without a memo. If you have a memo, there will be an additional data-size fee (x per kb). See https://cryptofresh.com/fees
BitShares committee member: abit
BitShares witness: in.abit

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
It is not over complected. The code is below, the worker to pay for it coming soon  :)

Code: [Select]
// Closure
(function() {
  /**
   * Decimal adjustment of a number.
   *
   * @param {String}  type  The type of adjustment.
   * @param {Number}  value The number.
   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).
   * @returns {Number} The adjusted value.
   */
  function decimalAdjust(type, value, exp) {
    // If the exp is undefined or zero...
    if (typeof exp === 'undefined' || +exp === 0) {
      return Math[type](value);
    }
    value = +value;
    exp = +exp;
    // If the value is not a number or the exp is not an integer...
    if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
      return NaN;
    }
    // Shift
    value = value.toString().split('e');
    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
    // Shift back
    value = value.toString().split('e');
    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
  }

  // Decimal round
  if (!Math.round10) {
    Math.round10 = function(value, exp) {
      return decimalAdjust('round', value, exp);
    };
  }
  // Decimal floor
  if (!Math.floor10) {
Math.floor10 = function(value, exp) {
      return decimalAdjust('floor', value, exp);
    };
  }
  // Decimal ceil
  if (!Math.ceil10) {
    Math.ceil10 = function(value, exp) {
      return decimalAdjust('ceil', value, exp);
    };
  }
})();
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
... where it comes to financial exchange software, things like fees and decimal places being as written, do matter.

every serious person will run or laugh when he sees floating point math being used in a 'financial' platform. It is a joke or a toy but  not a financial platform...

But when I say something like that... a 'complainer' and not a doer I am promptly called... so I will just shut up... and fix it.
« Last Edit: March 02, 2016, 08:50:34 pm by tonyk »
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline Methodise

My problem is, I've elected to buy 10 USD at a price of 0.003875. The computer says naah and counter-offers me 0.0038. If that isn't a feature, it's a bug.

My confirmation dialogue is expressing the price inversely to my writing it, which is slightly frustrating - that confirmation figure isn't something i can work with unless I fetch a calculator. But when I do so, I realise all of my precision orders have been rounded down. However, orders to 6 decimals do appear in the order book, and so far as I can tell I have been able to generate some of them myself, perhaps only when the interface is orientated the other way, (BTS:USD /  USD:BTS).

While I'm at it, I had a similar gripe with the interface when it offered me the ability to pay a transaction fee in 30 BTS or X USD. I chose to pay in BTS, and was charged 32 BTS. Certainly, that might be how things are supposed to work when transferring USD or whatever I was doing, but as finicky as it may seem, where it comes to financial exchange software, things like fees and decimal places being as written, do matter.
BTS: methodise

Offline svk



Most recent download. Doesn't seem to work to 4 decimals here. Misleading.
Some more detail would be nice. What exactly is the bug?
Worker: dev.bitsharesblocks

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
in graphene, prices are ratios of two integer numbers and they are stored on the blockchain that way!
What you get displayed is a floating number that is derived (and possibly truncated) for readability reasons.

Offline Methodise



Most recent download. Doesn't seem to work to 4 decimals here. Misleading.
BTS: methodise