Apr 18, 2021 • Graham Higgins • ~ 3 min to read • maintenance
Execute the following:
curl -X GET https://api.freiexchange.com/public/orderbook/GAP -o freiexchange-orderbook.json
This will result in the creation of a file called freiexchange-orderbook.json
with the contents:
{
"BUY": [
{
"id": "762002",
"coin": "GAP",
"basecoin": "BTC",
"price": "0.00000078",
"amount": "48.12000000"
},
...
],
"SELL": [
{
"id": "763667",
"coin": "gap",
"basecoin": "BTC",
"price": "0.00000079",
"amount": "79.00000000"
},
...
]
}
There’ll be more. The contents shown above have been elided for brevity and presentation with ...
.
Execute the following:
cat freiexchange-orderbook.json | \
grep -v 'coin\|id' | \
sed -r 's/\s+//g' | \
tr --delete '\n' | \
sed -r 's/],/],\n/g' | \
grep -v 'BUY' | \
sed -r 's/"SELL":\[//g' | \
sed -r 's/]}//g' | \
sed -r 's/^\{//g' | \
sed -r 's/}$//g' | \
sed -r 's/},\{/\n/g' | \
sed -r 's/"price"://g' | \
sed -r 's/"amount"://g' | \
sed -r 's/"//g' | \
sed -r 's/$/\\n/g' | \
tr --delete '\n' | \
sed -r 's/^/"/g' | \
sed -r 's/$/"/g' | \
sed -r 's/\\n"$/"/' > freiexchange-orderbook.csv
This will result in the creation of a file called freiexchange-orderbook.csv
with the contents:
"0.00000079,79.00000000\n0.00000080,245.57388877\n0.00000081,81.00000000\n0.00000082,82.00000000\n
...
0.70000020,5.00000000\n0.90000020,5.00000000\n1.00000000,5.00000000\n3.00000000,0.00325577"
(Again, there’ll be more than the content shown above which has also been elided with ...
)
Using the following template:
---
layout: orderbook
title: Freiexchange order book, re-charted
description: Reasonable, significant, offers to sell on YYYY-MM-DD.
author: <Your name here>
date: YYYY-MM-DD
data: ""
btcprice: 000000
---
{% include orderbook.html %}
Copy and paste the contents of freiexchange-orderbook.csv
into the data:
field, overwriting the ""
. It should appear as a solid block of text and look like this:
---
layout: orderbook
title: Freiexchange order book, re-charted
description: Reasonable, significant, offers to sell on YYYY-MM-DD.
author: <Your name here>
date: YYYY-MM-DD
data: "0.00000079,79.00000000\n0.00000080,245.57388877\n0.00000081,81.00000000\n0.00000082,82.00000000\n...
0.70000020,5.00000000\n0.90000020,5.00000000\n1.00000000,5.00000000\n3.00000000,0.00325577"
btcprice: 000000
---
{% include orderbook.html %}
Then, change the YYYY-MM-DD
placeholders to the actual date of creation, change <Your name here>
to something else and change the BTC price to the USD value at the time of downloading the orderbook (just the integer dollar value, without the decimal/cents).
Save the entry in the _orderbook
folder as YYYY-MM-DD-freiexchange-orderbook.md
That’s it.