Compare commits
1 Commits
d45f782a5e
...
5da11394d4
Author | SHA1 | Date | |
---|---|---|---|
5da11394d4 |
@ -4,7 +4,7 @@
|
||||
YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
|
||||
echo "Starting price tracking for $YESTERDAY" >&2
|
||||
|
||||
# Function to get and process price data for a currency
|
||||
# Fetch and process rates for a fiat currency
|
||||
get_price_data() {
|
||||
local currency=$1
|
||||
local data avg open24 last
|
||||
@ -15,7 +15,6 @@ get_price_data() {
|
||||
open24=$(echo "$data" | jq -r '.open_24')
|
||||
last=$(echo "$data" | jq -r '.last')
|
||||
avg=$(( (${open24%.*} + ${last%.*}) / 2 ))
|
||||
echo $avg
|
||||
else
|
||||
echo "ERROR: Failed to retrieve ${currency} price data" >&2
|
||||
exit 1
|
||||
@ -29,7 +28,6 @@ gbp_avg=$(get_price_data "GBP")
|
||||
|
||||
# Create JSON
|
||||
json="{\"EUR\":$eur_avg,\"USD\":$usd_avg,\"GBP\":$gbp_avg}"
|
||||
echo "Rates: $json" >&2
|
||||
|
||||
# PUT in remote storage
|
||||
response=$(curl -X PUT \
|
||||
|
Loading…
x
Reference in New Issue
Block a user