' + + '' + + _("Hide Search Matches") + + "
" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); diff --git a/docs/+1build/html/genindex.html b/docs/+1build/html/genindex.html new file mode 100644 index 0000000..ef7dee1 --- /dev/null +++ b/docs/+1build/html/genindex.html @@ -0,0 +1,112 @@ + + + + + +The get_series
function is designed to fetch economic data series from a specified API and return it formatted as a pandas DataFrame, making extensive use of various parameters to fine-tune the data retrieval process.
Identifier(s) for the data series to fetch. This can be a single string for one series or a tuple of strings for multiple series.
+The start date for the data retrieval in ‘DD-MM-YYYY’ format. By default, this calls default_start_date_fnc()
.
The end date for the data retrieval in ‘DD-MM-YYYY’ format. By default, this calls default_end_date_fnc()
.
The frequency at which data should be retrieved, options include ‘monthly’, ‘weekly’, ‘annually’, ‘semimonthly’, ‘semiannually’, and ‘business’.
+Computation methods to apply to the data series, such as ‘level’, ‘percentage_change’, ‘difference’, ‘year_to_year_percent_change’, or ‘year_to_year_differences’.
+Aggregation methods to apply to the data, options include ‘avg’, ‘min’, ‘max’, ‘first’, ‘last’, and ‘sum’.
+If True, uses cached data when available to speed up the data retrieval process. Default is False.
+The URL of the proxy server to use for the requests. Default is None.
+A dictionary of proxies to use for the request. Default is None.
+If True, runs the function in debug mode, providing additional debug information without making a real API request. Default is False.
+The API key required for accessing the data. Initially, it can be saved using the save("APIKEY")
function or via command line with $ evdspy save
.
A pandas DataFrame containing the retrieved data series.
+Raised if an invalid API key is provided or required parameters are missing.
+Basic usage:
+index = "TP.ODEMGZS.BDTTOPLAM"
+df = get_series(index, start_date="01-01-2020", end_date="01-01-2021", frequency="monthly")
+print(df.head())
+
Using multiple indexes and cache:
+indexes = ("TP.ODEMGZS.BDTTOPLAM", "TP.ODEMGZS.ABD")
+df = get_series(indexes, start_date="01-01-2020", frequency="monthly", cache=True)
+print(df.head())
+
template = """
+
+TP.ODEMGZS.BDTTOPLAM
+TP.ODEMGZS.ABD
+"""
+
+df = get_series(template, start_date="01-01-2020", frequency="monthly", cache=True)
+print(df.head())
+
Applying formulas and aggregation:
+df = get_series(template, start_date="01-01-2020", formulas="level", aggregation="sum")
+print(df.head())
+
evdspy is an open-source Python interface that simplifies making requests to the Central Bank of the Republic of Turkey (CBRT) Economic Data Service (EDS). It provides efficient request handling by caching results, a user-friendly menu for data inquiries, and capabilities for handling complex data structures through an accessible API.
+You can view the source code for this project on GitHub: View Source.
+Updated on this version:
+The API key parameter has now been moved to the HTTP header to enhance security and ensure that sensitive information is not exposed in URLs.
Added a new function, get_series
, which enhances the way data groups and series are handled.
Deprecated: The get_datagroup
function will be deprecated in future versions; get_series
will cover its functionalities.
API Key Management: Automatically saves the API key to a file when provided to the get_series
function, ignoring subsequent entries unless explicitly updated.
Visual and Textual Menu Options: Provides both a visual and textual menu to facilitate user interaction for setting up projects, creating output folders, and preparing configuration files.
Data Request Handling: Utilizes caching to optimize data retrieval, minimizing redundant requests and speeding up the data access process.
To install evdspy, simply run the following command:
+pip install evdspy -U
+
Here’s a quick example to get you started with using evdspy:
+from evdspy import get_series, default_start_date_fnc, default_end_date_fnc
+
+index = "TP.ODEMGZS.BDTTOPLAM", "TP.ODEMGZS.ABD"
+df = get_series(index, frequency="monthly", start_date=default_start_date_fnc(), end_date=default_end_date_fnc(), aggregation=("avg",), cache=True)
+print(df)
+
1from evdspy import *
+ 2
+ 3template = """TP_GSYIH01_GY_CF
+ 4TP_GSYIH02_GY_CF
+ 5TP_GSYIH03_GY_CF
+ 6TP_GSYIH04_GY_CF
+ 7TP_GSYIH05_GY_CF
+ 8TP_GSYIH06_GY_CF
+ 9TP_GSYIH07_GY_CF
+10TP_GSYIH08_GY_CF
+11TP_GSYIH09_GY_CF
+12TP_GSYIH10_GY_CF
+13TP_GSYIH11_GY_CF
+14TP_GSYIH14_GY_CF
+15TP_GSYIH15_GY_CF
+16TP_GSYIH16_GY_CF
+17"""
+18
+19df = get_series(template, debug=False)
+20print(df)
+21
+22
+
For more detailed information on all functions and their parameters, refer to the Modules section or visit our [GitHub Repository](https://github.com/SermetPekin/evdspy-repo).
+Please note that evdspy is not officially affiliated with or endorsed by the CBRT. It is developed and maintained under an MIT license by independent developers. Use of this tool should comply with all applicable laws and API usage guidelines provided by the CBRT.
+The save
function is designed to save an API key into your application’s configuration or a designated storage mechanism. It ensures the API key is valid and prompts the user for input if the provided key is not valid or if no key is provided.
The API key to be saved. If not provided or if an invalid key is passed, the user is prompted to input a valid API key interactively.
+The function checks if the provided api_key is a valid string. If the api_key is None or not a string, it attempts to set the API key through an interactive input method provided by set_apikey_input().
+This function should handle cases where: +- An API key is not provided, leading to an interactive input request. +- An invalid API key type is provided, prompting a type check and subsequent interactive input request.
+The final step involves checking the validity of the API key with check_apikey_and_then_save(api_key), which presumably implements further validation and storage mechanisms.
+Here is how you might typically call this function:
+# Example of saving an API key directly
+save("your_api_key_here")
+
+# Example when no API key is provided; this will trigger an interactive input prompt
+save()
+
This function is crucial for scenarios where secure and valid API key storage is necessary for the operation of your application, particularly in environments where configuration changes dynamically or where user input is required to initiate configuration.
+The setup
function initializes the application environment by performing multiple preparatory steps essential for the application’s operation. This function encapsulates tasks such as configuring settings, initializing data structures, and preparing necessary resources.
The function is designed to:
+Initialize base settings and configurations via SetupInitial().setup()
Configure additional settings specific to the application setup phase with start_setup_config(onsetup=True)
Create initial data examples necessary for the application with create_series_text_example(onsetup=True)
The setup
function is typically called at the beginning of the application’s lifecycle, before any other operations or user interactions occur.
This function is generally used without arguments and does not return any value:
+from evdspy import setup
+setup()
+
This call ensures that all initial configurations and setups are correctly executed, preparing the application for use.
++ |
|
+
|
+
|
+
The get_series
function is designed to fetch economic data series from a specified API and return it formatted as a pandas DataFrame, making extensive use of various parameters to fine-tune the data retrieval process.
Retrieves economic data series from the specified API and returns it as a pandas DataFrame. +Parameters +———- +index : str or tuple of str
+++The identifier(s) for the data series to fetch. Can be a single string for one series or a tuple of strings for multiple series.
+
The start date for the data retrieval in ‘DD-MM-YYYY’ format, by default calls default_start_date_fnc().
+The end date for the data retrieval in ‘DD-MM-YYYY’ format, by default calls default_end_date_fnc().
+The frequency at which data should be retrieved. +monthly | weekly | annually | semimonthly | semiannually | business
+The computation methods to apply to the data series +level | percentage_change | difference | year_to_year_percent_change | year_to_year_differences
+The aggregation methods to apply to the data, similar to formulas. +avg |min | max | first | last | sum
+If True, uses cached data when available to speed up the data retrieval process, by default False.
+The URL of the proxy server to use for the requests, by default None.
+A dictionary of proxies to use for the request, by default None.
+If True, runs the function in debug mode, providing additional debug information without making a real API request, by default False.
+The API key required for accessing the data, by default None. +When it was given for the first time it will be saved to a file for the subsequent requests. +alternatively it may be saved by save(“APIKEY”) function or $ evdspy save [from console]
+A pandas DataFrame containing the retrieved data series.
+If an invalid API key is provided or required parameters are missing.
+Basic usage: +# >>> template = “TP.ODEMGZS.BDTTOPLAM” +# >>> df = get_series(template, start_date=”01-01-2020”, end_date=”01-01-2021”, frequency=”monthly”) +# >>> print(df.head()) +# +# Using multiple indexes and cache: +# >>> indexes = (“TP.ODEMGZS.BDTTOPLAM”, “TP.ODEMGZS.ABD”) +# >>> df = get_series(indexes, start_date=”01-01-2020”, frequency=”monthly”, cache=True) +# >>> print(df.head()) +# +# Applying formulas and aggregation: +# >>> df = get_series(template, start_date=”01-01-2020”, formulas=”level”, aggregation=”sum”) +# >>> print(df.head())
+A pandas DataFrame containing the retrieved data series.
Raised if an invalid API key is provided or required parameters are missing.
Basic usage:
index = "TP.ODEMGZS.BDTTOPLAM"
df = get_series(index, start_date="01-01-2020", end_date="01-01-2021", frequency="monthly")
diff --git a/docs/build/html/index.html b/docs/build/html/index.html
index f35bd3f..06c0d0a 100644
--- a/docs/build/html/index.html
+++ b/docs/build/html/index.html
@@ -95,13 +95,15 @@ Welcome to evdspy’s documentation!get_series Function
setup()
save()
menu()
menu()
menu()
The menu
function displays a list of selectable options to the user and returns the index of the chosen option.
This function is useful in CLI applications where user interaction is required to choose between different actions.
save()
save()
The save
function is designed to save an API key into your application’s configuration or a designated storage mechanism. It ensures the API key is valid and prompts the user for input if the provided key is not valid or if no key is provided.
setup()
setup()
The setup
function initializes the application environment by performing multiple preparatory steps essential for the application’s operation. This function encapsulates tasks such as configuring settings, initializing data structures, and preparing necessary resources.