BitShares Forum

Main => General Discussion => Topic started by: dxtr on October 06, 2014, 06:52:30 am

Title: Major bitshares_toolkit flaw that needs to be solved.
Post by: dxtr on October 06, 2014, 06:52:30 am
First of all I really appreciate all that has been done to make BTSX real, I just want to throw my 2 Larimers
(and I hope they are not insignificant :D).

Let me describe an issue I find annoying when using BTSX GUI market tools:

Assume there is someone buying 1 bitGLD for 38456.78912345 BTSX and price feed is ok, and I'm willing to short that guy 1 bitGLD for this amount of BTSX.
What do I do? Simply enter those numbers in Sell Short window and expect this top position to be filled, right?
Well yes, but it's not exactly what happens.
If I do that I will short some bitGLD but not exactly 1, but something like 0.9999999999 bitGLD.
This happened to me and it's not a rare example.

Bytemaster, you claim that BTSX is different from traditional exchange in a way that you get exactly what you asked for and nothing more nor less - well that is not happening here.
For an average guy who want's to trade on a decentralized market, centralized ones like BTER are simply better for a reason they do, what you ask them to do, and not more or less so.

What I think, from my perspective of a small investor, is what needs to be done is to get rid of all floats and doubles in bitshares_toolkit code and base all blockchain variables and all arithmetics in integers. I remember it was mentioned in early stages of development, but now this problem is obvious and can not be worked around.
Right now this is something that keeps large investors looking at BTSX from safe distance, because they simply cannot put large money in something that doesn't function properly.

Bitshares is a multi-platform solution and I think every good system architect for financial applications will agree that floats simply do not work with accounting, when it comes to money you need to be accurate. Especially when designing a system that complicated and with such aspirations.

I think that this issue needs to be solved first, for investors to secure and multiply their holdings and bring large volumes in,
thus removing price feeds "scaffolding".

If there is someone who can fork toolkit code and implement this change only with a recent snapshot of BTSX then it is just a matter of time and marketing when people start packing their stuff and moving from BTSX to BTSY - It really hurts nobody, it's the opposite.

As a user of BTSX or Music or any other DAC I don't want a tool that fills only 99% of my request - that's just annoying and I don't want to loose my hair :P.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: bytemaster on October 06, 2014, 07:11:59 am
There are no doubles or floats
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: dxtr on October 06, 2014, 07:22:59 am
OK, but the problem with not filling 100% of one's order is still in place, right?

I don't know the inner workings, I thought it was float or double, because it looked like it from my ignorant perspective, sorry for that.

Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: bytemaster on October 06, 2014, 02:39:07 pm

OK, but the problem with not filling 100% of one's order is still in place, right?

I don't know the inner workings, I thought it was float or double, because it looked like it from my ignorant perspective, sorry for that.

Prices are represented as 128 bit. 64.64 fixed point.

Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: vikram on October 10, 2014, 08:24:05 pm
There are no doubles or floats

This is true of the backend where it is critical, but not yet true when reading user input. We are aware of the input issue: https://github.com/BitShares/bitshares_toolkit/issues/671 but it is not high priority. There have also been various rounding problems in the market engine which we are doing our best to eliminate.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: monsterer on October 10, 2014, 09:24:29 pm
Prices are represented as 128 bit. 64.64 fixed point.

The problem is not the representation, but the model.

Price is stored as a ratio, which means you will always have problems like this:

ratio = 1.0001
1 / ratio = 0.99990000999900009999000099990000 recurring - this cannot be stored accurately no matter the precision.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: Riverhead on October 10, 2014, 09:27:26 pm
Can you just floor or ceiling the irrational?
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: xeroc on October 10, 2014, 09:39:37 pm
Can you just floor or ceiling the irrational?
I think thats not so easy .. legally ... financial software is not supposed to round
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: monsterer on October 10, 2014, 09:41:00 pm
Can you just floor or ceiling the irrational?

You can try to round it, but really this is a patch not a fix.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: xeroc on October 10, 2014, 09:43:04 pm
You can try to round it, but really this is a patch not a fix.
I am not a CS expert ... but IMHO there just is no fix .. it's a issue of double<->float<->integer in combination with the inverse 1/x
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: monsterer on October 10, 2014, 10:22:07 pm
I am not a CS expert ... but IMHO there just is no fix .. it's a issue of double<->float<->integer in combination with the inverse 1/x

What is the reason for not storing the actual price in the market? Why not keep things simple and ignore flipped markets?
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: theoretical on October 10, 2014, 10:34:46 pm
What is the reason for not storing the actual price in the market? Why not keep things simple and ignore flipped markets?

Then you have to decide which one is "natural" and which one is "flipped".

bytemaster says the "natural" market is BTSX priced in BitUSD, because US dollars are a relatively stable and familiar unit of value.

I say the "natural" market is BitUSD priced in BTSX, because BTSX is like "real money" (a limited-issue token) and BitUSD is some kind of derivative contract.

Letting each investor have their own preferences is a compromise between these viewpoints.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: biophil on October 10, 2014, 11:02:05 pm
Can you just floor or ceiling the irrational?

