Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get commodity prices using YFinance.jl? #17

Closed
shayandavoodii opened this issue Mar 28, 2024 · 2 comments
Closed

How to get commodity prices using YFinance.jl? #17

shayandavoodii opened this issue Mar 28, 2024 · 2 comments

Comments

@shayandavoodii
Copy link
Contributor

shayandavoodii commented Mar 28, 2024

I see you've mentioned "commodity" in the description of the repository. I checked the documentation and searched for the "Commod" term to find related documentation in this regard. Unfortunately, I didn't find any related instructions. So, I'm writing to ask for an MRE for fetching commodity prices such as Brent oil or wheat.

@eohne
Copy link
Owner

eohne commented Mar 28, 2024

Hi, so I should have been more precise. The API covers all items on Yahoo Finance including commodity futures.
To find the symbol/ticker go to finance.yahoo.com and search for the item. I guess one could also use the search function.

julia> using YFinance
julia> get_symbols("brent crude")
7-element YahooSearch{YahooSearchItem, 1}:

Symbol:  BZ=F
Name:    Brent Crude Oil Last Day Financ
Type:    FUTURE
Exch.:   NY Mercantile (NYM)


Symbol:  BZT=F
Name:    Brent Crude Oil Last Day Future
Type:    FUTURE
Exch.:   NY Mercantile (NYM)

Here are the prices for a crude oil future and a wheat future.

julia> using YFinance, DataFrames

# Brent Crude Oil Last Day (NY Mercantile)

julia> brent_oil_future = get_prices("BZ=F") |> DataFrame
4×8 DataFrame
 Row │ ticker  timestamp            open     high     low      close    adjclose  vol
     │ String  DateTime             Float64  Float64  Float64  Float64  Float64   Float64
─────┼────────────────────────────────────────────────────────────────────────────────────
   1 │ BZ=F    2024-03-25T04:00:00    85.6     87.18    85.4     86.75     86.75  21176.0
   2 │ BZ=F    2024-03-26T04:00:00    86.77    87.05    85.81    86.25     86.25  12736.0
   3 │ BZ=F    2024-03-27T04:00:00    85.97    86.36    85.18    86.09     86.09  12736.0
   4 │ BZ=F    2024-03-28T16:48:21    86.53    87.37    86.32    87.37     87.37    476.0

# Chicago SRW Wheat Futures,May-2 (CBOT)

julia> wheat_future = get_prices("ZW=F") |> DataFrame
4×8 DataFrame
 Row │ ticker  timestamp            open     high     low      close    adjclose  vol
     │ String  DateTime             Float64  Float64  Float64  Float64  Float64   Float64
─────┼────────────────────────────────────────────────────────────────────────────────────
   1 │ ZW=F    2024-03-25T04:00:00   559.0     567.0   549.5     555.0     555.0  63147.0
   2 │ ZW=F    2024-03-26T04:00:00   555.0     557.5   542.75    543.5     543.5  39839.0
   3 │ ZW=F    2024-03-27T04:00:00   543.25    549.5   538.5     547.5     547.5  39839.0
   4 │ ZW=F    2024-03-28T17:21:43   546.5     568.5   544.5     561.0     561.0  55801.0

Hope this helps.

@shayandavoodii
Copy link
Contributor Author

shayandavoodii commented Mar 29, 2024

Hi, thank you so much for your reply. The thing is that I need the spot prices of commodities. Unfortunately, the future prices don't help me in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants