open-contracting / cardinal-rs

Measure red flags and procurement indicators using OCDS data
MIT License
9 stars 3 forks source link

prepare: Add currency conversion #11

Open jpmckinney opened 1 year ago

jpmckinney commented 1 year ago

Convert amounts if there are multiple currencies.

Use same approach as in pelican-backend: https://pelican-backend.readthedocs.io/en/latest/api/util/currency_converter.html

In Pelican we convert all values to USD. This means there will be very many conversions, even if 99% of the dataset is in another currency. However, I think supporting conversion to any currency requires more API cals to fixer.io (assuming it has rates between all currency pairs – I think conversion to USD has the best coverage).

Access to conversion rates is not free, in general. This feature would need to be opt-in, with the user supplying a fixer.io API token via the configuration file. (We can consider other sources, but I think fixer is pretty good.)

Amounts are compared in the fold step, so we already need to know by that point whether conversion is required. As such, the tool will need to be instructed (via configuration) to perform conversion from the start.

The default behavior can be to warn about multiple currencies, and otherwise ignore other currencies.

jpmckinney commented 1 year ago

Setting as post-MVP, because DGCP uses the same currency for all procedures (DOP).

So does SERCOP, at least for awards/value/currency (USD).