grctest / GRC-Netdata

Netdata charts for Gridcoin
MIT License
7 stars 6 forks source link

Idea: GRC exchange rate charts #6

Closed grctest closed 7 years ago

grctest commented 7 years ago

Bash script to scrape several exchange APIs, then extract the value and volume using jq. This would effectively enable real-time charts for Gridcoin exchange rates, pretty neat!

grctest commented 7 years ago

https://github.com/grctest/GRC-Netdata/tree/master/markets

grctest commented 7 years ago

Almost have the coinmarketcap charts working, however values < 1 show as 0 (glitch!)

grctest commented 7 years ago

Most of the coinmarketcap charts are now working: http://la.grcnode.co.uk:19999/

There is still an issue displaying USD and BTC values though: https://github.com/grctest/GRC-Netdata/blob/master/markets/markets.chart.sh#L40 https://github.com/grctest/GRC-Netdata/blob/master/markets/markets.chart.sh#L41

The netdata plugin API supports only integers, but you can specify multipliers and dividers for each DIMENSION. So, to get 0.01 resolution, multiply all values sent to netdata by 100 and specify a divider of 100 at the DIMENSION lines.

The two numbers after 'absolute' are: A multiplier to multiply the original value by, and the divisor to divide the multiplied value by. Multiplying the value gets past the '0 glitch', then the division shows the full decimal place version (ie 0.001).

Regardless of what values I put in for the multiplier/divisor, the value is always shown as 0..

CHART market.price '' "Gridcoin price" "Price" GRC_Price market.price line $((load_priority + 1)) $markets_update_every
DIMENSION usd 'USD' absolute 100 100
DIMENSION btc 'BTC' absolute 100000000 1
usdVal=$(cat /home/gridcoin/.GridcoinResearch/gridcoin_cmc.json | jq '.[].price_usd')
btcVal=$(cat /home/gridcoin/.GridcoinResearch/gridcoin_cmc.json | jq '.[].price_btc')
cat /home/gridcoin/.GridcoinResearch/gridcoin_cmc.json | jq '.[].price_btc'
"0.00001302"
cat /home/gridcoin/.GridcoinResearch/gridcoin_cmc.json | jq '.[].price_usd'
"0.0157758"
BEGIN market.price
SET usd = $usdVal
SET btc = $btcVal
END

JSON Data: (jq command is correct)

[
    {
        "price_usd": "0.0107371",
        "price_btc": "0.00000950",
    }
]

Screenshot: image

grctest commented 7 years ago

https://github.com/grctest/GRC-Netdata/pull/13 fixed!