evdspy 2.2.1__tar.gz → 2.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {evdspy-2.2.1 → evdspy-2.3.1}/PKG-INFO +11 -9
- {evdspy-2.2.1 → evdspy-2.3.1}/README.md +10 -7
- evdspy-2.3.1/evdspy/EVDSlocal/common/clear_cache_folder.py +37 -0
- evdspy-2.3.1/evdspy/EVDSlocal/index_requests/catalog.py +299 -0
- evdspy-2.3.1/evdspy/EVDSlocal/index_requests/client.py +200 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/get_series_indexes.py +37 -1
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/get_series_indexes_exp.py +47 -1
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/get_series_indexes_utils.py +118 -7
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Api_requester.py +58 -32
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Request_config.py +38 -36
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Url_builder.py +5 -3
- evdspy-2.3.1/evdspy/EVDSlocal/requests_/json_cache.py +98 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/my_cache.py +9 -1
- evdspy-2.3.1/evdspy/EVDSlocal/requests_/real_requests.py +182 -0
- evdspy-2.3.1/evdspy/EVDSlocal/tests/test_v230_features.py +460 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/utils/utils_test.py +15 -8
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/__init__.py +62 -27
- evdspy-2.3.1/evdspy/__version__.py +1 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/skills/evdspy/SKILL.md +29 -7
- {evdspy-2.2.1 → evdspy-2.3.1}/pyproject.toml +5 -4
- evdspy-2.2.1/evdspy/EVDSlocal/common/clear_cache_folder.py +0 -30
- evdspy-2.2.1/evdspy/EVDSlocal/requests_/real_requests.py +0 -56
- evdspy-2.2.1/evdspy/__version__.py +0 -1
- {evdspy-2.2.1 → evdspy-2.3.1}/LICENSE +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/colors.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/common_imports.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/file_classes.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/files.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/folder_name_checks.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/prog.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/table.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/common/url_clean.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/api_params.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/api_params_enums.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/bucket_from_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/evds_files.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/evds_seri_files.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/excel_class.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/options_class.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/request_or_cache.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/components/url_class.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/config/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/config/apikey_class.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/config/config.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/config/credentials_file.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/config/dotenv.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/menu.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/menu_async.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/menu_logo_header.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/panel.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/proxy_for_menu.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/console/screen.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/helper/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/helper/print_m.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/categories.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/data_models.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/datagroup_individual.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/datagroups.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/datagroups_extra.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/datagroups_initial.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/df_operations.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/error_classes_index.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/index_classes.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/index_util_funcs.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/real_reqs_tests.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Data_processor.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Proxy_manager.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Serialize.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/Url_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/User_req_typings.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/User_request_utils.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/_Tables.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/index_requests/user_requests/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/cache_folder.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/cmd_line_classes.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/command_pictures.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/load_commands_.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/load_commands_cmds_to_load.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/load_modules.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/sample_series_content.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/start_args.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/start_options.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial/try_loading_initial_commands.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial_setup/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial_setup/api_key_save.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial_setup/initial_setups.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/initial_setup/setup_folders.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/log_classes/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/log_classes/log_template.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/main_.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/manual_requests/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/manual_requests/prepare.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/messages/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/messages/cmd_formats.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/messages/current_menu_message.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/messages/error_classes.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/messages/error_messages.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/messages/help_messages.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/ev_request.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/lower_energy.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/mock_req.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/request_error_classes.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/requests_/test_reg_result.pickle +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/populate_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/populate_series_helper.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/read_config_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/sample_series_content.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/series_creator.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/series_creator_on_setup.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/series_examples.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/series_format_config_funcs.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/series_format/stats/save_stats_of_requests.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/session/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/session/session_.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/setup_project/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/setup_project/read_config_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/setup_project/user_options_config.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/setup_project/user_series_config.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/setup_project/user_setup.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/setup_project/user_setup_helper.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/state/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/state/current_state.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/state/test_or_real.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/stats/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/stats/save_stats_of_requests.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/core_options_test.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_apikey_checks.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_categories.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_datagroups.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_frequency.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_get_proxies_env.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_get_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_get_series_exp.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_get_series_exp_cache.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_log_session.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_main_load.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_manual_series.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_multifreq_edge_cases.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_requests.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_user_requests.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/test_v220_improvements.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests/testing_mock_credentials.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/tests_main.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/utils/__init__.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/utils/github_actions.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/EVDSlocal/utils/utils_general.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/main.py +0 -0
- {evdspy-2.2.1 → evdspy-2.3.1}/evdspy/main_t.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: evdspy
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: A versatile interface for the 'EDDS' (EVDS) API of the Central Bank of the Republic of Türkiye (https://evds3.tcmb.gov.tr/dokumanlar). This package allows users to easily access and manage economic data through a user-friendly menu function. It features a robust caching mechanism to enhance the efficiency of data requests by storing frequently accessed data for selected periods. Required API keys can be obtained by registering on the EVDS website.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -26,7 +26,6 @@ Classifier: Typing :: Typed
|
|
|
26
26
|
Provides-Extra: jupyter
|
|
27
27
|
Requires-Dist: openpyxl (>3.0.10)
|
|
28
28
|
Requires-Dist: pandas (>1.5.0)
|
|
29
|
-
Requires-Dist: pytest (>=7.0.0)
|
|
30
29
|
Requires-Dist: python-dotenv (>=1.0.0)
|
|
31
30
|
Requires-Dist: requests (>=2.28.1)
|
|
32
31
|
Requires-Dist: rich (>=12.5.1)
|
|
@@ -51,13 +50,16 @@ Description-Content-Type: text/markdown
|
|
|
51
50
|
pip install evdspy -U
|
|
52
51
|
|
|
53
52
|
|
|
54
|
-
### Updated on this version (2.
|
|
55
|
-
- **
|
|
56
|
-
- **
|
|
57
|
-
- **
|
|
58
|
-
- **
|
|
59
|
-
-
|
|
60
|
-
- **
|
|
53
|
+
### Updated on this version (2.3.0)
|
|
54
|
+
- **HTTP resilience & pooling**: shared `requests.Session`, default `timeout=30`, and automatic exponential backoff retries on `429` / `502` / `503` / `504` and transient network timeouts.
|
|
55
|
+
- **Validated `formulas` & `aggregation` with aliases**: accepts `aggregation="mean"`, `"total"`, `"start"`, `"end"` and `formulas="yoy"`, `"pct"`, `"diff"`, `"ma"`, `"msum"`; unknown values or tuple length mismatches raise clear `ValueError`s before making any request.
|
|
56
|
+
- **JSON disk cache with live TTL**: replaces pickled responses with portable UTF-8 JSON under `~/.cache/evdspy/json`, supports dynamic `cache_ttl` (`"daily"`, `"hourly"`, `"nocache"`, seconds, or `datetime.timedelta`), and uses Python `logging` instead of printing to stdout.
|
|
57
|
+
- **Series discovery helpers**: `get_categories()`, `get_datagroups(category_id=...)`, `search_datagroups(query)`, and `search_series(query, datagroup=...)` return clean pandas DataFrames.
|
|
58
|
+
- **`EvdsClient` class**: reusable stateful client sharing configuration and an HTTP session (`with EvdsClient(api_key=..., cache=True) as client:`).
|
|
59
|
+
- **Cleaner packaging & faster imports**: moved `pytest` out of runtime dependencies, fixed Poetry 2.x group config, removed the double slash from EVDS URLs, and made legacy CLI/menu helpers lazy-loaded via PEP 562.
|
|
60
|
+
- **Built-in pagination (2.2.0)**: `paginate=True` (default) automatically pages backwards past EVDS's 1,000-row limit.
|
|
61
|
+
- **Consistent dates & flexible date inputs (2.2.0)**: `Tarih` is always used as the date column (never `index`), `parse_dates=True` normalizes all frequencies into period-start `Timestamp`s, and `start_date`/`end_date` accept `"YYYY-MM-DD"`, `datetime.date`/`datetime.datetime`, and `"DD-MM-YYYY"`.
|
|
62
|
+
- **Lazy `EVDS_API_KEY`, typed exceptions & `get_metadata()` (2.2.0)**: `EVDS_API_KEY` is read at request time, failures raise `EvdsAuthError`/`EvdsEmptyDataError`/`EvdsRequestError`, and `get_metadata(codes)` fetches metadata without downloading observations.
|
|
61
63
|
- ***frequency*** accepts aliases such as `yearly`, `quarter`, `month`, `week`, `semi-annual` and codes 1-8; unknown values raise a `ValueError` instead of silently returning daily data (2.1.5).
|
|
62
64
|
- ***AI agent skill*** added: `evdspy` ships a [`SKILL.md`](evdspy/skills/evdspy/SKILL.md) that teaches AI coding assistants (Claude Code, Cursor, Codex, Copilot, …) how to use this package correctly. See [Using evdspy with AI assistants](#using-evdspy-with-ai-assistants-skill).
|
|
63
65
|
- ***get_series_exp*** function was added
|
|
@@ -14,13 +14,16 @@
|
|
|
14
14
|
pip install evdspy -U
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
### Updated on this version (2.
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
-
|
|
23
|
-
- **
|
|
17
|
+
### Updated on this version (2.3.0)
|
|
18
|
+
- **HTTP resilience & pooling**: shared `requests.Session`, default `timeout=30`, and automatic exponential backoff retries on `429` / `502` / `503` / `504` and transient network timeouts.
|
|
19
|
+
- **Validated `formulas` & `aggregation` with aliases**: accepts `aggregation="mean"`, `"total"`, `"start"`, `"end"` and `formulas="yoy"`, `"pct"`, `"diff"`, `"ma"`, `"msum"`; unknown values or tuple length mismatches raise clear `ValueError`s before making any request.
|
|
20
|
+
- **JSON disk cache with live TTL**: replaces pickled responses with portable UTF-8 JSON under `~/.cache/evdspy/json`, supports dynamic `cache_ttl` (`"daily"`, `"hourly"`, `"nocache"`, seconds, or `datetime.timedelta`), and uses Python `logging` instead of printing to stdout.
|
|
21
|
+
- **Series discovery helpers**: `get_categories()`, `get_datagroups(category_id=...)`, `search_datagroups(query)`, and `search_series(query, datagroup=...)` return clean pandas DataFrames.
|
|
22
|
+
- **`EvdsClient` class**: reusable stateful client sharing configuration and an HTTP session (`with EvdsClient(api_key=..., cache=True) as client:`).
|
|
23
|
+
- **Cleaner packaging & faster imports**: moved `pytest` out of runtime dependencies, fixed Poetry 2.x group config, removed the double slash from EVDS URLs, and made legacy CLI/menu helpers lazy-loaded via PEP 562.
|
|
24
|
+
- **Built-in pagination (2.2.0)**: `paginate=True` (default) automatically pages backwards past EVDS's 1,000-row limit.
|
|
25
|
+
- **Consistent dates & flexible date inputs (2.2.0)**: `Tarih` is always used as the date column (never `index`), `parse_dates=True` normalizes all frequencies into period-start `Timestamp`s, and `start_date`/`end_date` accept `"YYYY-MM-DD"`, `datetime.date`/`datetime.datetime`, and `"DD-MM-YYYY"`.
|
|
26
|
+
- **Lazy `EVDS_API_KEY`, typed exceptions & `get_metadata()` (2.2.0)**: `EVDS_API_KEY` is read at request time, failures raise `EvdsAuthError`/`EvdsEmptyDataError`/`EvdsRequestError`, and `get_metadata(codes)` fetches metadata without downloading observations.
|
|
24
27
|
- ***frequency*** accepts aliases such as `yearly`, `quarter`, `month`, `week`, `semi-annual` and codes 1-8; unknown values raise a `ValueError` instead of silently returning daily data (2.1.5).
|
|
25
28
|
- ***AI agent skill*** added: `evdspy` ships a [`SKILL.md`](evdspy/skills/evdspy/SKILL.md) that teaches AI coding assistants (Claude Code, Cursor, Codex, Copilot, …) how to use this package correctly. See [Using evdspy with AI assistants](#using-evdspy-with-ai-assistants-skill).
|
|
26
29
|
- ***get_series_exp*** function was added
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import shutil
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("evdspy.cache")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def clear_cache_folder(cache_folder_path: Path):
|
|
10
|
+
normalized = str(cache_folder_path).replace("\\", "/")
|
|
11
|
+
if "cache/evdspy" not in normalized:
|
|
12
|
+
logger.warning(
|
|
13
|
+
"Refusing to clear %s: does not look like an evdspy cache directory.",
|
|
14
|
+
cache_folder_path,
|
|
15
|
+
)
|
|
16
|
+
return
|
|
17
|
+
if not os.path.exists(cache_folder_path):
|
|
18
|
+
logger.info("Cache folder %s does not exist.", cache_folder_path)
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
for filename in os.listdir(cache_folder_path):
|
|
22
|
+
file_path = os.path.join(cache_folder_path, filename)
|
|
23
|
+
try:
|
|
24
|
+
if os.path.isfile(file_path) or os.path.islink(file_path):
|
|
25
|
+
os.unlink(file_path)
|
|
26
|
+
elif os.path.isdir(file_path):
|
|
27
|
+
shutil.rmtree(file_path)
|
|
28
|
+
except Exception as exc:
|
|
29
|
+
logger.warning("Failed to delete %s: %s", file_path, exc)
|
|
30
|
+
|
|
31
|
+
logger.info("Cleared evdspy cache folder %s.", cache_folder_path)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def clear_cache():
|
|
35
|
+
cache_folder = Path.home() / ".cache" / "evdspy"
|
|
36
|
+
clear_cache_folder(cache_folder)
|
|
37
|
+
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"""Modern EVDS catalog & series discovery helpers (categories, datagroups, search)."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Optional, Union
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
import requests
|
|
8
|
+
|
|
9
|
+
from evdspy.EVDSlocal.index_requests.user_requests.Api_requester import ApiRequester
|
|
10
|
+
from evdspy.EVDSlocal.index_requests.user_requests.Proxy_manager import ProxyManager
|
|
11
|
+
from evdspy.EVDSlocal.messages.error_classes import EvdsEmptyDataError
|
|
12
|
+
from evdspy.EVDSlocal.requests_.json_cache import CacheTTL
|
|
13
|
+
from evdspy.EVDSlocal.requests_.real_requests import (
|
|
14
|
+
DEFAULT_BACKOFF_FACTOR,
|
|
15
|
+
DEFAULT_RETRIES,
|
|
16
|
+
DEFAULT_TIMEOUT,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
EVDS_BASE_URL = "https://evds3.tcmb.gov.tr/igmevdsms-dis"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class _SimpleUrlConfig:
|
|
24
|
+
cache: bool = True
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class _StaticUrlBuilder:
|
|
28
|
+
def __init__(self, url: str, cache: bool = True):
|
|
29
|
+
self.url = url
|
|
30
|
+
self.config = _SimpleUrlConfig(cache=cache)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _fetch_catalog_json(
|
|
34
|
+
url: str,
|
|
35
|
+
*,
|
|
36
|
+
cache: bool = True,
|
|
37
|
+
proxy: Optional[str] = None,
|
|
38
|
+
proxies: Optional[dict[str, str]] = None,
|
|
39
|
+
no_proxy: bool = False,
|
|
40
|
+
api_key: Optional[str] = None,
|
|
41
|
+
timeout: Optional[float] = DEFAULT_TIMEOUT,
|
|
42
|
+
retries: int = DEFAULT_RETRIES,
|
|
43
|
+
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
|
|
44
|
+
cache_ttl: CacheTTL = "daily",
|
|
45
|
+
session: Optional[requests.Session] = None,
|
|
46
|
+
) -> Any:
|
|
47
|
+
proxy_manager = ProxyManager(proxy=proxy, proxies=proxies, no_proxy=no_proxy)
|
|
48
|
+
url_builder = _StaticUrlBuilder(url=url, cache=cache)
|
|
49
|
+
requester = ApiRequester(
|
|
50
|
+
url_builder,
|
|
51
|
+
proxy_manager,
|
|
52
|
+
api_key=api_key,
|
|
53
|
+
timeout=timeout,
|
|
54
|
+
retries=retries,
|
|
55
|
+
backoff_factor=backoff_factor,
|
|
56
|
+
session=session,
|
|
57
|
+
cache_ttl=cache_ttl,
|
|
58
|
+
)
|
|
59
|
+
return requester()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _records_to_df(payload: Any, empty_message: str) -> pd.DataFrame:
|
|
63
|
+
if isinstance(payload, dict) and "items" in payload:
|
|
64
|
+
payload = payload["items"]
|
|
65
|
+
if not payload or not isinstance(payload, list):
|
|
66
|
+
raise EvdsEmptyDataError(empty_message)
|
|
67
|
+
df = pd.DataFrame.from_records(payload)
|
|
68
|
+
if df.empty:
|
|
69
|
+
raise EvdsEmptyDataError(empty_message)
|
|
70
|
+
return df
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _filter_df_by_query(
|
|
74
|
+
df: pd.DataFrame, query: str, columns: tuple[str, ...]
|
|
75
|
+
) -> pd.DataFrame:
|
|
76
|
+
tokens = [tok.lower() for tok in query.strip().split() if tok]
|
|
77
|
+
if not tokens:
|
|
78
|
+
return df.copy()
|
|
79
|
+
searchable = [c for c in columns if c in df.columns]
|
|
80
|
+
if not searchable:
|
|
81
|
+
searchable = list(df.columns)
|
|
82
|
+
combined = (
|
|
83
|
+
df[searchable]
|
|
84
|
+
.fillna("")
|
|
85
|
+
.astype(str)
|
|
86
|
+
.agg(" ".join, axis=1)
|
|
87
|
+
.str.lower()
|
|
88
|
+
)
|
|
89
|
+
mask = pd.Series(True, index=df.index)
|
|
90
|
+
for tok in tokens:
|
|
91
|
+
mask = mask & combined.str.contains(tok, regex=False)
|
|
92
|
+
return df.loc[mask].reset_index(drop=True)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def get_categories(
|
|
96
|
+
cache: bool = True,
|
|
97
|
+
proxy: Optional[str] = None,
|
|
98
|
+
proxies: Optional[dict[str, str]] = None,
|
|
99
|
+
no_proxy: bool = False,
|
|
100
|
+
api_key: Optional[str] = None,
|
|
101
|
+
timeout: Optional[float] = DEFAULT_TIMEOUT,
|
|
102
|
+
retries: int = DEFAULT_RETRIES,
|
|
103
|
+
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
|
|
104
|
+
cache_ttl: CacheTTL = "daily",
|
|
105
|
+
session: Optional[requests.Session] = None,
|
|
106
|
+
) -> pd.DataFrame:
|
|
107
|
+
"""Return all EVDS top-level categories as a pandas DataFrame."""
|
|
108
|
+
url = f"{EVDS_BASE_URL}/categories/type=json"
|
|
109
|
+
payload = _fetch_catalog_json(
|
|
110
|
+
url,
|
|
111
|
+
cache=cache,
|
|
112
|
+
proxy=proxy,
|
|
113
|
+
proxies=proxies,
|
|
114
|
+
no_proxy=no_proxy,
|
|
115
|
+
api_key=api_key,
|
|
116
|
+
timeout=timeout,
|
|
117
|
+
retries=retries,
|
|
118
|
+
backoff_factor=backoff_factor,
|
|
119
|
+
cache_ttl=cache_ttl,
|
|
120
|
+
session=session,
|
|
121
|
+
)
|
|
122
|
+
return _records_to_df(payload, "EVDS returned no categories.")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def get_datagroups(
|
|
126
|
+
category_id: Optional[Union[int, str]] = None,
|
|
127
|
+
cache: bool = True,
|
|
128
|
+
proxy: Optional[str] = None,
|
|
129
|
+
proxies: Optional[dict[str, str]] = None,
|
|
130
|
+
no_proxy: bool = False,
|
|
131
|
+
api_key: Optional[str] = None,
|
|
132
|
+
timeout: Optional[float] = DEFAULT_TIMEOUT,
|
|
133
|
+
retries: int = DEFAULT_RETRIES,
|
|
134
|
+
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
|
|
135
|
+
cache_ttl: CacheTTL = "daily",
|
|
136
|
+
session: Optional[requests.Session] = None,
|
|
137
|
+
) -> pd.DataFrame:
|
|
138
|
+
"""Return EVDS datagroups as a pandas DataFrame.
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
category_id : int or str, optional
|
|
143
|
+
If omitted, fetches all datagroups across every category (``mode=0``).
|
|
144
|
+
If given, fetches datagroups belonging to that category (``mode=2``).
|
|
145
|
+
"""
|
|
146
|
+
if category_id is None:
|
|
147
|
+
url = f"{EVDS_BASE_URL}/datagroups/mode=0&type=json"
|
|
148
|
+
else:
|
|
149
|
+
url = f"{EVDS_BASE_URL}/datagroups/mode=2&code={category_id}&type=json"
|
|
150
|
+
payload = _fetch_catalog_json(
|
|
151
|
+
url,
|
|
152
|
+
cache=cache,
|
|
153
|
+
proxy=proxy,
|
|
154
|
+
proxies=proxies,
|
|
155
|
+
no_proxy=no_proxy,
|
|
156
|
+
api_key=api_key,
|
|
157
|
+
timeout=timeout,
|
|
158
|
+
retries=retries,
|
|
159
|
+
backoff_factor=backoff_factor,
|
|
160
|
+
cache_ttl=cache_ttl,
|
|
161
|
+
session=session,
|
|
162
|
+
)
|
|
163
|
+
return _records_to_df(
|
|
164
|
+
payload, f"EVDS returned no datagroups for category_id={category_id!r}."
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def search_datagroups(
|
|
169
|
+
query: str,
|
|
170
|
+
category_id: Optional[Union[int, str]] = None,
|
|
171
|
+
cache: bool = True,
|
|
172
|
+
proxy: Optional[str] = None,
|
|
173
|
+
proxies: Optional[dict[str, str]] = None,
|
|
174
|
+
no_proxy: bool = False,
|
|
175
|
+
api_key: Optional[str] = None,
|
|
176
|
+
timeout: Optional[float] = DEFAULT_TIMEOUT,
|
|
177
|
+
retries: int = DEFAULT_RETRIES,
|
|
178
|
+
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
|
|
179
|
+
cache_ttl: CacheTTL = "daily",
|
|
180
|
+
session: Optional[requests.Session] = None,
|
|
181
|
+
) -> pd.DataFrame:
|
|
182
|
+
"""Search EVDS datagroups by keyword (case-insensitive, multi-word)."""
|
|
183
|
+
df = get_datagroups(
|
|
184
|
+
category_id=category_id,
|
|
185
|
+
cache=cache,
|
|
186
|
+
proxy=proxy,
|
|
187
|
+
proxies=proxies,
|
|
188
|
+
no_proxy=no_proxy,
|
|
189
|
+
api_key=api_key,
|
|
190
|
+
timeout=timeout,
|
|
191
|
+
retries=retries,
|
|
192
|
+
backoff_factor=backoff_factor,
|
|
193
|
+
cache_ttl=cache_ttl,
|
|
194
|
+
session=session,
|
|
195
|
+
)
|
|
196
|
+
return _filter_df_by_query(
|
|
197
|
+
df,
|
|
198
|
+
query,
|
|
199
|
+
columns=(
|
|
200
|
+
"DATAGROUP_CODE",
|
|
201
|
+
"DATAGROUP_NAME",
|
|
202
|
+
"DATAGROUP_NAME_ENG",
|
|
203
|
+
"NOTE",
|
|
204
|
+
"NOTE_ENG",
|
|
205
|
+
),
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def search_series(
|
|
210
|
+
query: str,
|
|
211
|
+
datagroup: Optional[str] = None,
|
|
212
|
+
category_id: Optional[Union[int, str]] = None,
|
|
213
|
+
max_datagroups: int = 10,
|
|
214
|
+
cache: bool = True,
|
|
215
|
+
proxy: Optional[str] = None,
|
|
216
|
+
proxies: Optional[dict[str, str]] = None,
|
|
217
|
+
no_proxy: bool = False,
|
|
218
|
+
api_key: Optional[str] = None,
|
|
219
|
+
timeout: Optional[float] = DEFAULT_TIMEOUT,
|
|
220
|
+
retries: int = DEFAULT_RETRIES,
|
|
221
|
+
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
|
|
222
|
+
cache_ttl: CacheTTL = "daily",
|
|
223
|
+
session: Optional[requests.Session] = None,
|
|
224
|
+
) -> pd.DataFrame:
|
|
225
|
+
"""Search EVDS series by keyword.
|
|
226
|
+
|
|
227
|
+
Parameters
|
|
228
|
+
----------
|
|
229
|
+
query : str
|
|
230
|
+
Case-insensitive search keywords (all space-separated tokens must match).
|
|
231
|
+
datagroup : str, optional
|
|
232
|
+
If provided (e.g. ``'bie_tukfiy2025'``), searches directly inside that datagroup's series list.
|
|
233
|
+
Otherwise, first finds matching datagroups via ``search_datagroups`` (up to ``max_datagroups``)
|
|
234
|
+
and fetches their series lists.
|
|
235
|
+
category_id : int or str, optional
|
|
236
|
+
Restrict datagroup discovery to a specific EVDS category.
|
|
237
|
+
max_datagroups : int, default 10
|
|
238
|
+
Maximum number of matched datagroups to expand when ``datagroup`` is not specified.
|
|
239
|
+
"""
|
|
240
|
+
common_kwargs = dict(
|
|
241
|
+
cache=cache,
|
|
242
|
+
proxy=proxy,
|
|
243
|
+
proxies=proxies,
|
|
244
|
+
no_proxy=no_proxy,
|
|
245
|
+
api_key=api_key,
|
|
246
|
+
timeout=timeout,
|
|
247
|
+
retries=retries,
|
|
248
|
+
backoff_factor=backoff_factor,
|
|
249
|
+
cache_ttl=cache_ttl,
|
|
250
|
+
session=session,
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
series_cols = (
|
|
254
|
+
"SERIE_CODE",
|
|
255
|
+
"SERIE_NAME",
|
|
256
|
+
"SERIE_NAME_ENG",
|
|
257
|
+
"DATAGROUP_CODE",
|
|
258
|
+
"TAG",
|
|
259
|
+
"UNIT",
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
if datagroup is not None:
|
|
263
|
+
url = f"{EVDS_BASE_URL}/serieList/type=json&code={datagroup.strip()}"
|
|
264
|
+
payload = _fetch_catalog_json(url, **common_kwargs)
|
|
265
|
+
df = _records_to_df(payload, f"EVDS returned no series for datagroup {datagroup!r}.")
|
|
266
|
+
return _filter_df_by_query(df, query, columns=series_cols)
|
|
267
|
+
|
|
268
|
+
matched_groups = search_datagroups(
|
|
269
|
+
query, category_id=category_id, **common_kwargs
|
|
270
|
+
)
|
|
271
|
+
if matched_groups.empty or "DATAGROUP_CODE" not in matched_groups.columns:
|
|
272
|
+
return pd.DataFrame()
|
|
273
|
+
|
|
274
|
+
dg_codes = list(matched_groups["DATAGROUP_CODE"].dropna().unique())[: max(1, int(max_datagroups))]
|
|
275
|
+
frames = []
|
|
276
|
+
for dg_code in dg_codes:
|
|
277
|
+
url = f"{EVDS_BASE_URL}/serieList/type=json&code={dg_code}"
|
|
278
|
+
try:
|
|
279
|
+
payload = _fetch_catalog_json(url, **common_kwargs)
|
|
280
|
+
frames.append(_records_to_df(payload, f"No series for {dg_code}"))
|
|
281
|
+
except EvdsEmptyDataError:
|
|
282
|
+
continue
|
|
283
|
+
|
|
284
|
+
if not frames:
|
|
285
|
+
return pd.DataFrame()
|
|
286
|
+
|
|
287
|
+
all_series = pd.concat(frames, axis="rows", join="outer", ignore_index=True)
|
|
288
|
+
filtered = _filter_df_by_query(all_series, query, columns=series_cols)
|
|
289
|
+
# If the query matched the datagroup title (e.g. "inflation expectations") but individual
|
|
290
|
+
# series names use slightly different wording, return all series from the matched datagroups.
|
|
291
|
+
return filtered if not filtered.empty else all_series
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
__all__ = (
|
|
295
|
+
"get_categories",
|
|
296
|
+
"get_datagroups",
|
|
297
|
+
"search_datagroups",
|
|
298
|
+
"search_series",
|
|
299
|
+
)
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"""Stateful EvdsClient with shared requests.Session and default configuration."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Optional, Union
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from evdspy.EVDSlocal.index_requests.catalog import (
|
|
9
|
+
get_categories as _get_categories,
|
|
10
|
+
get_datagroups as _get_datagroups,
|
|
11
|
+
search_datagroups as _search_datagroups,
|
|
12
|
+
search_series as _search_series,
|
|
13
|
+
)
|
|
14
|
+
from evdspy.EVDSlocal.index_requests.get_series_indexes import get_series as _get_series
|
|
15
|
+
from evdspy.EVDSlocal.index_requests.get_series_indexes_exp import (
|
|
16
|
+
Result,
|
|
17
|
+
get_metadata as _get_metadata,
|
|
18
|
+
get_series_exp as _get_series_exp,
|
|
19
|
+
)
|
|
20
|
+
from evdspy.EVDSlocal.index_requests.get_series_indexes_utils import DateLike
|
|
21
|
+
from evdspy.EVDSlocal.index_requests.user_requests.Request_config import RequestConfig
|
|
22
|
+
from evdspy.EVDSlocal.requests_.json_cache import CacheTTL
|
|
23
|
+
from evdspy.EVDSlocal.requests_.real_requests import (
|
|
24
|
+
DEFAULT_BACKOFF_FACTOR,
|
|
25
|
+
DEFAULT_RETRIES,
|
|
26
|
+
DEFAULT_TIMEOUT,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class EvdsClient:
|
|
31
|
+
"""Reusable EVDS API client sharing configuration and an HTTP session.
|
|
32
|
+
|
|
33
|
+
Supports use as a context manager::
|
|
34
|
+
|
|
35
|
+
with EvdsClient(api_key="...", cache=True, timeout=20) as client:
|
|
36
|
+
df = client.get_series("TP.DK.USD.A.YTL", start_date="2024-01-01")
|
|
37
|
+
meta = client.get_metadata("TP.DK.USD.A.YTL")
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self,
|
|
42
|
+
api_key: Optional[str] = None,
|
|
43
|
+
*,
|
|
44
|
+
proxy: Optional[str] = None,
|
|
45
|
+
proxies: Optional[dict[str, str]] = None,
|
|
46
|
+
no_proxy: bool = False,
|
|
47
|
+
cache: bool = False,
|
|
48
|
+
cache_ttl: CacheTTL = "daily",
|
|
49
|
+
timeout: float = DEFAULT_TIMEOUT,
|
|
50
|
+
retries: int = DEFAULT_RETRIES,
|
|
51
|
+
backoff_factor: float = DEFAULT_BACKOFF_FACTOR,
|
|
52
|
+
paginate: bool = True,
|
|
53
|
+
parse_dates: bool = True,
|
|
54
|
+
basic: bool = True,
|
|
55
|
+
session: Optional[requests.Session] = None,
|
|
56
|
+
):
|
|
57
|
+
self.api_key = api_key
|
|
58
|
+
self.proxy = proxy
|
|
59
|
+
self.proxies = proxies
|
|
60
|
+
self.no_proxy = no_proxy
|
|
61
|
+
self.cache = cache
|
|
62
|
+
self.cache_ttl = cache_ttl
|
|
63
|
+
self.timeout = timeout
|
|
64
|
+
self.retries = retries
|
|
65
|
+
self.backoff_factor = backoff_factor
|
|
66
|
+
self.paginate = paginate
|
|
67
|
+
self.parse_dates = parse_dates
|
|
68
|
+
self.basic = basic
|
|
69
|
+
self._owns_session = session is None
|
|
70
|
+
self.session: requests.Session = session if session is not None else requests.Session()
|
|
71
|
+
|
|
72
|
+
def close(self) -> None:
|
|
73
|
+
if self._owns_session and self.session is not None:
|
|
74
|
+
self.session.close()
|
|
75
|
+
|
|
76
|
+
def __enter__(self) -> "EvdsClient":
|
|
77
|
+
return self
|
|
78
|
+
|
|
79
|
+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
|
80
|
+
self.close()
|
|
81
|
+
|
|
82
|
+
def _transport_defaults(self, overrides: dict[str, Any]) -> dict[str, Any]:
|
|
83
|
+
defaults = {
|
|
84
|
+
"api_key": self.api_key,
|
|
85
|
+
"proxy": self.proxy,
|
|
86
|
+
"proxies": self.proxies,
|
|
87
|
+
"no_proxy": self.no_proxy,
|
|
88
|
+
"cache": self.cache,
|
|
89
|
+
"cache_ttl": self.cache_ttl,
|
|
90
|
+
"timeout": self.timeout,
|
|
91
|
+
"retries": self.retries,
|
|
92
|
+
"backoff_factor": self.backoff_factor,
|
|
93
|
+
"session": self.session,
|
|
94
|
+
}
|
|
95
|
+
defaults.update(overrides)
|
|
96
|
+
return defaults
|
|
97
|
+
|
|
98
|
+
def get_series(
|
|
99
|
+
self,
|
|
100
|
+
index: Union[str, tuple[Any, ...], list[Any]],
|
|
101
|
+
start_date: Optional[DateLike] = None,
|
|
102
|
+
end_date: Optional[DateLike] = None,
|
|
103
|
+
frequency: Any = None,
|
|
104
|
+
formulas: Any = None,
|
|
105
|
+
aggregation: Any = None,
|
|
106
|
+
**kwargs: Any,
|
|
107
|
+
) -> Union[pd.DataFrame, RequestConfig]:
|
|
108
|
+
params = self._transport_defaults(kwargs)
|
|
109
|
+
params.setdefault("basic", self.basic)
|
|
110
|
+
params.setdefault("paginate", self.paginate)
|
|
111
|
+
params.setdefault("parse_dates", self.parse_dates)
|
|
112
|
+
return _get_series(
|
|
113
|
+
index=index,
|
|
114
|
+
start_date=start_date,
|
|
115
|
+
end_date=end_date,
|
|
116
|
+
frequency=frequency,
|
|
117
|
+
formulas=formulas,
|
|
118
|
+
aggregation=aggregation,
|
|
119
|
+
**params,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def get_series_exp(
|
|
123
|
+
self,
|
|
124
|
+
index: Union[str, tuple[Any, ...], list[Any]],
|
|
125
|
+
start_date: Optional[DateLike] = None,
|
|
126
|
+
end_date: Optional[DateLike] = None,
|
|
127
|
+
frequency: Any = None,
|
|
128
|
+
formulas: Any = None,
|
|
129
|
+
aggregation: Any = None,
|
|
130
|
+
**kwargs: Any,
|
|
131
|
+
) -> Result:
|
|
132
|
+
params = self._transport_defaults(kwargs)
|
|
133
|
+
params.setdefault("meta_cache", self.cache)
|
|
134
|
+
params.setdefault("basic", self.basic)
|
|
135
|
+
params.setdefault("paginate", self.paginate)
|
|
136
|
+
params.setdefault("parse_dates", self.parse_dates)
|
|
137
|
+
return _get_series_exp(
|
|
138
|
+
index=index,
|
|
139
|
+
start_date=start_date,
|
|
140
|
+
end_date=end_date,
|
|
141
|
+
frequency=frequency,
|
|
142
|
+
formulas=formulas,
|
|
143
|
+
aggregation=aggregation,
|
|
144
|
+
**params,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
def get_metadata(
|
|
148
|
+
self,
|
|
149
|
+
codes: Union[str, tuple[str, ...], list[str]],
|
|
150
|
+
**kwargs: Any,
|
|
151
|
+
) -> Union[pd.DataFrame, RequestConfig]:
|
|
152
|
+
params = self._transport_defaults(kwargs)
|
|
153
|
+
return _get_metadata(codes=codes, **params)
|
|
154
|
+
|
|
155
|
+
def get_categories(self, **kwargs: Any) -> pd.DataFrame:
|
|
156
|
+
params = self._transport_defaults(kwargs)
|
|
157
|
+
if "cache" not in kwargs:
|
|
158
|
+
params["cache"] = True
|
|
159
|
+
return _get_categories(**params)
|
|
160
|
+
|
|
161
|
+
def get_datagroups(
|
|
162
|
+
self, category_id: Optional[Union[int, str]] = None, **kwargs: Any
|
|
163
|
+
) -> pd.DataFrame:
|
|
164
|
+
params = self._transport_defaults(kwargs)
|
|
165
|
+
if "cache" not in kwargs:
|
|
166
|
+
params["cache"] = True
|
|
167
|
+
return _get_datagroups(category_id=category_id, **params)
|
|
168
|
+
|
|
169
|
+
def search_datagroups(
|
|
170
|
+
self,
|
|
171
|
+
query: str,
|
|
172
|
+
category_id: Optional[Union[int, str]] = None,
|
|
173
|
+
**kwargs: Any,
|
|
174
|
+
) -> pd.DataFrame:
|
|
175
|
+
params = self._transport_defaults(kwargs)
|
|
176
|
+
if "cache" not in kwargs:
|
|
177
|
+
params["cache"] = True
|
|
178
|
+
return _search_datagroups(query=query, category_id=category_id, **params)
|
|
179
|
+
|
|
180
|
+
def search_series(
|
|
181
|
+
self,
|
|
182
|
+
query: str,
|
|
183
|
+
datagroup: Optional[str] = None,
|
|
184
|
+
category_id: Optional[Union[int, str]] = None,
|
|
185
|
+
max_datagroups: int = 10,
|
|
186
|
+
**kwargs: Any,
|
|
187
|
+
) -> pd.DataFrame:
|
|
188
|
+
params = self._transport_defaults(kwargs)
|
|
189
|
+
if "cache" not in kwargs:
|
|
190
|
+
params["cache"] = True
|
|
191
|
+
return _search_series(
|
|
192
|
+
query=query,
|
|
193
|
+
datagroup=datagroup,
|
|
194
|
+
category_id=category_id,
|
|
195
|
+
max_datagroups=max_datagroups,
|
|
196
|
+
**params,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
__all__ = ("EvdsClient",)
|