Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
modGateway="BFGMPykfKxXZ1otrCZcsbnTwJjKHPP9dsP" # mod poloniex NuBot; https://discuss.nubits.com/t/passed-nbt-exit-gateway-on-poloniex-provided-by-masterofdisaster/3107
zoroGateway="BJs4YbtaqCmxeHLiR6zzjnZEotYVFAPfMo" # zoro poloniex NuBot; https://discuss.nubits.com/t/passed-dual-side-nubot-gateway-in-poloniex-by-zoro/3395
cybnateGateway="B954pkUEdkeT1G5Lq14Cisij5no3RVxHYe" # Cybnate poloniex PyBot; https://discuss.nubits.com/t/passed-dual-side-pybot-gateway-on-poloniex-and-bittrex/3412/27
modSellSideGateways="BETwD8nSjtj9ADSvej2na34xmsMYwPRymv" # mod sells side gateways;
huafeiBter="BRUuKfGur7CZSLy65gYUPJUQyQZeT1XQnD" # huafei Bter sell side NuBot; https://discuss.nubits.com/t/sell-side-bter-com-huafei/3713/
gw1_array=(
$modGateway
$zoroGateway
$modSellSideGateways
$huafeiBter
)
gw2_array=(
$cybnateGateway
)
# gather information for gateways, which use dedicated liquidity broadcast addresses
n=0
p=0
for gw in "${gw1_array[@]}"
do
liq=`./nud getliquidityinfo B | grep "${gw1_array[$n]}" -A 2 | awk '{print $3}'`
read -r -a array <<< $liq
# split strings and use only the number in front of the decimal
buy1[$p]=`echo ${array[1]} | awk -F'.' '{print $1}'`
((p++))
ask1[$p]=`echo ${array[2]} | awk -F'.' '{print $1}'`
((n++))
done
# put liquidity values in array
buyIndex=0
for i in "${buy1[@]}"
do
buyTotal[$buyIndex]="$i"
((buyIndex++))
done
askIndex=0
for i in "${ask1[@]}"
do
askTotal[$askIndex]="$i"
((askIndex++))
done
# gather information for @Cybnate's gateway, which uses the liquidity broadcast address for other operations as well
n=0
p=0
for gw in "${gw2_array[@]}"
do
liq=`./nud getliquiditydetails B | grep "${gw2_array[$n]}" -A 20 | grep poloniex -A 2 | awk '{print $3}'`
read -r -a array <<< $liq
# split strings and use only the number in front of the decimal
buy2[$p]=`echo ${array[1]} | awk -F'.' '{print $1}'`
((p++))
ask2[$p]=`echo ${array[2]} | awk -F'.' '{print $1}'`
# ((n++))
liq=`./nud getliquiditydetails B | grep "${gw2_array[$n]}" -A 20 | grep bittrex -A 2 | awk '{print $3}'`
read -r -a array <<< $liq
# split strings and use only the number in front of the decimal
buy2[$p]=`echo ${array[1]} | awk -F'.' '{print $1}'`
((p++))
ask2[$p]=`echo ${array[2]} | awk -F'.' '{print $1}'`
((n++))
done
# put liquidity values in array
for i in "${buy2[@]}"
do
buyTotal[$buyIndex]="$i"
((buyIndex++))
done
for i in "${ask2[@]}"
do
askTotal[$askIndex]="$i"
((askIndex++))
done
# sum liquidity values up
#buySumGw=0
for i in "${buyTotal[@]}"
do
buySumGw="$(($buySumGw+$i))"
done
#askSumGw=0
for i in "${askTotal[@]}"
do
askSumGw="$(($askSumGw+$i))"
done
# retrieve alix json data
alix=`curl -i https://alix.coinerella.com/walls/?json 2>/dev/null`
# split data into array
i=0
for element in ${alix//,/ } ; do
alix_array[$i]="$element"
((i++))
done
# find the relevant index numbers in alix_array
max_index=${#alix_array[@]}
min15_ask=$(($max_index-12))
min15_bid=$(($max_index-11))
min15_tot=$(($max_index-10))
h4_ask=$(($max_index-6))
h4_bid=$(($max_index-5))
h4_tot=$(($max_index-4))
# retrieve integer values from alix alp data
ask15minAlp=`echo ${alix_array[$min15_ask]} | awk -F':' '{print $3}' | awk -F'.' '{print $1}'`
buy15minAlp=`echo ${alix_array[$min15_bid]} | awk -F':' '{print $2}' | awk -F'.' '{print $1}'`
tot15minAlp=`echo ${alix_array[$min15_tot]} | awk -F':' '{print $2}' | awk -F'.' '{print $1}'`
ask4hAlp=`echo ${alix_array[$h4_ask]} | awk -F':' '{print $3}' | awk -F'.' '{print $1}'`
buy4hAlp=`echo ${alix_array[$h4_bid]} | awk -F':' '{print $2}' | awk -F'.' '{print $1}'`
tot4hAlp=`echo ${alix_array[$h4_tot]} | awk -F':' '{print $2}' | awk -F'.' '{print $1}'`
# print gateway liquidity values
totalSumGw=$(($buySumGw+$askSumGw))
buyRatioGw=$((100*$buySumGw/$totalSumGw))
askRatioGw=$((100*$askSumGw/$totalSumGw))
# print ALP liquidity values
echo "## [Liquidity; ALix T1 + gateways (poloniex dual side, numerous sell side)](https://gist.github.com/Lamz0rNewb/a76776a50fa8476667ea): "
echo "[quote]"
date
echo "###"
echo "status of the gateways in total:"
echo "bid total" $buySumGw" USD, bid side ratio" $buyRatioGw"%"
echo "ask total" $askSumGw" USD, ask side ratio" $askRatioGw"%"
echo "###"
echo "status of the ALP last 15 minutes:"
echo "bid total" $buy15minAlp" USD, bid side ratio" $((100*$buy15minAlp/$tot15minAlp))"%"
echo "ask total" $ask15minAlp" USD, ask side ratio" $((100*$ask15minAlp/$tot15minAlp))"%"
echo
echo "status of the ALP last 4 hours:"
echo "bid total" $buy4hAlp" USD, bid side ratio" $((100*$buy4hAlp/$tot4hAlp))"%"
echo "ask total" $ask4hAlp" USD, ask side ratio" $((100*$ask4hAlp/$tot4hAlp))"%"
echo "###"
# print liquidity values on the whole
totBuy4h=$(($buy4hAlp+$buySumGw))
totAsk4h=$(($ask4hAlp+$askSumGw))
totSum4h=$(($totBuy4h+$totAsk4h))
totBuy15min=$(($buy15minAlp+$buySumGw))
totAsk15min=$(($ask15minAlp+$askSumGw))
totSum15min=$(($totBuy15min+$totAsk15min))
echo "status of the total liquidity; gateways and ALP (last 15 minutes):"
echo "bid total **"$totBuy15min" USD**, bid side ratio **"$((100*$totBuy15min/$totSum15min))"%**"
echo "ask total **"$totAsk15min" USD**, ask side ratio **"$((100*$totAsk15min/$totSum15min))"%**"
echo
echo "status of the total liquidity; gateways and ALP (last 4 hours):"
echo "bid total **"$totBuy4h" USD**, bid side ratio **"$((100*$totBuy4h/$totSum4h))"%**"
echo "ask total **"$totAsk4h" USD**, ask side ratio **"$((100*$totAsk4h/$totSum4h))"%**"
echo "[/quote]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment