forked from webworker01/mmtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_recent_swaps
executable file
·18 lines (15 loc) · 1.14 KB
/
my_recent_swaps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
#
# Show last 10 swaps
#
# @author webworker01
# @link https://developers.atomicdex.io/basic-docs/atomicdex-api-legacy/my_recent_swaps.html
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
swapdata=$(curl -s --url "http://127.0.0.1:7783" --data '{"method":"my_recent_swaps","limit":10,"userpass":"'${userpass}'"}')
titleformat="%-6s %-38s %16s %29s %29s %20s %20s %-20s"
printf "$titleformat\n" "Type" "UUID" "Started" "Sold " "Buy " "Price (Sold/Buy)" "Price (Buy/Sold)" "Status"
printf "$titleformat\n" "----" "----" "-------" "---- " "--- " "----------------" "----------------" "------"
swaps=$(jq -rc '.result.swaps[] | [.type, .uuid, .my_info.started_at, .my_info.my_amount, .my_info.my_coin, .my_info.other_amount, .my_info.other_coin, ((.my_info.my_amount|tonumber)/(.my_info.other_amount|tonumber)), ((.my_info.other_amount|tonumber)/(.my_info.my_amount|tonumber)), .events[-1].event.type] | @tsv' <<< $swapdata)
awk '{printf("%-6s %-38s %16s %20.8f %-8s %20.8f %-8s %20.8f %20.8f %-20s\n", $1, $2, strftime("%F %R", $3), $4, $5, $6, $7, $8, $9, $10)}' <<< $swaps