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

Wrong aggregation #26

Closed
snvv opened this issue Jun 6, 2024 · 3 comments
Closed

Wrong aggregation #26

snvv opened this issue Jun 6, 2024 · 3 comments
Assignees

Comments

@snvv
Copy link

snvv commented Jun 6, 2024

Hello,
When I download weekly data with how_to_aggregate = "last" for the GEKTERNA.AT ticker the closing prices are wrong
Thank you

@msperlin msperlin self-assigned this Jun 6, 2024
@msperlin
Copy link
Collaborator

msperlin commented Jun 6, 2024

Hi snvv,

Can you provide a reproducible code, please?
Why you think prices are wrong?

@snvv
Copy link
Author

snvv commented Jun 6, 2024

Hello,

Using the following code:

library(yfR)

# Set options for algorithm
my_ticker <- 'GEKTERNA.AT'
first_date <- Sys.Date() - 360
last_date <- Sys.Date()

# Fetch data
df_yf <- yf_get(
  tickers = my_ticker, 
  freq_data = "weekly",
  first_date = first_date,
  last_date = last_date
)

# Output is a tibble with data
tail(df_yf)

I get:

> tail(df_yf)
# A tibble: 6 × 11
  ticker      ref_date   volume price_open price_high price_low price_close price_adjusted
  <chr>       <date>      <dbl>      <dbl>      <dbl>     <dbl>       <dbl>          <dbl>
1 GEKTERNA.AT 2024-04-29 426305       16.8       16.9      16.4        16.6           16.6
2 GEKTERNA.AT 2024-05-08 261453       16.7       16.9      16.5        16.9           16.9
3 GEKTERNA.AT 2024-05-13 566573       16.8       16.9      16.1        16.4           16.4
4 GEKTERNA.AT 2024-05-20 345089       16.6       16.9      16.2        16.7           16.7
5 GEKTERNA.AT 2024-05-27 472400       16.6       16.9      16.4        16.8           16.8
6 GEKTERNA.AT 2024-06-03 287244       16.7       16.9      16.4        16.8           16.8
# ℹ 3 more variables: ret_adjusted_prices <dbl>, ret_closing_prices <dbl>,
#   cumret_adjusted_prices <dbl>

However the closing prices from the Yahoo site for specific dates are:

  • Jun 3, 2024: 16.74
  • May 27, 2024: 16.60
  • May 20, 2024: 16.50
  • etc.

Best regards

@msperlin
Copy link
Collaborator

msperlin commented Jun 6, 2024

Unfortinately, I can't help. This is certantly an issue with Yahoo site. The yfR is imported using quantmod::get_symbols(), which in turn grabs it from the json api endpoint https://query2.finance.yahoo.com/v8/finance/chart/:

image

As yfR developer, I have no control or knowledge of how the data from the yahoo site is organized.

@msperlin msperlin closed this as completed Jun 6, 2024
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