-
Notifications
You must be signed in to change notification settings - Fork 8
/
sell
executable file
·29 lines (24 loc) · 1.24 KB
/
sell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#
# Automatically sets a taker order with miner and dex fees calculated
#
# Usage: ./sell kmd btc 0.0001 10000
# (Tries to sell 10000 KMD at a price of 0.0001 BTC/KMD)
#
# @author webworker01
# @link https://developers.atomicdex.io/basic-docs/atomicdex-api-legacy/sell.html
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
#price - the price in buycoin the user is willing to receive per one unit of the sellcoin coin
#volume - the amount of coins the user is willing to sell of the sellcoin coin
if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] || [[ -z $4 ]]; then
echo "Usage: sell <sellcoin> <buycoin> <price=buycoin/sellcoin> <volume (sellcoin)>"
exit 0
fi
coin1=${1^^}
coin2=${2^^}
minerfee=$(jq -r .result.amount <<< $(curl -s --url "http://127.0.0.1:7783" --data '{"method":"get_trade_fee","coin":"'${coin1}'","userpass":"'${userpass}'"}'))
# volume=$( printf "%.8f" $(bc -l <<< "($4 - $minerfee * 2) * (1 - 1 / 777)") )
volume=$( printf "%.8f" $(bc -l <<< "$4 * (1 - 1 / 777) - $minerfee * 2") )
jq . <<< $(curl -s --url "http://127.0.0.1:7783" --data '{"method":"sell","base":"'${coin1}'","rel":"'${coin2}'","price":"'${3}'","volume":"'${volume}'","userpass":"'${userpass}'"}')