Script to retrieve currency exchange rates and put them in a CSV, plus the CSV with daily data
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore COMMIT ALL THE THINGS!!! Dec 20, 2016
README.md Update README.md Jan 24, 2017
UNLICENSE Create UNLICENSE Dec 20, 2016
cron.sh
getrates.py update URL Dec 20, 2016
rates.csv [automatic commit] rates for 2018-04-14 Apr 14, 2018
requirements-fresh.txt COMMIT ALL THE THINGS!!! Dec 20, 2016
requirements.txt update dependencies Jul 14, 2018

README.md

currency-exchange-rates

Script to retrieve currency exchange rates and put them in a CSV, plus a CSV with data added every day. Attempts to have a lot of currencies.

Uses the Yahoo Finance API (which has a lot of currencies) to retrieve current exchange rates and stick them in a CSV together with the date.

This repository will be updated once in a while to include daily data.

This should not break when the world changes and currencies appear or disappear -- the script will just retrieve whatever is available and correctly merge the new data with the old CSV. (Therefore the CSV file cannot be append-only. At least it is written atomically.)

Usage

  • rates.csv: Data that falls out of the script when it is run once a day (from 2017-01-10). Example thing to do with it:

    from datetime import date
    from currency_converter import CurrencyConverter  # https://pypi.python.org/pypi/CurrencyConverter/
    URL = 'https://raw.githubusercontent.com/AnotherKamila/currency-exchange-rates/master/rates.csv'
    cc = CurrencyConverter(URL, ref_currency='USD')
    print(cc.convert(10, 'EUR', 'CHF', date=date(2016, 12, 20)))  # prints 10.69
  • getrates.py: commandline tool to retrieve the data. Make sure to install the requirements (probably in a venv). See getrates.py --help.

  • cron.sh: If your venv is called venv and the requirements are installed, this will run getrates.py and commit the updated rates.csv.

All of this is best effort: I will not be responsible if your world-domination bot makes wrong decisions because of the data/script here.

License

I believe that the currency exchange rates are public domain, correct me if I am wrong.

I unlicense everything in this repository. But it would be nice if you linked to this repo when you use it.