timmolter/XChange — pull request #351 by whitslack (2014-03-06 13:17:49+00:00)
Title: correct scaling routines in CoinfloorUtils

The scaling factors were wrong. Coinfloor scales BTC quantities by 10000 and GBP quantities by 100. Prices are expressed in units of the counter asset per unit of the base asset and then scaled by 10000.

> Ƀ12.3456 <=> 123456
> £987.65 <=> 98765
> £512.34/BTC <=> 51234

To understand the last line, consider that £512.34 is 51234 units of the GBP currency, and Ƀ1 is 10000 units of the BTC currency. Divide 51234 by 10000, and you get a price of 5.1234. Scale this price by 10000, and you get 51234, which is how Coinfloor expresses this price.

As another illustrative example, consider a hypothetical future in which Coinfloor adds support for JPY with a scaling factor of 1 and DOGE with a scaling factor of 100. Then:

> Đ1234.56 <=> 123456
> ¥98765 <=> 98765
> ¥5.1234/DOGE <=> 51234

¥5.1234 is 512.34 units of the JPY currency, and Đ1 is 100 units of the DOGE currency. Divide 512.34 by 100, and you get a price of 5.1234. Scale this price by 10000, and you get 51234.