Wednesday, August 9, 2017

Bash (Unix shell): Converting Bitcoin Cash Amount to Yen

Command:

$ cat ./cryptocurrency_price_bittrex.sh


Result:

#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 PAIR AMOUNT" >&2
exit 1
fi

pair=$1;
amount=$2;
yenrate=$(curl -s "https://coincheck.com/api/rate/BTC_JPY" | python -c "import sys, json; print json.load(sys.stdin)['rate']");
curl -s "https://bittrex.com/api/v1.1/public/getticker?market=$pair" | python -c "import sys, json; print float(json.load(sys.stdin)['result']['Last']) * float(sys.argv[1]) * float(sys.argv[2])" $amount $yenrate


Command (How many Yen for 0.19 Bitcoin Cash):

$ ./cryptocurrency_price_bittrex.sh BTC-BCC 0.19


Result:

7461.446566

Tuesday, August 1, 2017

Pyocotan (ピョコタン): 喫茶店でニコ生してたら「高校生の頃からずっとファンです」という巨乳美女が突然やってきた!!【現代版ツルの恩返し】【ピョコタン】

Bash (Unix shell): Getting Cryptocurrency Price Using API

Command:

$ cat cryptocurrency_price.sh


Result:

#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 PAIR AMOUNT" >&2
exit 1
fi
pair=$1; amount=$2; curl -s "https://coincheck.com/api/rate/$pair" | python -c "import sys, json; print float(json.load(sys.stdin)['rate']) * float(sys.argv[1])" $amount


Command:

$ ./cryptocurrency_price.sh


Result:

Usage: ./cryptocurrency_price_jpy.sh PAIR AMOUNT


Command:

$ ./cryptocurrency_price.sh btc_jpy 1


Result:

318146.0


Command:

$ ./cryptocurrency_price_jpy.sh eth_jpy 13.5


Result:

303218.972773


Command:

$ ./cryptocurrency_price_jpy.sh xem_jpy 1000


Result:

18703.59758