Exchange rates can be set using external custom xrate script.


The script should be created (or uploaded) on the server as /home/ssp/private/scripts/xrate_update_custom.sh


When the script is available on the server, customers can set source of exchange rate update as Custom Script.

The script gets 2 arguments:

  • currency (string)
  • base_currency (string)


and returns:

  • rate N base_currency units per 1 currency unit (float)


Here is an example of custom script. It get the rate from Yahoo! Finance and scales it by 1.1: 

 

#!/bin/sh
#
# Scale Yahoo! Finance rate.
#
# Input arguments:
#  currency
#  base currency
# Returns:
#  exchange rate

SCALE=1.1

if [ -e /home/ssp/scripts/xrate_update_yahoo.py ]
then
  SCRIPT="/home/ssp/scripts/xrate_update_yahoo.py"
else
  SCRIPT="/home/ssp/scripts/xrate_update_yahoo.pyc"
fi

RATE=`/usr/local/bin/python "${SCRIPT}" "${@}"`

echo "scale=12; ${RATE} / ${SCALE}" | /usr/bin/bc -q