Based on the coinmarket cap api, how do they calculate the bitcoin percent change

99 Views Asked by At

I know this isn't the correct stack exchange site for this question but this question has to do with math and creating a formula.

I am trying to figure out how coinmarketcap calculates the bitcoin percent change for other coins. For example on ethereum:

enter image description here

I'm trying to figure out how they calculate that bottom BTC percent change 3.85%.

Their api (https://api.coinmarketcap.com/v1/ticker/?limit=100) spits out this data:

{
    "id": "bitcoin", 
    "name": "Bitcoin", 
    "symbol": "BTC", 
    "rank": "1", 
    "price_usd": "8397.08", 
    "price_btc": "1.0", 
    "24h_volume_usd": "8190950000.0", 
    "market_cap_usd": "141531834530", 
    "available_supply": "16854887.0", 
    "total_supply": "16854887.0", 
    "max_supply": "21000000.0", 
    "percent_change_1h": "-0.51", 
    "percent_change_24h": "1.0", 
    "percent_change_7d": "-1.88", 
    "last_updated": "1518191066"
}, 
{
    "id": "ethereum", 
    "name": "Ethereum", 
    "symbol": "ETH", 
    "rank": "2", 
    "price_usd": "846.675", 
    "price_btc": "0.101377", 
    "24h_volume_usd": "3096660000.0", 
    "market_cap_usd": "82559453770.0", 
    "available_supply": "97510206.0", 
    "total_supply": "97510206.0", 
    "max_supply": null, 
    "percent_change_1h": "-0.2", 
    "percent_change_24h": "4.14", 
    "percent_change_7d": "-5.14", 
    "last_updated": "1518191052"
}

The first number is stated in this "percent_change_24h": "4.14" but they dont show how they came up with that second number ( 3.85% ).

Is there some formula I can create with the data they provide? The data above is all they give, so it might not be possible, I've been messing with this data trying to figure it out for a while but still no solution.

Thanks

1

There are 1 best solutions below

5
On BEST ANSWER

Let's start with their value in USD, 24 h ago:

BTC

$ (x)(1.01) = \$8397.08 \Rightarrow x = \$8313.94 $

ETH

$ (x)(1.0414) = \$846.68 \Rightarrow x = \$813.02 $


ETH/BTC 24 hours ago:

$ \frac{813.02}{8313.94}=0.097789 $


ETH/BTC NOW:

$ 0.101377 $


ETH/BTC 24hrs Change:

$(0.097789)x=0.101377 \Rightarrow = 1.03669$

Which means the increase at this point in time is: $3.669 \%$