summaryrefslogtreecommitdiff
path: root/ledger-price-db-update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ledger-price-db-update.sh')
-rwxr-xr-xledger-price-db-update.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/ledger-price-db-update.sh b/ledger-price-db-update.sh
index 084b27c..478efb9 100755
--- a/ledger-price-db-update.sh
+++ b/ledger-price-db-update.sh
@@ -17,8 +17,18 @@ xe() {
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s=$1&f=p"
}
-usd=$(xe "USDRUB=X")
-eur=$(xe "EURRUB=X")
+print_rate() {
+ currency="$1"
+ symbol="$2"
+
+ val=$(xe "$currency=X")
+
+ test -n "$val" && echo P $(date +"%Y/%m/%d %H:%M:%S") $symbol $val R
+}
+
+{
+ print_rate "USDRUB" "\$"
+ print_rate "EURRUB" "€"
+ print_rate "PLNRUB" "P"
+} >> "$PRICE_DB_FILE"
-test -n "$usd" && echo P $(date +"%Y/%m/%d %H:%M:%S") \$ $usd R >> "$PRICE_DB_FILE"
-test -n "$eur" && echo P $(date +"%Y/%m/%d %H:%M:%S") € $eur R >> "$PRICE_DB_FILE"