• Short guides to forum navigation, searching, posting, translation, alerts and notifications viewable by clicking here.
  • Türk dostlarımıza hoş geldiniz Giriş burada.
  • Scammers are running ads on Facebook and Instagram claiming a giveaway. DO NOT OPEN THESE LINKS AND LOG IN. See this thread: here

[Tech note] linux 1 liner to pull coin in circulation numbers via Kinesis API (KAG KAU). No privateKey, nor publicKey needed

For how they are actually derived, see uchiki's spreadsheet method.

To simply read them, you can always just go to Explorer:
Screenshot from 2023-06-18 23-46-07.png
To pull them on automatic however, do this:

kag before kau:
Code:
linux>
q_kag=`curl -s https://api.kinesis.money/api/exchange/on-chain/circulating-supply/kag`
echo $q_kag 
3311507.1746000

q_kau=`curl -s https://api.kinesis.money/api/exchange/on-chain/circulating-supply/kau`
echo $q_kau
1242602.9868000
Muchos kewl.
For basic analysis using GNU units tool, see next post.
 
You can also do this with watcher nodes:


JSON:
{
  "ingest_latest_ledger": 26482066,
  "history_latest_ledger": 26482066,
  "history_latest_ledger_closed_at": "2023-06-18T22:23:01Z",
  "history_elder_ledger": 2,
  "records": [
    {
      "circulation": "3301707.1746000",
      "mint": "8477263.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-08T00:00:00Z"
    },
    {
      "circulation": "3304307.1746000",
      "mint": "8479863.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-09T00:00:00Z"
    },
    {
      "circulation": "3308907.1746000",
      "mint": "8484463.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-12T00:00:00Z"
    },
    {
      "circulation": "3309707.1746000",
      "mint": "8485263.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-13T00:00:00Z"
    },
    {
      "circulation": "3311507.1746000",
      "mint": "8487063.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-14T00:00:00Z"
    },
    {
      "circulation": "3307907.1746000",
      "mint": "8490463.0974000",
      "redemption": "5182555.9228000",
      "date": "2023-06-15T00:00:00Z"
    },
    {
      "circulation": "3283707.1746000",
      "mint": "8491263.0974000",
      "redemption": "5207555.9228000",
      "date": "2023-06-16T00:00:00Z"
    }
  ]
}
 
Basic analysis of coin in circulation using GNU units:

KAG
Code:
linux>
echo $q_kag 
units -t "$q_kag ozt" t
units -t "$q_kag ozt XAG (1/ozt)" "million USD"
3283707.1746000
102.13471
79.498551
ozt
t
M USD

How much volume would that take up in one location?
Code:
linux>
units -o "%-5.2f" -t "(102.13471 t / silverdensity)" "m^3"
units -o "%-5.2f" -t "(102.13471 t / silverdensity)^(1/3)" m
units -t silverdensity
9.74 
2.14 
10.49 g/cm^3 = 10490 kg / m^3

Order of (10 cubic metres) = O (10 m^3)
If melted down, this metal would fit into a cube of side 2.14 metres.
Silver is about 10 times denser than water (rounding down from 10.49).
Thus 1 cubic metre of silver weighs about 10 tonnes. Rounding-down.

Quick sanity check for volume of cube of side 2.14:
Code:
linux> bc <<< "2.14^3"
9.80
Good enough.

KAU
Code:
linux>
echo $q_kau
units -t "$q_kau g" t
units -t "$q_kau XAU (g/ozt)" "million USD"
1242602.9868000
1.242603
78.230093
g
t
M USD

How much volume would that take up in one location?
Code:
linux>
units -o "%-5.2f" -t "(1.242603 t / golddensity)" "m^3"
units -o "%-5.2f" -t "(1.242603 t / golddensity)^(1/3)" m
units -t golddensity
0.06 
0.40 
19.30 g/cm^3 = 19300 kg / m^3

linux>
qalc "1/ 0.06"
1 / 0.06 ≈ 16.66666667

