Skip to content

Instantly share code, notes, and snippets.

@oscahie
Last active January 24, 2018 12:47
Show Gist options
  • Save oscahie/7c0a2ce9f23b6f248aec63b35d3b75d1 to your computer and use it in GitHub Desktop.
Save oscahie/7c0a2ce9f23b6f248aec63b35d3b75d1 to your computer and use it in GitHub Desktop.
Monitors the gate.io exchange and notifies you (via push notification, which requires a valid Pushover account) when the deposits for Bitcoin Faith (BTF) are finally open, enabling some potentially great arbitrage possibilities :)
#!/bin/bash
COIN_NAME="Bitcoin Faith"
COIN_TICKER="BTF"
EXCHANGE="gate.io"
DEPOSIT_URL=("https://gate.io/myaccount/deposit/BTF" -H "Cookie: __cfduid=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; captcha=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; market_title=BTC; captcha_reg=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; show_zero_funds=0; notice=Regarding"%"20the"%"20LLT"%"20and"%"20SNET"%"20Swap; total_fund=1; lasturl="%"2Fmyaccount"%"2Fdeposit"%"2FBTF; nav_index=2; uid=11111111; nickname=XXXXXXXX; pver=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -H "Cache-Control: max-age=0")
DEPOSIT_DISABLED="<p>BTF deposit is disabled"
function push {
curl -s -F "token=<TOKEN>" \
-F "user=<USER_KEY>" \
-F "title=$1" \
-F "message=$2" https://api.pushover.net/1/messages.json > /dev/null
}
while true
do
echo "`date` Checking..."
curl --silent --write-out '\nhttp_status_code=%{http_code}\n' "${DEPOSIT_URL[@]}" > $0.lastCheck
if [ $? -gt 0 ]; then
echo "Curl has failed to fetch the URL (error $?) - will retry after 10 secs..."
sleep 10
continue
fi
STATUS_CODE=$(grep "http_status_code=" $0.lastCheck | grep '[0-9]\{3\}' --only-matching)
if [ "$STATUS_CODE" != "200" ]; then
echo "HTTP status code was $STATUS_CODE - will retry after 10 secs..."
sleep 10
continue
fi
grep "$DEPOSIT_DISABLED" $0.lastCheck > /dev/null
if [ $? == 0 ]; then
echo "$COIN_TICKER deposits not open yet in $EXCHANGE"
sleep 60;
else
echo "Deposits of $COIN_TICKER might be now open in $EXCHANGE!!!!!"
# send push notification
push "$COIN_NAME ($COIN_TICKER)" "$COIN_TICKER deposits might be now open in $EXCHANGE"
break
fi
done
@oscahie
Copy link
Author

oscahie commented Jan 24, 2018

Note: the DEPOSIT_URL can be obtained from your browser by using the dev console (F12) while being logged-in in the exchange. This script can be modified to monitor other cryptocurrencies in other exchanges with a few minor changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment