Skip to content

Commit d04f5f1

Browse files
authored
Merge pull request #28 from GrupoTuring/docs/sphinx
Cria documentação utilizando sphinx
2 parents 67120e5 + b88c97e commit d04f5f1

File tree

8 files changed

+245
-116
lines changed

8 files changed

+245
-116
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
sys.path.insert(0, os.path.abspath('../'))
16+
17+
# -- Project information -----------------------------------------------------
18+
19+
project = 'turingquant'
20+
copyright = '2020, Grupo Turing'
21+
author = 'Grupo Turing'
22+
23+
# The full version, including alpha/beta/rc tags
24+
release = '0.1.5'
25+
26+
27+
# -- General configuration ---------------------------------------------------
28+
29+
# Add any Sphinx extension module names here, as strings. They can be
30+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
31+
# ones.
32+
extensions = [
33+
'sphinx.ext.autodoc',
34+
'sphinx.ext.autosummary',
35+
'sphinx.ext.napoleon',
36+
'sphinx_rtd_theme'
37+
]
38+
39+
# Add any paths that contain templates here, relative to this directory.
40+
templates_path = ['_templates']
41+
42+
# The language for content autogenerated by Sphinx. Refer to documentation
43+
# for a list of supported languages.
44+
#
45+
# This is also used if you do content translation via gettext catalogs.
46+
# Usually you set "language" from the command line for these cases.
47+
language = 'pt_BR'
48+
49+
# List of patterns, relative to source directory, that match files and
50+
# directories to ignore when looking for source files.
51+
# This pattern also affects html_static_path and html_extra_path.
52+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
53+
54+
# Napoleon settings
55+
56+
napoleon_numpy_docstring = False
57+
# napoleon_use_param = False
58+
59+
# -- Options for HTML output -------------------------------------------------
60+
61+
# The theme to use for HTML and HTML Help pages. See the documentation for
62+
# a list of builtin themes.
63+
#
64+
html_theme = 'sphinx_rtd_theme'
65+
66+
# Add any paths that contain custom static files (such as style sheets) here,
67+
# relative to this directory. They are copied after the builtin static files,
68+
# so a file named "default.css" will overwrite the builtin "default.css".
69+
html_static_path = ['_static']

docs/index.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
turingquant
2+
===========
3+
4+
``turingquant`` é uma biblioteca para coleta, análise e backtesting de ativos e estratégias financeiras.
5+
O projeto está em desenvolvimento ativo pelos membros de Finanças Quantitativas do `Grupo Turing <https://github.com/GrupoTuring>`_.
6+
7+
A API de onde obtemos os dados fundamentalistas é a Alpha Vantage e você pode `obter a chave de uso gratuitamente <https://www.alphavantage.co/support/#api-key>`_.
8+
Essa chave será necessária sempre que você utilizar as funções daily e intraday.
9+
10+
``pip install turingquant`` instala a última versão estável.
11+
12+
.. toctree::
13+
:maxdepth: 4
14+
:caption: Contents:
15+
16+
.. automodule:: turingquant
17+
:members:
18+
:undoc-members:
19+
:show-inheritance:
20+
21+
Módulos
22+
-------
23+
24+
.. autosummary::
25+
26+
turingquant.metrics
27+
turingquant.benchmark
28+
turingquant.support
29+
30+
Módulo metrics
31+
==============
32+
33+
.. automodule:: turingquant.metrics
34+
:members:
35+
36+
Módulo benchmark
37+
================
38+
39+
.. automodule:: turingquant.benchmark
40+
:members:
41+
42+
Módulo support
43+
==============
44+
45+
.. automodule:: turingquant.support
46+
:members:
47+

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="turingquant",
8-
version="0.1.4",
8+
version="0.1.5",
99
packages=find_packages(),
1010
install_requires=["pandas", "pandas_datareader", "numpy", "matplotlib", "alpha_vantage", "bs4", "plotly", "yfinance"],
1111

turingquant/benchmark.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Módulo para comparação e benchmarking de ativos e retornos."""
2+
13
import pandas as pd
24
import plotly.express as px
35
from datetime import datetime
@@ -9,13 +11,15 @@ def benchmark(ticker, start: datetime, end: datetime, source='yahoo', plot=True)
911
Essa função fornece um plot de retorno acumulado de um ativo ao longo de um dado intervalo de tempo, definido pelos parâmetros start e end.
1012
Os dados são coletados da API do yahoo, caso haja dados faltantes, os retornos são contabilizados como nulos.
1113
12-
ticker[str]: recebe o ticker do papel que será obtido
13-
14-
start[datetime]: início do intervalo
14+
Args:
15+
ticker (str): recebe o ticker do papel que será obtido.
16+
start (datetime): início do intervalo.
17+
end (datetime): final do intervalo.
18+
plot (bool): opcional; exibe o gráfico caso `True`.
1519
16-
end[datetime]: final do interval
20+
Returns:
21+
pd.series: uma série de ativos indexados com o tempo com o retorno cumulativo para o período.
1722
18-
plot[bool]: (default = True) se True, realiza o plot
1923
"""
2024

2125
asset = data.DataReader(ticker, data_source=source, start=start, end=end)
@@ -35,11 +39,13 @@ def benchmark_ibov(start: datetime, end: datetime, source='yahoo', plot=True):
3539
"""
3640
Essa função produz um plot da evolução do Índice Bovespa ao longo de um dado intervalo, definido pelos parâmetros start e end.
3741
38-
start[datetime]: início do intervalo
42+
Args:
43+
start (datetime): início do intervalo.
44+
end (datetime): final do intervalo.
45+
plot (bool): opcional; exibe o gráfico caso `True`.
3946
40-
end[datetime]: final do interval
41-
42-
plot[bool]: (default = True) se True, realiza o plot
47+
Returns:
48+
pd.series: uma série temporal com o retorno acumulado do Ibovespa para o período.
4349
"""
4450

4551
return benchmark('^BVSP', start=start, end=end, source=source, plot=plot)
@@ -49,11 +55,13 @@ def benchmark_sp500(start: datetime, end: datetime, source='yahoo', plot=True):
4955
"""
5056
Essa função produz um plot da evolução do Índice S&P500 ao longo de um dado intervalo, definido pelos parâmetros start e end.
5157
52-
start[datetime]: início do intervalo
53-
54-
end[datetime]: final do interval
58+
Args:
59+
start (datetime): início do intervalo.
60+
end (datetime): final do intervalo.
61+
plot (bool): opcional; exibe o gráfico caso `True`.
5562
56-
plot[bool]: (default = True) se True, realiza o plot
63+
Returns:
64+
pd.series: uma série temporal com o retorno acumulado do S&P500 para o período.
5765
"""
5866

5967
return benchmark('^GSPC', start=start, end=end, source=source, plot=plot)

0 commit comments

Comments
 (0)