About one sixteenth of a cubic metre.
If melted down, this metal would fit into a cube of side 40 centimetres.
Gold is about 19 times denser than water.
Thus 1 cubic metre of gold weighs about 20 tonnes. Rounding-up.

Oh and for newbies:
Code:
linux> units -t ozt g
31.103477
For a short skim on where and how frequently units fetches its version of spot XAG, XAU, next post:
 
You can also do this with watcher nodes:


JSON:
{
  "ingest_latest_ledger": 26482066,
  "history_latest_ledger": 26482066,
  "history_latest_ledger_closed_at": "2023-06-18T22:23:01Z",
  "history_elder_ledger": 2,
  "records": [
    {
      "circulation": "3301707.1746000",
      "mint": "8477263.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-08T00:00:00Z"
    },
    {
      "circulation": "3304307.1746000",
      "mint": "8479863.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-09T00:00:00Z"
    },
    {
      "circulation": "3308907.1746000",
      "mint": "8484463.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-12T00:00:00Z"
    },
    {
      "circulation": "3309707.1746000",
      "mint": "8485263.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-13T00:00:00Z"
    },
    {
      "circulation": "3311507.1746000",
      "mint": "8487063.0974000",
      "redemption": "5175555.9228000",
      "date": "2023-06-14T00:00:00Z"
    },
    {
      "circulation": "3307907.1746000",
      "mint": "8490463.0974000",
      "redemption": "5182555.9228000",
      "date": "2023-06-15T00:00:00Z"
    },
    {
      "circulation": "3283707.1746000",
      "mint": "8491263.0974000",
      "redemption": "5207555.9228000",
      "date": "2023-06-16T00:00:00Z"
    }
  ]
}
Ah yes:
Code:
linux>
curl -s https://kag.aboutkinesis.com/coin_in_circulation | tail -8
    {
      "circulation": "3283707.1746000",
      "mint": "8491263.0974000",
      "redemption": "5207555.9228000",
      "date": "2023-06-16T00:00:00Z"
    }
  ]
}

curl -s https://kau.aboutkinesis.com/coin_in_circulation | tail -8
 
Actually let's sidetrack again.

Instead of looking at source of XAG and XAU for GNU units (spot prices Ag Au respectively), let's go and fetch the price of KAG and KAU directly from KMS Exchange on automatic.

This does involve modifying some python and using private and public API keys. I'll include the gist of the code below.

First, we acknowledge the great work by csokun at github who is likely one of the / the (?) central workhorse (brains?) behind the whole system.

H/T his API sample python source code here

Let us now ruthlessly mangle that down to our current purposes:

fetch (get ?)
USD
P(KAG) bid ask mid
P(KAU) bid ask mid


After only a few minutes' work (thanks in large part to the clarity of csokun's skeleton example), we get:
Code:
linux> python3 Get-KAG-KAU-versus-USD-bid-mid-ask.py 
KAG_USD bid ask mid
24.3
24.31
24.3
KAU_USD bid ask mid
62.91
63.02
62.96
To compare with GNU units result for spot (not necessarily at all the same thing!):
Code:
linux>
units -t XAG USD
units -o "%5.2f" -t "XAU (g/ozt)" USD
24.21
62.96
I'll include "my" (ha!) python code minus the security parts using this snipping technique:
Code:
grep -n "def main" Get-KAG-KAU-versus-USD-bid-mid-ask.py 
linux> grep -n "def main" Get-KAG-KAU-versus-USD-bid-mid-ask.py 
92:def main():
sed -n '92,$p' Get-KAG-KAU-versus-USD-bid-mid-ask.py > demo.py
nl -ba demo.py
The nl command is just to check I cut out the sensitive security parts.
zip 'em up and away we post
Code:
linux> zip -j API-demo-`date -u +"%Y-%m-%d-T%T-%Z"`.zip demo.py
  adding: demo.py (deflated 71%)
