Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions mybalance_pad.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
source userpass

# Simplified table view of the enabled coins
# ---------------------------------------------------

ENABLED_COINS=$(curl -Ss --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"get_enabled_coins\"}");

for k in $(jq '.result | keys | .[]' <<< "$ENABLED_COINS"); do

ticker=$(jq -r ".result[$k] | .ticker" <<< "$ENABLED_COINS");
mybalance=$(curl -Ss --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"my_balance\",\"coin\":\"$ticker\"}");
ENABLED_COINS=$(jq -r ".result[$k].mybalance |= . + $mybalance" <<< "$ENABLED_COINS");
done

BALANCES=$(jq -r '

def width: map( . | map(length) | max) | max ;
def pad($w): . + (($w-length)*" ") ;
def padnum($w): ( . |tonumber as $b | $b|floor as $n | ($b - $n) as $f | if $f == 0 then "0.0" else $f end | . as $f | (20 - ($f|tostring|length|tonumber)) as $l | ($f|tostring + ($l*"0")) | ltrimstr("0") as $f | (10 - ($n|tostring|length|tonumber)) as $l | (($l*" ") + ($n|tostring)) as $n | ($n + $f) | . ) ;

[.result | .[] | .mybalance]
| . as $mb |
([
( [ $mb | .[] | {"address"}] | width as $w | map({ address: .address|pad($w) }) ),
( [ $mb | .[] | {"coin"}] | width as $w | map({ coin: .coin|pad($w) }) ),
( [ $mb | .[] | {"balance"}] | width as $w | map({ balance: .balance|padnum($w) }) ),
( [ $mb | .[] | {"unspendable_balance"}] | width as $w | map({ unspendable_balance: .unspendable_balance|pad($w) }) )
])
| [transpose | .[] | add] | sort_by(.coin) | .[] | flatten | @tsv

' <<< "$ENABLED_COINS");

printf "\n";
printf "Address Coin Balance Unspendable\n";
printf "%s-----------------------------------------------------------------------------------------\n";
printf "$BALANCES";
printf "\n";
printf "\n";

30 changes: 30 additions & 0 deletions mybalance_tab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
source userpass

# Simplified table view of the enabled coins
# ---------------------------------------------------

ENABLED_COINS=$(curl -Ss --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"get_enabled_coins\"}");

for k in $(jq '.result | keys | .[]' <<< "$ENABLED_COINS"); do

ticker=$(jq -r ".result[$k] | .ticker" <<< "$ENABLED_COINS");
mybalance=$(curl -Ss --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"my_balance\",\"coin\":\"$ticker\"}");
ENABLED_COINS=$(jq -r ".result[$k].mybalance |= . + $mybalance" <<< "$ENABLED_COINS");
done

ENABLED_COINS=$(jq -r '

[.result | .[] | .mybalance]
| map({address: .address,coin: .coin|tostring, balance: .balance|tonumber})
| sort_by(.coin) | .[] | flatten | @tsv

' <<< "$ENABLED_COINS");

printf "\n";
printf "Address Coin Balance\n";
printf "%s----------------------------------------------------------------------\n";
printf "$ENABLED_COINS";
printf "\n";
printf "\n";

38 changes: 38 additions & 0 deletions myorders_tab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
source userpass

# Simplified table view of my orders
# ----------------------------------
# - no param provided
# - first param provided
# - first and second param provided

MY_ORDERS=$(curl -Ss --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"my_orders\"}");

printf "%s\n";
printf "%sUUID Base Rel Price Volume \n";
printf "%s--------------------------------------------------------------------------\n";

# var1 unset = no params provided -> list all records
if [ -z "$1" ]; then

printf $MY_ORDERS | jq ".result.maker_orders | [map(.) | .[] | {uuid: .uuid, base: .base, rel: .rel, price: .price|tonumber, amount: .available_amount|tonumber}] | sort_by(.price) | sort_by(.rel) | sort_by(.base)" | jq -r '.[]|flatten|@tsv';
printf "%s\n";
exit 0;
fi

# var2 unset = one param provided -> list var1 found in records
if [ -z "$2" ]; then

printf $MY_ORDERS | jq ".result.maker_orders | [map(.) | .[] | {uuid: .uuid, base: .base, rel: .rel, price: .price|tonumber, amount: .available_amount|tonumber}] | sort_by(.price) | sort_by(.rel) | sort_by(.base) | .[] | select(.base==\"$1\" or .rel==\"$1\")" | jq -r 'flatten|@tsv';
printf "%s\n";

# var2 set = two params provided -> list var1/var2 pair records
else

printf $MY_ORDERS | jq ".result.maker_orders | [map(.) | .[] | {uuid: .uuid, base: .base, rel: .rel, price: .price|tonumber, amount: .available_amount|tonumber}] | sort_by(.price) | sort_by(.rel) | sort_by(.base) | .[] | select(.base==\"$1\" and .rel==\"$2\")" | jq -r 'flatten|@tsv';
printf "%s\n";

fi


19 changes: 19 additions & 0 deletions orderbook_tab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
source userpass

# Simplified table view of the orderbook
# ---------------------------------------------------
# Adding trailing zeros to price needs to be improved

ORDERBOOK=$(curl -Ss --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"$1\",\"rel\":\"$2\"}");

#printf "$ORDERBOOK";

printf "%s\n";
printf "%sAddress Coin Price Max. Volume \n";
printf "%s--------------------------------------------------------------------------------\n";
printf "$ORDERBOOK" | jq ".asks | [map(.) | .[] | {address: .address, coin: .coin, price: (((.price|tonumber + 0.0000000001) * 10000000000)|round | . / 10000000000), maxvol: ((.maxvolume|tonumber * 1000000)|round| . / 1000000)}]" | jq -r '.[]|flatten|@tsv'
printf "%s--------------------------------------------------------------------------------\n";
printf "$ORDERBOOK" | jq ".bids | [map(.) | .[] | {address: .address, coin: .coin, price: (((.price|tonumber + 0.0000000001) * 10000000000)|round | . / 10000000000), maxvol: ((.maxvolume|tonumber * 1000000)|round| . / 1000000)}]" | jq -r '.[]|flatten|@tsv'
printf "%s\n";