ocbc_rates: Make requests to the OCBC Rates category APIs

Description Usage Arguments Value Examples

View source: R/Rates.R

Description

This function makes the information from the OCBC Rates category APIs easily accessible in an R-readable format. There are three different types of rates, each with their own unique API
1. Fixed Deposit Rates
2. Forex Rates
3. Unit Trust Rates

Usage

1
2
3
4
5
6
ocbc_rates(
  rate_type = c("fixed deposit", "forex", "unit trust"),
  acctoken,
  local_currency = NULL,
  foreign_currency = NULL
)

Arguments

rate_type

Rate type, hence the API that the function will call from. Required. Options are "fixed deposit" for Fixed Deposit Rates, "forex" for Forex Rates, "unit trust" for Unit Trust Rates. Note: it is recommended to only specify 1 rate type at a time.

acctoken

Account token. Required. Users can sign up for their api key, api secret and account token at https://api.ocbc.com/store/home

local_currency

The currency in which the rates will be shown. Optional. Options are "SG" for Singapore and "MY" for Malaysia

foreign_currency

The currency for foreign exchange. Input the official ISO 4217 currency code (e.g GBP for British Pounds). Optional. Note: Only required for Forex Rates. If specified for Fixed Deposit and Unit Trust Rates, the foreign_currency parameter is automatically ignored.

Value

Returns various items depending on the type of rate specified
1. For Fixed Deposits the function returns a list containing a dataframe of the fixed deposit interest rates according to the duration in months as well as a graph of this information.
2. For Foreign Exchange the function returns a dataframe containing the bank buying rate and bank selling rate, information on the local currency and foreign currency as well as the rate list unit.
3. For Unit Trust the function returns an empty dataframe as this information is not yet available through the API.

Examples

1
ocbc_rates("fixed deposit", acctoken = Sys.getenv("ACC_TOKEN_OCBC"))

racheltlw/OCBCR documentation built on Dec. 16, 2019, 12:46 a.m.