linux> zip -sf API-demo-2023-06-19-T00\:50\:09-UTC.zip 
Archive contains:
  demo.py
Total 1 entries (785 bytes)
 

Attachments

  • API-demo-2023-06-19-T00:50:09-UTC.zip
    389 bytes · Views: 0
For a short skim on where and how frequently units fetches its version of spot XAG, XAU, next post:
Aha that's how you do a quote! You select it first while reading with the mouse (select option Quote). Then insert later when editing a post. Gotcha!

To refresh units_cur with up-to-date prices,
Code:
sudo units_cur
[SNIP]

units_cur
is part of
GNU units

If you have linux and you want to check,

Code:
man units
man units_cur
units_cur -h
more /var/lib/units/currency.units

After some sniffing around, it appears units_cur goes to packetizer by default. You can make it point elsewhere if you follow and experiment with the instructions in the man (for manual) alluded to above.

Download the python code from packetizer
Code:
wget http://services.packetizer.com/code/spotprices/spotprices.py
python3 spotprices.py
run it
Code:
linux> python3 spotprices.py
Gold: 1958.17
Silver: 24.21
Platinum: 990.55

Compare with direct calls to units:
Code:
linux> for i in XAG XAU XPT; do echo $i; units -t $i USD; done
XAG
24.21
XAU
1958.17
XPT
990.55
That's a MATCH init?
Always good when the world works rationally.
The above is for ozt in each of the precious metal types listed.

Let's switch it up a gear to find some fiat currency pairs with 1 ozt silver:
Code:
for i in AUD CAD GBP EUR USD; do echo $i; units -t XAG $i; done

AUD
35.198276
CAD
31.997762
GBP
18.931813
EUR
22.148536
USD
24.21

We follow-on that idea for 1 ozt gold.

Edit G to U
As in XAG to XAU

Which is after all the standard world-wide quoting convention.
Code:
linux> for i in AUD CAD GBP EUR USD; do echo $i; units -t XAU $i; done
AUD
2846.9314
CAD
2588.0652
GBP
1531.256
EUR
1791.4333
USD
1958.17

Divide that by 31 and a bit to standardize onto Kinesis standard gold unit KAU (1 g gold):
Code:
linux> units -t ozt
troyounce = 1|12 troypound = 0.031103477 kg
Code:
linux> for i in AUD CAD GBP EUR USD; do echo $i; units -t "XAU (g/ozt)" $i; done
AUD
91.530969
CAD
83.208228
GBP
49.231024
EUR
57.595917
USD
62.956627
"(g/ozt)" is all it took

GNU units may not be for traders but it's definitely a dream tool for analysts!
Out.
 
Ah yes:
Code:
linux>
curl -s https://kag.aboutkinesis.com/coin_in_circulation | tail -8
    {
      "circulation": "3283707.1746000",
      "mint": "8491263.0974000",
      "redemption": "5207555.9228000",
      "date": "2023-06-16T00:00:00Z"
    }
  ]
}

curl -s https://kau.aboutkinesis.com/coin_in_circulation | tail -8

Just to fiinish the job properly following up on @Derek 's suggestion:

Code:
linux> curl -s https://kag.aboutkinesis.com/coin_in_circulation | tail -8 | grep circulation | cut -d":" -f2 | sed 's/"//g' | sed 's/^ //g' | sed 's/\,$//'
3332907.1746000
linux> KAG_coin_in_circulation=` curl -s https://kag.aboutkinesis.com/coin_in_circulation | tail -8 | grep circulation | cut -d":" -f2 | sed 's/"//g' | sed 's/^ //g' | sed 's/\,$//'`
linux> echo $KAG_coin_in_circulation 
3332907.1746000

3332907.1746000

matches current number on screen here:

Screenshot from 2023-06-27 01-02-32.png


There are probably better ways of scraping the data from curl. I don't know enough about CSS / Javascript for now.

All good enough for now though to go into the tool-box.
 

Translate

Back
Top