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. If end_date is omitted, only start_date is returned. The API limits the range to 367 days.

end_date

(NULL | character(1) | Date(1))
End date of the data. Requires start_date. If NULL, defaults to 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-09-16 516.15
#>  2: 2026-09-17 523.97
#>  3: 2026-09-18 527.13
#>  4: 2026-09-21 536.53
#>  5: 2026-09-22 530.81
#>  6: 2026-09-23 528.04
#>  7: 2026-09-24 529.95
#>  8: 2026-09-25 528.37
#>  9: 2026-09-28 530.05
#> 10: 2026-09-29 512.64
# }