tesorotools-python 0.0.0__py2.py3-none-any.whl → 0.0.2__py2.py3-none-any.whl
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/data_sources/README.md +14 -0
- tesorotools/data_sources/{eikon.py → lseg.py} +17 -22
- {tesorotools_python-0.0.0.dist-info → tesorotools_python-0.0.2.dist-info}/METADATA +2 -1
- {tesorotools_python-0.0.0.dist-info → tesorotools_python-0.0.2.dist-info}/RECORD +5 -4
- {tesorotools_python-0.0.0.dist-info → tesorotools_python-0.0.2.dist-info}/WHEEL +0 -0
|
@@ -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
|
|
|
@@ -6,9 +6,10 @@ tesorotools/artists/barh_plot.py,sha256=3KkoT0DLkctzYNMV3Pz1EcAT9i29YGYSkTLTFNb3
|
|
|
6
6
|
tesorotools/artists/line_plot.py,sha256=BqOHnmVB6fL0ElN_WDpvCzP0L7O2-mp6ULfHo3qwiCI,3405
|
|
7
7
|
tesorotools/artists/table.py,sha256=CjyjWivn5YrNP5m8_eWi-ZA7R1ts3aIhATrYMEgTuOU,7651
|
|
8
8
|
tesorotools/artists/type_curve.py,sha256=VGFCCyMVNwjliLK9usyw_nLC6emKcJYOSV1pmWJQNXk,6463
|
|
9
|
+
tesorotools/data_sources/README.md,sha256=iMAeLsv9Xk3IogDh8nCt2pSeTqCHmXA66KPvV25Za7I,261
|
|
9
10
|
tesorotools/data_sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
11
|
tesorotools/data_sources/debug.py,sha256=fmUHt7f3dAd6qUBo5D_kTn__MgGC0hisdaC6sFXHKNg,877
|
|
11
|
-
tesorotools/data_sources/
|
|
12
|
+
tesorotools/data_sources/lseg.py,sha256=YxU9G2yq0cLsKSpYQP6XnW8DH59DFRBc018SfkY8qY0,3643
|
|
12
13
|
tesorotools/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
14
|
tesorotools/database/push.py,sha256=Y1ToNupMIdNfXcg20P0sFijXza05FUCB1OK53cPXYtU,1960
|
|
14
15
|
tesorotools/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -33,6 +34,6 @@ tesorotools/utils/globals.py,sha256=gFhNjCjeih7NaNEb6yjgoJbkTSUuJu9Xw5-UDtCPAQA,
|
|
|
33
34
|
tesorotools/utils/matplotlib.py,sha256=tKidZIcDLKWgawIOJggWwVoaTMsrjw1WEJQouydSYbI,1197
|
|
34
35
|
tesorotools/utils/series.py,sha256=eUEUOdzDfA7YbgO4o6KtxwJOL5cQYdqLjrdvuQ7Hqhc,1168
|
|
35
36
|
tesorotools/utils/template.py,sha256=xpBVad28gG9ZLVwd9e0dTWsGsbujjmVcCPEW2mIKEJo,4917
|
|
36
|
-
tesorotools_python-0.0.
|
|
37
|
-
tesorotools_python-0.0.
|
|
38
|
-
tesorotools_python-0.0.
|
|
37
|
+
tesorotools_python-0.0.2.dist-info/METADATA,sha256=yNrZhBJ5ULwC_cNCPbn40rP3D9XpjbMhKIC4YHNRrwU,323
|
|
38
|
+
tesorotools_python-0.0.2.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
|
39
|
+
tesorotools_python-0.0.2.dist-info/RECORD,,
|
|
File without changes
|