boc_fx_rates: Fetch Bank of Canada foreign exchange rates

View source: R/fx-rates.R

boc_fx_ratesR Documentation

Fetch Bank of Canada foreign exchange rates

Description

Fetch the latest or historical foreign exchange reference rates from the Bank of Canada (BoC).

Usage

boc_fx_rates(start_date = NULL, end_date = NULL, limit = NULL, skip = NULL)

Arguments

start_date

(NULL | Date(1) | character(1))
Start date of the data. Default NULL.

end_date

(NULL | Date(1) | character(1))
End date of the data. Default NULL.

limit

(NULL | integer(1))
Maximum number of records to return. Default NULL (all records).

skip

(NULL | integer(1))
Number of records to skip. Default NULL (do not skip any records).

Details

The recorded rates indicate the number of Canadian dollars required to buy a single unit of the foreign currency. New rates are released by the Bank of Canada (BoC) daily at 4:30 pm. The Canada Border Services (CBSA) retrieves these updates between 4:30 pm and 5 pm ET.

BoC provides 23 foreign exchange rates. All other rates are maintained by the CBSA.

Exchange rates from the BoC are updated daily in the system while other exchange rates are updated by the CBSA at set intervals. The updated rates are available for retrieval between 7 pm and 11:59 pm ET.

As BoC publishes exchange rates every business day, it is recommended that exchange rate data be retrieved on a daily basis. This retrieval should occur after 7 pm ET to ensure retrieval of the latest updates.

Value

A data.table::data.table() with the exchange rates.

Source

https://www.cbsa-asfc.gc.ca/eservices/api/er-tc-api-eng.html

Examples



# fetch latest exchange rates
boc_fx_rates()

# fetch historical exchange rates
boc_fx_rates(start_date = "2021-10-22", end_date = "2021-10-23", limit = 10, skip = 2)



bbk documentation built on Nov. 5, 2025, 6:07 p.m.