getPriceAdaArs.sh 531 B

12345678910111213
  1. #!/usr/bin/env bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. #set -x
  6. DATE_START=$(date +%FT%H:%M)
  7. DATE_END=$(date +%FT%H:%M --date="next minute")
  8. ADA_PRICE=$(curl -s "https://production.api.coindesk.com/v2/price/values/ADA?start_date=${DATE_START}&end_date=${DATE_END}&ohlc=false" | jq '.data.entries[][1]')
  9. USD_PRICE=$(curl -s "https://mercados.ambito.com//dolar/informal/variacion" | jq '.venta' | tr -d '"' | sed 's:\,[^|]*::g')
  10. ADA_PRICE_ARS=$(echo "${ADA_PRICE}*${USD_PRICE}" | bc)
  11. printf "%0.0f\n" "${ADA_PRICE_ARS}"