druzsan / justetf-scraping

Scraping the justETF
MIT License
32 stars 10 forks source link

"Country" parameter does not work as expected #6

Closed andreaiacoponi closed 7 months ago

andreaiacoponi commented 7 months ago

It seems that the "Country" parameter does not work as I would have expected. Digging the code, it does not provides input data for the country field inside the etfsParams string. Because of that, it cannot be used to provide additional filtering of data based on the country of interest.

druzsan commented 7 months ago

Hi @andreaiacoponi, the country parameter sets the overall settings' country which can be found at the page's bottom (s. screenshot below). I guess it shows all the ETFs available in the country chosen regardless on fund domicile. I haven't tested it much though.

Country you mean is probably the ETF's domicile country? It can be easily get from the scraped data:

import justetf_scraping
etf_df = justetf_scraping.load_overview()
etf_df["domicile_country"].unique()
# ['Jersey', 'Ireland', 'Netherlands', 'Switzerland', 'Liechtenstein', 'Germany', 'Luxembourg', 'Bulgaria', 'France']

Filter one fund domicile country:

df = etf_df[etf_df["domicile_country"] == "Ireland"]
df
# isin         wkn    ticker valor     name                                                                     index                                     inception_date ...
# IE000GGQK173 A3D4VW R8T    125589092 abrdn Global Real Estate Active Thematics UCITS ETF USD Accumulating ETF abrdn Global Real Estate Active Thematics 2023-02-22     ...
# ...

Filter multiple fund domicile countries:

df = etf_df[etf_df["domicile_country"].isin(["Bulgaria", "Liechtenstein"])]
df
# isin         wkn    ticker valor     name                index    inception_date ...
# DE000A3GWNE8 A3GWNE VGND   <NA>      VanEck Algorand ETN Algorand 2022-03-24     ...
# ...

Although, I can easily add fund domicile to the request parameters. Please, say if you need this implemented.

settings' country

andreaiacoponi commented 7 months ago

Hi @druzsan, thanks for your replay.

I realize, should have expressed myself not clearly and I apologize for that.

The final effect I was expecting, when specifying the US as the country, is the one obtained by adding this line of code just before the end of the get_etf_params function.

etf_params += f"&country=US"

So far, I managed by hard-coding this, but it would be great if library could be updated for a more general implementation of this parameter.

druzsan commented 7 months ago

@andreaiacoponi now I got you, you mean the country targeted by ETF. It is now built in.

You can use alpha-2 country codes to get exact results:

import justetf_scraping
etf_df = justetf_scraping.load_overview(country="US")

or use the country name to fuzzy-find its code:

etf_df = justetf_scraping.load_overview(country="England")

The previous country parameter is renamed to local_country.

andreaiacoponi commented 7 months ago

Hey, thanks a lot for such a rapid fix. I will give it a try immediately. Andrea

Il giorno lun 12 feb 2024 alle ore 17:57 Alexander Druz < @.***> ha scritto:

@andreaiacoponi https://github.com/andreaiacoponi now I got you, you mean the country targeted by ETF. It is now built in.

You can use alpha-2 country codes to get exact results:

import justetf_scrapingetf_df = justetf_scraping.load_overview(country="US")

or use the country name to fuzzy-find its code:

etf_df = justetf_scraping.load_overview(country="England")

The previous country parameter is renamed to local_country.

— Reply to this email directly, view it on GitHub https://github.com/druzsan/justetf-scraping/issues/6#issuecomment-1939145636, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYN446WU6MK7NR4GMNG4KTYTJCYFAVCNFSM6AAAAABDDU63S6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZGE2DKNRTGY . You are receiving this because you were mentioned.Message ID: @.***>