Skip to contents

Retrieve the price of gold from the NBP Web API.

Usage

nbp_gold(start_date = NULL, end_date = NULL, last_n = NULL)

Arguments

start_date

(NULL | character(1) | Date(1))
Start date of the data. Must be given together with end_date; the API limits the range to 367 days. For a single day, pass the same date as start_date and end_date.

end_date

(NULL | character(1) | Date(1))
End date of the data. Must be given together with start_date.

last_n

(NULL | integer(1))
Return only the last n quotations.

Value

A data.table::data.table() with gold prices.

Examples

# \donttest{
nbp_gold(last_n = 10L)
#>           date  price
#>         <Date>  <num>
#>  1: 2026-08-03 488.51
#>  2: 2026-08-04 487.08
#>  3: 2026-08-05 488.36
#>  4: 2026-08-06 499.12
#>  5: 2026-08-07 512.07
#>  6: 2026-08-10 516.60
#>  7: 2026-08-11 520.12
#>  8: 2026-08-12 523.42
#>  9: 2026-08-13 527.80
#> 10: 2026-08-14 525.53
# }