tesorotools-python 0.0.0__tar.gz → 0.0.2__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.
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/PKG-INFO +2 -1
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/README.md +0 -28
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/pyproject.toml +2 -2
- tesorotools_python-0.0.2/src/tesorotools/data_sources/README.md +14 -0
- tesorotools_python-0.0.0/src/tesorotools/data_sources/eikon.py → tesorotools_python-0.0.2/src/tesorotools/data_sources/lseg.py +17 -22
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/.gitignore +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/README.md +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/barh_plots.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/data.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/dependencies.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/line_plots.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/offsets.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/plots.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/tables.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/template.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/examples/type_curves.yaml +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/artists/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/artists/barh_plot.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/artists/line_plot.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/artists/table.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/artists/type_curve.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/convert.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/data_sources/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/data_sources/debug.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/database/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/database/push.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/functions.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/node.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/resolution.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/main.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/offsets/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/offsets/offsets.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/offsets/outliers.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/content.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/images.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/section.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/table.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/headline.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/introduction.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/report.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/utils/__init__.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/utils/config.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/utils/globals.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/utils/matplotlib.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/utils/series.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/utils/template.py +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/PKG-INFO +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/SOURCES.txt +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/dependency_links.txt +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/requires.txt +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/top_level.txt +0 -0
- {tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/tesoro.mplstyle +0 -0
|
@@ -49,34 +49,6 @@ La fecha se renderizará en el estilo `Subtitle` o `Subtítulo` del documento ba
|
|
|
49
49
|
- Cálculo o *prerrenderizado*: se generan las imágenes de los gráficos así como los archivos necesarios para renderizar las tablas en su formato final.
|
|
50
50
|
- *Renderizado* final.
|
|
51
51
|
|
|
52
|
-
## Sistema de lectura de archivos `.yaml`
|
|
53
|
-
El informe a generar se describe mediante unas *plantillas*, que en la práctica son archivos `.yaml`, con lo que es importante entender cómo el programa procede a la lectura de los mismos.
|
|
54
|
-
|
|
55
|
-
Todo archivo `.yaml` debe leerse a través de la función `utils.config.read_config`. Esta toma como parámetros el path al fichero a leer y un *cargador*. Siempre que se vaya a leer una *plantilla*, este cargador debe ser `utils.config.CustomLoader`, en caso contrario, puede dejarse en blanco.
|
|
56
|
-
|
|
57
|
-
En el proceso de lectura, el documento completo se representa como un objeto de tipo `MappingNode` y este es el parámetro `node` en la función `construct_mapping`.
|
|
58
|
-
|
|
59
|
-
Cada `MappingNode` contiene un atributo `value`, que en una lista de tuplas `(key_node, value_node)`
|
|
60
|
-
|
|
61
|
-
Dentro de un documento `.yaml` sencillo como
|
|
62
|
-
```yaml
|
|
63
|
-
clave1: "valor1"
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
La lista `value` solo tiene una tupla en su interior, donde:
|
|
67
|
-
- La clave o `key_node` es de tipo `ScalarNode` con tag `tag:yaml.org,2002:str` *implícito* y valor `clave1`.
|
|
68
|
-
- El valor o `value_node` también es de tipo `ScalarNode` con valor `valor1`.
|
|
69
|
-
|
|
70
|
-
En casos más complejos como
|
|
71
|
-
```yaml
|
|
72
|
-
clave2: !offset_table
|
|
73
|
-
subclave: "subvalor"
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
De nuevo, la lista `value` solo contendrá una tupla en su interior, donde:
|
|
77
|
-
- La clave es un `ScalarNode` con valor `clave2`
|
|
78
|
-
- El valor es un `MappingNode` con *tag* personalizado `!offset_table`. Su valor a su vez en una lista de tuplas bla bla bla (se ve la recursividad)
|
|
79
|
-
|
|
80
52
|
## Informes
|
|
81
53
|
- Un *informe* (*Report*) es una **clase** que contiene un diccionario de *contenidos* (*Content*)
|
|
82
54
|
- Un *cotenido* (*Content*) es un **protocolo** que permite consultar y modificar su *nivel de anidamiento* así como construirse a partir de un archivo `.yaml`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tesorotools-python"
|
|
3
|
-
version = "0.0.
|
|
4
|
-
dependencies = ["psycopg2", "SQLAlchemy", "pandas", "matplotlib", "pyarrow", "python-docx", "openpyxl", "PyYAML", "babel", "eikon"]
|
|
3
|
+
version = "0.0.2"
|
|
4
|
+
dependencies = ["psycopg2", "SQLAlchemy", "pandas", "matplotlib", "pyarrow", "python-docx", "openpyxl", "PyYAML", "babel", "eikon", "lseg-data"]
|
|
5
5
|
|
|
6
6
|
[build-system]
|
|
7
7
|
requires = ["hatchling"]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# LSEG Data Library for Python
|
|
2
|
+
|
|
3
|
+
## Capa de acceso
|
|
4
|
+
|
|
5
|
+
## Capa de contenido
|
|
6
|
+
|
|
7
|
+
## Capa de reparto
|
|
8
|
+
|
|
9
|
+
## Capa de sesión
|
|
10
|
+
|
|
11
|
+
## Referencias
|
|
12
|
+
|
|
13
|
+
- https://cdn.refinitiv.com/public/lseg-lib-python-doc/2.0.0.2/book/en/index.html
|
|
14
|
+
- https://pypi.org/project/lseg-data/
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import time
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import lseg.data as ld
|
|
5
5
|
import pandas as pd
|
|
6
6
|
|
|
7
|
+
# there should be a better way for testing this
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
def get_series(
|
|
9
11
|
api_key: str,
|
|
@@ -16,13 +18,9 @@ def get_series(
|
|
|
16
18
|
datapoint_limit: int = 2_000,
|
|
17
19
|
cache_path: Path | None = None,
|
|
18
20
|
) -> pd.DataFrame:
|
|
19
|
-
"""Downloads data from
|
|
20
|
-
|
|
21
|
-
fields =
|
|
22
|
-
["TIMESTAMP", "CLOSE", "CF_LAST", "CF_YIELD"]
|
|
23
|
-
if fields is None
|
|
24
|
-
else fields
|
|
25
|
-
)
|
|
21
|
+
"""Downloads data from LSEG given that tou have a valid API key"""
|
|
22
|
+
ld.open_session(app_key=api_key)
|
|
23
|
+
fields = ["TIMESTAMP", "CLOSE"] if fields is None else fields
|
|
26
24
|
|
|
27
25
|
dates_list: list[str] = list(
|
|
28
26
|
pd.date_range(start=start_date, end=end_date, freq=freq).astype("str")
|
|
@@ -52,15 +50,14 @@ def get_series(
|
|
|
52
50
|
fields=fields,
|
|
53
51
|
cooldown=cooldown,
|
|
54
52
|
file_path=cache_file_path,
|
|
55
|
-
debug=True,
|
|
56
53
|
)
|
|
57
54
|
if cache_file_path is None:
|
|
58
55
|
partial_data.append(data)
|
|
59
56
|
if downloaded_dates + download_step < len(dates_list):
|
|
60
|
-
print(f"Waiting {cooldown} seconds for
|
|
57
|
+
print(f"Waiting {cooldown} seconds for LSEG to cool down...")
|
|
61
58
|
time.sleep(cooldown)
|
|
62
59
|
downloaded_dates += download_step
|
|
63
|
-
data = concat_partial_data(cache_path, partial_data)
|
|
60
|
+
# data = concat_partial_data(cache_path, partial_data)
|
|
64
61
|
return data
|
|
65
62
|
|
|
66
63
|
|
|
@@ -72,22 +69,20 @@ def block_download(
|
|
|
72
69
|
fields: list[str] | None = None,
|
|
73
70
|
cooldown: int = 60,
|
|
74
71
|
file_path: Path | None = None,
|
|
75
|
-
debug: bool = False,
|
|
76
72
|
):
|
|
77
73
|
interval = "daily" if freq == "B" else freq
|
|
78
74
|
|
|
79
75
|
while True:
|
|
80
76
|
try:
|
|
81
|
-
data: pd.DataFrame | None =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fields=fields,
|
|
77
|
+
data: pd.DataFrame | None = ld.get_history(
|
|
78
|
+
universe=series_id_list,
|
|
79
|
+
start=start_date,
|
|
80
|
+
end=end_date,
|
|
81
|
+
# fields=fields,
|
|
86
82
|
interval=interval,
|
|
87
|
-
debug=debug,
|
|
88
83
|
)
|
|
89
84
|
if data is None:
|
|
90
|
-
raise
|
|
85
|
+
raise ld.errors.LDError(
|
|
91
86
|
code=404, message="Service temporarily unavailable"
|
|
92
87
|
)
|
|
93
88
|
data = data.drop_duplicates()
|
|
@@ -97,10 +92,10 @@ def block_download(
|
|
|
97
92
|
if file_path is not None:
|
|
98
93
|
data.to_csv(file_path)
|
|
99
94
|
break
|
|
100
|
-
except
|
|
101
|
-
print(f"
|
|
95
|
+
except ld.errors.LDError as e:
|
|
96
|
+
print(f"LSEG error: {e}")
|
|
102
97
|
print("This is probably not our fault")
|
|
103
|
-
print(f"Waiting {cooldown} seconds for
|
|
98
|
+
print(f"Waiting {cooldown} seconds for LSEG to cool down...")
|
|
104
99
|
time.sleep(cooldown)
|
|
105
100
|
return data
|
|
106
101
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/data_sources/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/dependencies/resolution.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/__init__.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/content.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/images.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/section.py
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/content/table.py
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools/render/introduction.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/PKG-INFO
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/requires.txt
RENAMED
|
File without changes
|
{tesorotools_python-0.0.0 → tesorotools_python-0.0.2}/src/tesorotools_python.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|