Skip to content

Instantly share code, notes, and snippets.

@raymanoz
Last active February 7, 2018 04:28
Show Gist options
  • Save raymanoz/b1722a03e6e659651d9da28ceb1a9655 to your computer and use it in GitHub Desktop.
Save raymanoz/b1722a03e6e659651d9da28ceb1a9655 to your computer and use it in GitHub Desktop.
Historical crypto value conversion. Eg get the AUD value of half a BTC on some date in the past
#!/bin/bash
ts=$(date -j -f "%Y%m%d" "$1" "+%s")
from=$2
to=$3
convert=$4
result=$(curl -s "https://min-api.cryptocompare.com/data/pricehistorical?fsym=${from}&tsyms=${to}&ts=${ts}")
toValue=$(echo ${result} | jq -r ".${from}.AUD")
echo "${to}: ${toValue}"
echo "${toValue}*${convert}" | bc
@raymanoz
Copy link
Author

raymanoz commented Feb 7, 2018

Usage:

$ ./value.sh 20170716 BTC AUD 0.0005077
AUD: 2571.8
1.3057028

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