2020-12-01 12:01:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
source scripts/maxapi.sh
|
|
|
|
|
|
|
|
|
|
|
|
command=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
case "$command" in
|
|
|
|
market)
|
|
|
|
market=$1
|
|
|
|
side=$2
|
|
|
|
volume=$3
|
|
|
|
|
|
|
|
if [[ $# < 3 ]] ; then
|
|
|
|
echo "$0 market [market] [side] [volume]"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
declare -A order_params=()
|
|
|
|
order_params[market]=$market
|
|
|
|
order_params[side]=$side
|
|
|
|
order_params[volume]=$volume
|
|
|
|
order_params[ord_type]="market"
|
|
|
|
submitOrder order_params
|
|
|
|
;;
|
|
|
|
|
2021-03-13 12:49:36 +00:00
|
|
|
deposits)
|
|
|
|
declare -A params=()
|
|
|
|
currency=$1
|
|
|
|
if [[ -n $currency ]] ; then
|
|
|
|
params[currency]=$currency
|
|
|
|
fi
|
|
|
|
|
|
|
|
deposits params \
|
2021-03-14 02:42:11 +00:00
|
|
|
| jq -r '.[] | [ .uuid, .txid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \
|
2021-03-13 12:49:36 +00:00
|
|
|
| column -ts $'\t'
|
|
|
|
;;
|
|
|
|
|
|
|
|
withdrawals)
|
|
|
|
declare -A params=()
|
|
|
|
currency=$1
|
|
|
|
if [[ -n $currency ]] ; then
|
|
|
|
params[currency]=$currency
|
|
|
|
fi
|
|
|
|
|
|
|
|
withdrawals params \
|
2021-03-14 02:42:11 +00:00
|
|
|
| jq -r '.[] | [ .uuid, .txid, ((.amount | tonumber) * 10000 | floor / 10000), .currency, ((.fee | tonumber) * 10000 | floor / 10000), .fee_currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \
|
2021-03-09 05:19:08 +00:00
|
|
|
| column -ts $'\t'
|
|
|
|
;;
|
|
|
|
|
2020-12-01 12:01:50 +00:00
|
|
|
limit)
|
|
|
|
market=$1
|
|
|
|
side=$2
|
|
|
|
price=$3
|
|
|
|
volume=$4
|
2020-12-01 12:03:54 +00:00
|
|
|
|
|
|
|
if [[ $# < 4 ]] ; then
|
|
|
|
echo "$0 limit [market] [side] [price] [volume]"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-12-01 12:01:50 +00:00
|
|
|
declare -A order_params=()
|
|
|
|
order_params[market]=$market
|
|
|
|
order_params[side]=$side
|
|
|
|
order_params[price]=$price
|
|
|
|
order_params[volume]=$volume
|
|
|
|
order_params[ord_type]="limit"
|
|
|
|
submitOrder order_params
|
|
|
|
;;
|
|
|
|
|
|
|
|
me)
|
2020-12-01 12:25:45 +00:00
|
|
|
me | jq -r '.accounts[] | select(.balance | tonumber > 0.0) | "\(.currency)\t\(.balance) \t(\(.locked) locked)"'
|
2020-12-01 12:01:50 +00:00
|
|
|
;;
|
|
|
|
|
2020-12-01 12:07:13 +00:00
|
|
|
# open orders
|
|
|
|
open)
|
2020-12-01 12:03:54 +00:00
|
|
|
if [[ $# < 1 ]] ; then
|
2020-12-01 12:07:13 +00:00
|
|
|
echo "$0 open [market]"
|
2020-12-01 12:03:54 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-12-01 12:01:50 +00:00
|
|
|
market=$1
|
|
|
|
declare -A orders_params=()
|
|
|
|
orders_params[market]=$market
|
2020-12-03 01:25:26 +00:00
|
|
|
myOrders orders_params | \
|
|
|
|
jq -r '.[] | "\(.id) \(.market) \(.side) \(.ord_type) \(if .ord_type | test("stop") then "stop@" + .stop_price else "" end) price = \(if .ord_type | test("market") then "any" else .price end) \t volume = \(.volume) \(.state)"'
|
2020-12-01 12:01:50 +00:00
|
|
|
;;
|
2020-12-02 01:40:27 +00:00
|
|
|
|
|
|
|
cancel)
|
|
|
|
if [[ $# < 1 ]] ; then
|
|
|
|
echo "$0 cancel [oid]"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
order_id=$1
|
|
|
|
cancelOrder $order_id
|
|
|
|
;;
|
2021-01-15 03:10:43 +00:00
|
|
|
|
|
|
|
rewards)
|
|
|
|
declare -A rewards_params=()
|
|
|
|
currency=$1
|
|
|
|
if [[ -n $currency ]] ; then
|
|
|
|
rewards_params[currency]=$currency
|
|
|
|
fi
|
2021-02-02 09:26:35 +00:00
|
|
|
|
2021-01-15 03:10:43 +00:00
|
|
|
# rewards rewards_params | jq -r '.[] | "\(.type)\t\((.amount | tonumber) * 1000 | floor / 1000)\t\(.currency) \(.state) \(.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z"))"'
|
2021-02-02 09:26:35 +00:00
|
|
|
rewards rewards_params | jq -r '.[] | [ .uuid, .type, ((.amount | tonumber) * 10000 | floor / 10000), .currency, .state, (.created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z")), .note ] | @tsv' \
|
2021-01-15 03:10:43 +00:00
|
|
|
| column -ts $'\t'
|
|
|
|
;;
|
2021-03-09 05:19:08 +00:00
|
|
|
|
2020-12-01 12:01:50 +00:00
|
|
|
trades)
|
2020-12-01 12:03:54 +00:00
|
|
|
if [[ $# < 1 ]] ; then
|
|
|
|
echo "$0 trades [market]"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-12-01 12:01:50 +00:00
|
|
|
market=$1
|
|
|
|
declare -A trades_params=()
|
|
|
|
trades_params[market]=$market
|
2020-12-02 08:56:04 +00:00
|
|
|
myTrades trades_params | \
|
2020-12-17 09:35:24 +00:00
|
|
|
jq -r '.[] | "\(.id) \(.market) \(.side) \(.price) \t \(.volume) amount = \((.price | tonumber) * (.volume | tonumber) * 100 | floor / 100) \t fee = \( .fee // 0 | tonumber * 100000 | floor / 100000 ) \(.fee_currency)\t\( .created_at | strflocaltime("%Y-%m-%dT%H:%M:%S %Z") )"'
|
2020-12-01 12:01:50 +00:00
|
|
|
;;
|
|
|
|
esac
|