Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SermetPekin committed Apr 19, 2024
1 parent 1b4080c commit 8128cc0
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 12 deletions.
5 changes: 4 additions & 1 deletion docs/Makefile. → docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@

# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
Expand Down
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

evdspy==1.1.21
sphinx_rtd_theme
sphinx_book_theme
22 changes: 20 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

html_build_dir = '../docs'
# html_build_dir = 'docs'

project = 'evdspy'
copyright = '2024, Sermet Pekin'
author = 'Sermet Pekin'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration


extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
Expand All @@ -27,28 +32,41 @@
'sphinx.ext.autosummary',
# 'myst_parser'
]

templates_path = ['_templates']
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output


# html_theme = 'sphinx_rtd_theme'
html_theme = 'sphinx_book_theme'

html_static_path = ['static']

source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
}

import os
import inspect
from sphinx.util import logging

logger = logging.getLogger(__name__)

import time


def linkcode_resolve(domain, info):
print(domain, info, "Domain info ")
if domain != 'py':
return None
if not info['module']:
return None
filename = info['module'].replace('.', '/')
return "https://github.com/SermetPekin/evdspy-repo/%s.py" % filename
return "https://github.com/SermetPekin/evdspy-repo/%s.py" % filename


32 changes: 30 additions & 2 deletions docs/source/get_series.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@

get_series Function
===================

The ``get_series`` function fetches economic data series from a specified API and returns it formatted as a pandas DataFrame, making extensive use of various parameters to fine-tune the data retrieval process.

.. autofunction:: evdspy.get_series

Parameters
----------
index : str or tuple
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.

start_date : str, optional
The start date for the data retrieval in 'DD-MM-YYYY' format. By default, this calls ``default_start_date_fnc()``.

end_date : str, optional
The end date for the data retrieval in 'DD-MM-YYYY' format. By default, this calls ``default_end_date_fnc()``.

frequency : str, optional
The frequency at which data should be retrieved. Options include:

- **daily (1)**: Data retrieved every day.
- **business (2)**: Data retrieved only on business days.
- **weekly (3)**: Data retrieved weekly on Fridays.
Expand All @@ -21,8 +27,10 @@ frequency : str, optional
- **quarterly (6)**: Data retrieved every quarter.
- **semiannually (7)**: Data retrieved twice a year.
- **annual/annually (8)**: Data retrieved once a year.

formulas : str or tuple, optional
Computation methods to apply to the data series. Options include:

- **level (0)**: Raw data values.
- **percentage change (1)**: Percent change between consecutive data points.
- **difference (2)**: Difference between consecutive data points.
Expand All @@ -32,46 +40,66 @@ formulas : str or tuple, optional
- **difference compared to end-of-previous year (6)**: Difference relative to the end of the previous year.
- **moving average (7)**: Moving average of data points.
- **moving sum (8)**: Moving sum of data points.

aggregation : str or tuple, optional
Aggregation methods to apply to the data, options include:

- **avg**: Average value over the specified period.
- **min**: Minimum value over the specified period.
- **max**: Maximum value over the specified period.
- **first**: First value within the specified period.
- **last**: Last value within the specified period.
- **sum**: Sum of all values within the specified period.

cache : bool, optional
If True, uses cached data when available to speed up the data retrieval process. Default is False.

proxy : str, optional
The URL of the proxy server to use for the requests. Default is None.

proxies : dict, optional
A dictionary of proxies to use for the request. Default is None.

debug : bool, optional
If True, runs the function in debug mode, providing additional debug information without making a real API request. Default is False.

api_key : str, optional
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``.

Returns
-------
pd.DataFrame
A pandas DataFrame containing the retrieved data series.

Raises
------
ValueError
Raised if an invalid API key is provided or required parameters are missing.

Examples
--------
Basic usage:

.. code-block:: python
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:

.. code-block:: python
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:

.. code-block:: python
template = "TP.ODEMGZS.BDTTOPLAM"
df = get_series(template, start_date="01-01-2020", formulas="level", aggregation="sum")
print(df.head())
print(df.head())
19 changes: 18 additions & 1 deletion docs/source/home.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,70 @@ Introduction
:target: https://pypi.org/project/evdspy/
.. image:: https://pepy.tech/badge/evdspy/week
:target: https://pepy.tech/project/evdspy

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.

View Source Code
----------------
You can view the source code for this project on GitHub: `View Source <https://github.com/SermetPekin/evdspy-repo>`_.

What's New
----------
**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.

Key Features
------------
- **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.

Installation
------------
To install evdspy, simply run the following command:
.. code-block:: bash
pip install evdspy -U
Quick Start
-----------
Here's a quick example to get you started with using evdspy:

.. code-block:: python
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)
API Usage Examples
------------------

.. literalinclude:: ../../evdspy_example.py
:language: python
:linenos:
:caption: Example of using the get_series function to retrieve data.

Menus and Commands
------------------
- **Main Menu**: Access a user-friendly menu to manage data requests and settings.
- **Console Commands**: Use terminal commands to manage settings and request data:

.. code-block:: bash
evdspy setup
evdspy menu
evdspy create series
evdspy help
evdspy get
Learn More
----------
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).

Disclaimer
----------
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.
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.

8 changes: 6 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@

.. evdspy documentation master file, created by
sphinx-quickstart on Wed Apr 17 23:47:22 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to evdspy's documentation!
==================================
.. toctree::
:maxdepth: 2
:caption: Contents:

home
get_series
setup
save
menu


Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
* :ref:`search`

13 changes: 12 additions & 1 deletion docs/source/menu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,37 @@ menu Function
=============
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.

.. autofunction:: evdspy.menu

Function Details
----------------

.. autofunction:: evdspy.menu

Parameters
----------
options : list of str
A list of strings that represent the choices available to the user.

Returns
-------
int
The index of the option selected by the user, where the first option is indexed as 0.

Raises
------
ValueError
If the user's input is not a valid option index.

Example Usage
-------------
Here is a simple usage example that demonstrates how to use the ``menu`` function:

.. code-block:: python
from evdspy import menu
menu()
This example will display a menu with three options. After the user selects an option, the function will print the selected option.
This example will display a menu with three options. After the user selects an option, the function will print the selected option.

Loading

0 comments on commit 8128cc0

Please sign in to comment.