Currency Conversion#


Introduction:#


The oasislmf package can handle the conversion of relevant columns of the oed files to a consistent reporting currency. The package will reference exchange rates either form a user supplied exchange rate table (dictionary based) , or from an external API (FX).

File Based Currency Conversion#


DictBasedCurrencyRates is a solution where all the rate are provided via files and stored internally in the package as a dictionary.

Oasis LMF supports csv file (compressed or not) or a parquet file where they will be read as DataFrame. The file is referenced using a JSON configuration file with the --currency_conversion_json flag :

{
    "currency_conversion_type": "DictBasedCurrencyRates",
    "source_type": "csv",
    "file_path": "tests/inputs/roe.csv"
}

note, you should use "source_type": "parquet" if parquet file is used

The expected format is (roe being a float in parquet format):

cur_from

cur_to

roe

USD

GBP

0.85

USD

EUR

0.95

GBP

EUR

1.12


Rate can also be passed directly in currency_conversion_json with type dict ex:

{
    "currency_conversion_type": "DictBasedCurrencyRates",
    "source_type": "dict",
    "currency_rates": [
        ["USD", "GBP", 0.85],
        ["USD", "EUR", 0.95],
        ["GBP", "EUR", 1.12]
        ]
}

When looking for a key pair, DictBasedCurrencyRates checks first for the key pair (cur1, cur2) then for (cur2, cur1). So if a Currency pairs is only specified one way (ex: GBP=>EUR) then it is automatically assume that roe EUR=>GBP = 1/(roe GPB=>EUR)

if a currency pair is missing ValueError(f”currency pair {(cur_from, cur_to)} is missing”) is thrown

FX Currency Rates#


OasisLMF also lets you use the external package forex-python to perform the conversion. A date may be specified in ISO 8601 format (YYYY-MM-DD) currency_conversion_json:

{
    "currency_conversion_type": "FxCurrencyRates",
    "datetime": "2018-10-10"
}

Reporting Currency#


The desired reporting currency will also need to be specified when running the oasislmf package. To do this, the user should enter the currecny code using the --reporting-currency flag

MDK#


To run the currency conversion as part of the MDK then, the user should use a command as follows:

oasislmf model run
    --config oasislmf.json
    --currency-conversion-json currency_settings.json
    --reporting-currency GBP

Note that this will create and use a copy of the original OED input files with the currency fields converted. It will also store the original currency and the rate of exchange used in the new OED file for reference.