You can try to round it, but really this is a patch not a fix.

I think rounding errors are considered "fees." So they're kind of good.

Sent from my SCH-S720C using Tapatalk 2

Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: jamesc on October 10, 2014, 11:02:25 pm
You have to store the fraction.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: Troglodactyl on October 10, 2014, 11:23:38 pm
This was discussed here, for reference:

https://bitsharestalk.org/index.php?topic=1890.msg26442.msg#26442
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: monsterer on October 11, 2014, 10:28:39 am
Then you have to decide which one is "natural" and which one is "flipped".

bytemaster says the "natural" market is BTSX priced in BitUSD, because US dollars are a relatively stable and familiar unit of value.

I say the "natural" market is BitUSD priced in BTSX, because BTSX is like "real money" (a limited-issue token) and BitUSD is some kind of derivative contract.

Letting each investor have their own preferences is a compromise between these viewpoints.

And that is literally the only reason for storing a ratio? Pretty *major* compromise for something so trivial.

What happens, if when down the line BTSX is valued as much as BTC you're talking about rounding off quite large sums as fees?

IMO, it looks like a bug. If you need to install confidence in the platform and attract institutional investors and big money, things like this will put them off.

Cheers, Paul.

Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: bytemaster on October 11, 2014, 10:40:13 am
Try to store and sort an order book in two different orientations and the problem is not trivial.

Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: monsterer on October 11, 2014, 12:13:26 pm
Try to store and sort an order book in two different orientations and the problem is not trivial.

I suggest ditching the flipped market. Then wont all the problems simply 'go away'?
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: xeroc on October 11, 2014, 12:48:43 pm
Try to store and sort an order book in two different orientations and the problem is not trivial.

I suggest ditching the flipped market. Then wont all the problems simply 'go away'?
yes .. but user experience will also suffer
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: monsterer on October 11, 2014, 01:11:14 pm
yes .. but user experience will also suffer

Consider an outside investor from the world of Forex. They're used to using metaquotes, you can't flip the markets, you just have to go with what each broker has listed.

Now consider an outsider from the world of crypto - same story.

In fact, flipped markets is a feature novel to bitshares, isn't it? So the only people who might miss the feature are existing users?

Cheers, Paul.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: vikram on October 11, 2014, 06:20:24 pm
What is the reason for not storing the actual price in the market? Why not keep things simple and ignore flipped markets?

Then you have to decide which one is "natural" and which one is "flipped".

bytemaster says the "natural" market is BTSX priced in BitUSD, because US dollars are a relatively stable and familiar unit of value.

I say the "natural" market is BitUSD priced in BTSX, because BTSX is like "real money" (a limited-issue token) and BitUSD is some kind of derivative contract.

Letting each investor have their own preferences is a compromise between these viewpoints.

The "natural" markets are the ones where x = asset_id(X) and y = asset_id(Y) such that x < y and thus X (e.g. BTSX) is priced in Y (e.g. USD). Everything in the backend is handled this way.

This is why USD has the highest asset id of all genesis assets, so that all other genesis assets can be priced in USD. New assets that are added to BTSX cannot be priced in USD in the backend.

The "flipped" markets are a hack we display only in the GUI, and are subject to the inversion issue:

Prices are represented as 128 bit. 64.64 fixed point.

The problem is not the representation, but the model.

Price is stored as a ratio, which means you will always have problems like this:

ratio = 1.0001
1 / ratio = 0.99990000999900009999000099990000 recurring - this cannot be stored accurately no matter the precision.
Title: Re: Major bitshares_toolkit flaw that needs to be solved.
Post by: vikram on October 16, 2014, 08:29:21 pm
What is the reason for not storing the actual price in the market? Why not keep things simple and ignore flipped markets?

Then you have to decide which one is "natural" and which one is "flipped".

bytemaster says the "natural" market is BTSX priced in BitUSD, because US dollars are a relatively stable and familiar unit of value.

I say the "natural" market is BitUSD priced in BTSX, because BTSX is like "real money" (a limited-issue token) and BitUSD is some kind of derivative contract.

Letting each investor have their own preferences is a compromise between these viewpoints.

The "natural" markets are the ones where x = asset_id(X) and y = asset_id(Y) such that x < y and thus X (e.g. BTSX) is priced in Y (e.g. USD). Everything in the backend is handled this way.

This is why USD has the highest asset id of all genesis assets, so that all other genesis assets can be priced in USD. New assets that are added to BTSX cannot be priced in USD in the backend.

The "flipped" markets are a hack we display only in the GUI, and are subject to the inversion issue:

Prices are represented as 128 bit. 64.64 fixed point.

The problem is not the representation, but the model.

Price is stored as a ratio, which means you will always have problems like this:

ratio = 1.0001
1 / ratio = 0.99990000999900009999000099990000 recurring - this cannot be stored accurately no matter the precision.

User confusion due to likely this same inversion problem: https://bitsharestalk.org/index.php?topic=8935.msg131390#msg131390