Tucsky / SignificantTrades

better than 1 min chart
https://aggr.trade
GNU General Public License v3.0
623 stars 212 forks source link

Minor question #88

Open kuldeeps48 opened 4 years ago

kuldeeps48 commented 4 years ago

Screenshot_2020-04-24-12-14-23-10_3aea4af51f236e4932235fdada7d1643 Hi, As we can see, there's a transaction with 1000k value. I thought these would show up as 1 million and with cash animation? Correct me if I misunderstood.

Thanks

Tucsky commented 4 years ago

You are right, definitely an issue here Most likely a rounding error, but since I dont do any round myself, maybe its a limitation of javascript related to the number of decimal allowed

https://pastebin.com/LrPiyiV0 < theses are the trades that was in this aggregation respectively exchange | timestamp | price | size | side

So if you take thoses trades, sum the size and prices

var trades = rawPastbinOutput.split('\n').map(a => a.split(' '));
var size = trades.reduce((sum, trade) => sum + (+trade[3]), 0)
var price = trades.reduce((sum, trade) => sum + (trade[2] * trade[3]), 0) / size

You get (size * price) = 132.8170523018985 * 7529.153694263291 = 999999.9999999999

Imma investigate this but one solution could be to round the very last decimal Math.ceil(999999.9999999999 * 1000000000) / 1000000000 = 100000