MCPcopy
hub / github.com/JerBouma/FinanceDatabase / select

Method select

financedatabase/ETFs.py:25–167  ·  view source on GitHub ↗

Retrieve ETF data based on specified criteria. This method allows you to retrieve data for specific ETFs based on a combination of category group, category, and family filters. You can also exclude exchanges from the search. If no input criteria are provided, it ret

(
        self,
        category_group: str | list | None = None,
        category: str | list | None = None,
        family: str | list | None = None,
        currency: str | list | None = None,
        exchange: str | list | None = None,
        mic: str | list | None = None,
        only_primary_listing: bool = False,
    )

Source from the content-addressed store, hash-verified

23 FILE_NAME = "etfs.bz2"
24
25 def select(
26 self,
27 category_group: str | list | None = None,
28 category: str | list | None = None,
29 family: str | list | None = None,
30 currency: str | list | None = None,
31 exchange: str | list | None = None,
32 mic: str | list | None = None,
33 only_primary_listing: bool = False,
34 ) -> FinanceFrame:
35 """
36 Retrieve ETF data based on specified criteria.
37
38 This method allows you to retrieve data for specific ETFs based on a combination
39 of category group, category, and family filters. You can also exclude
40 exchanges from the search. If no input criteria are provided, it returns data for all ETFs.
41
42 Args:
43 category_group (str | list, optional): Specific category group to filter ETFs.
44 If not provided, returns data for all category groups.
45 category (str | list, optional): Specific category to filter ETFs.
46 If not provided, returns data for all categories.
47 family (str | list, optional): Specific family to filter ETFs.
48 If not provided, returns data for all families.
49 currency (str | list, optional): Specific currency to filter ETFs.
50 If not provided, returns data for all currencies.
51 exchange (str | list, optional): Specific exchange to filter ETFs.
52 If not provided, returns data for all exchanges.
53 mic (str | list | None): Specific ISO 10383 MIC code or list of MIC codes to filter
54 ETFs. If not provided, returns data for all MIC codes.
55 only_primary_listing (bool, optional): If True, returns only primary listings.
56 Default is False, which returns all listings.
57
58 Raises:
59 ValueError: If the specified category group, category, family, currency,
60 or exchange is not available in the database. Please check the available
61 options using the 'show_options' method.
62
63 Returns:
64 FinanceFrame:
65 A DataFrame containing ETF data matching the specified input criteria.
66 """
67 etfs = self.data.copy(deep=True)
68
69 if category_group:
70 category_groups = (
71 [category_group] if isinstance(category_group, str) else category_group
72 )
73 category_groups_lower = [
74 category_group.lower() for category_group in category_groups
75 ]
76 options_lower = [
77 option.lower()
78 for option in self.show_options(selection="category_group")
79 ]
80
81 for category_group_lower, category_group_actual in zip(
82 category_groups_lower, category_groups

Calls 2

show_optionsMethod · 0.95
FinanceFrameClass · 0.85