Browse Source

Switch to Yahoo and handle formatting problem with BRK.B

Samuel W. Flint 4 years ago
parent
commit
1987179f3d
1 changed files with 3 additions and 1 deletions
  1. 3 1
      bean-prices

+ 3 - 1
bean-prices

@@ -15,7 +15,9 @@ for line in $(cat ~/.ledger/commodities.txt ) ; do
     if [ $TYPE == 'c' ] ; then
         bean-price -e "USD:yahoo/${COMMODITY}USD=X" | sed -e 's/USD=X//' | awk -e '{printf "%s %s %s %.2f %s\n", $1, $2, $3, $4, $5}'  | tee -a ${TEMP_FILE}
     elif [ $TYPE == 's' ] ; then
-        bean-price -e "USD:iex/$COMMODITY" | awk -e '{printf "%s %s %s %.2f %s\n", $1, $2, $3, $4, $5}'  | tee -a ${TEMP_FILE}
+        ORIGCOMMODITY="$COMMODITY"
+        NEWCOMMODITY=$(echo $ORIGCOMMODITY | tr '.' '-')
+        bean-price -e "USD:yahoo/$NEWCOMMODITY" | awk -e '{printf "%s %s %s %.2f %s\n", $1, $2, $3, $4, $5}' | sed -e "s/${NEWCOMMODITY}/${ORIGCOMMODITY}/g" | tee -a ${TEMP_FILE}
     elif [ $TYPE == 'm' ] ; then
         bean-price -e "USD:oanda/${COMMODITY}_USD" | sed -e 's/_USD//' | awk -e '{printf "%s %s %s %.2f %s\n", $1, $2, $3, $4, $5}'  | tee -a ${TEMP_FILE}
     elif [ $TYPE == 'f' ] ; then