luxorasap 0.1.14__py3-none-any.whl → 0.1.16__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.
- luxorasap/__init__.py +1 -1
- luxorasap/datareader/core.py +10 -3
- luxorasap/utils/storage/blob.py +24 -6
- {luxorasap-0.1.14.dist-info → luxorasap-0.1.16.dist-info}/METADATA +1 -1
- {luxorasap-0.1.14.dist-info → luxorasap-0.1.16.dist-info}/RECORD +8 -8
- {luxorasap-0.1.14.dist-info → luxorasap-0.1.16.dist-info}/WHEEL +0 -0
- {luxorasap-0.1.14.dist-info → luxorasap-0.1.16.dist-info}/entry_points.txt +0 -0
- {luxorasap-0.1.14.dist-info → luxorasap-0.1.16.dist-info}/top_level.txt +0 -0
luxorasap/__init__.py
CHANGED
|
@@ -13,7 +13,7 @@ from types import ModuleType
|
|
|
13
13
|
try:
|
|
14
14
|
__version__: str = metadata.version(__name__)
|
|
15
15
|
except metadata.PackageNotFoundError: # editable install
|
|
16
|
-
__version__ = "0.1.
|
|
16
|
+
__version__ = "0.1.16"
|
|
17
17
|
|
|
18
18
|
# ─── Lazy loader ─────────────────────────────────────────────────
|
|
19
19
|
def __getattr__(name: str) -> ModuleType:
|
luxorasap/datareader/core.py
CHANGED
|
@@ -297,9 +297,10 @@ class LuxorQuery:
|
|
|
297
297
|
last_date_df["Last_Price"] = last_prices.values
|
|
298
298
|
|
|
299
299
|
table = (pd.concat([table, last_date_df]).sort_values(by="Date")
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
.set_index("Date").groupby("Asset")
|
|
301
|
+
.apply(lambda g: g[~g.index.duplicated(keep="first")].resample("D").ffill(),
|
|
302
|
+
include_groups=False).reset_index(level=0, drop=True)
|
|
303
|
+
.reset_index())
|
|
303
304
|
|
|
304
305
|
self.price_tables_loaded[table_key] = table
|
|
305
306
|
|
|
@@ -648,6 +649,12 @@ class LuxorQuery:
|
|
|
648
649
|
prices = prices.set_index("Date").groupby("Asset")\
|
|
649
650
|
.resample("D").last().ffill()\
|
|
650
651
|
.reset_index(level=0, drop=True).reset_index()
|
|
652
|
+
# Precisará ser substituido pela linha abaixo no futuro
|
|
653
|
+
# Porém ha perda de eficiencia, avaliar outras opções.
|
|
654
|
+
#prices = prices.set_index("Date").groupby("Asset", group_keys=False)\
|
|
655
|
+
# .apply(lambda g: g.resample("D").last().ffill().assign(Asset=g.name),
|
|
656
|
+
# include_groups=False).reset_index()
|
|
657
|
+
|
|
651
658
|
|
|
652
659
|
if get_intraday_prices:
|
|
653
660
|
prices = self.__hist_prices_intraday_extensor(prices)
|
luxorasap/utils/storage/blob.py
CHANGED
|
@@ -4,6 +4,7 @@ from datetime import timezone
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
import pyarrow as pa, pyarrow.parquet as pq
|
|
6
6
|
from azure.storage.blob import BlobServiceClient
|
|
7
|
+
import tempfile
|
|
7
8
|
|
|
8
9
|
from ..dataframe import read_bytes
|
|
9
10
|
|
|
@@ -33,13 +34,30 @@ class BlobParquetClient:
|
|
|
33
34
|
return None, False
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
def write_df(self, df, blob_path: str):
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
def write_df(self, df, blob_path: str, large_df: bool = False):
|
|
38
|
+
if not large_df:
|
|
39
|
+
table = pa.Table.from_pandas(df)
|
|
40
|
+
buf = io.BytesIO()
|
|
41
|
+
pq.write_table(table, buf)
|
|
42
|
+
buf.seek(0)
|
|
43
|
+
self._blob(blob_path).upload_blob(buf, overwrite=True)
|
|
42
44
|
|
|
45
|
+
else:
|
|
46
|
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".parquet") as f:
|
|
47
|
+
writer = None
|
|
48
|
+
chunk_size = 100_000
|
|
49
|
+
for i in range(0, len(df), chunk_size):
|
|
50
|
+
chunk = pa.Table.from_pandas(df.iloc[i:i+chunk_size])
|
|
51
|
+
if writer is None:
|
|
52
|
+
writer = pq.ParquetWriter(f.name, chunk.schema)
|
|
53
|
+
writer.write_table(chunk)
|
|
54
|
+
writer.close()
|
|
55
|
+
|
|
56
|
+
with open(f.name, "rb") as f_read:
|
|
57
|
+
self._blob(blob_path).upload_blob(f_read, overwrite=True)
|
|
58
|
+
|
|
59
|
+
os.remove(f.name)
|
|
60
|
+
|
|
43
61
|
|
|
44
62
|
def get_df_update_time(self, blob_path: str) -> float:
|
|
45
63
|
try:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
luxorasap/__init__.py,sha256=
|
|
1
|
+
luxorasap/__init__.py,sha256=UttBxtiTnV8vcvDfAuiUk_-P_7eERzUTP6tN_rt13CM,1356
|
|
2
2
|
luxorasap/btgapi/__init__.py,sha256=QUlfb5oiBY6K1Q5x4-a-x2wECe1At5wc2962I5odOJk,620
|
|
3
3
|
luxorasap/btgapi/auth.py,sha256=PvyCtbEyBO2B1CIeAlNXWugKW1OgiKfPcVzS6K5FBnQ,1872
|
|
4
4
|
luxorasap/btgapi/reports.py,sha256=ZVEMLoJPXc0r3XjPJPMsKQN0zZd1Npd7umNpAj1bncs,8040
|
|
5
5
|
luxorasap/btgapi/trades.py,sha256=956HZ9BvN9C_VQvKTyBLN0x6ZygwVqBZN11F7OnNbDI,5985
|
|
6
6
|
luxorasap/datareader/__init__.py,sha256=41RAvbrQ4R6oj67S32CrKqolx0CJ2W8cbOF6g5Cqm2g,120
|
|
7
|
-
luxorasap/datareader/core.py,sha256=
|
|
7
|
+
luxorasap/datareader/core.py,sha256=P8AjtRFRRmUrqjbjfKRb0wTLW2eHcUva8iWid4uh4PE,155123
|
|
8
8
|
luxorasap/ingest/__init__.py,sha256=XhxDTN2ar-u6UCPhnxNU_to-nWiit-SpQ6cA_N9eMSs,795
|
|
9
9
|
luxorasap/ingest/cloud/__init__.py,sha256=Hm-43YkjRhu3UiFVt1Zx7DmQuNJnK2GVWfCx1T3gKNc,2052
|
|
10
10
|
luxorasap/ingest/legacy_local/dataloader.py,sha256=zKPhuiBSFwkuWN6d8g2s60KkbVk1R_1cGMCtQM9j-0c,11908
|
|
@@ -13,9 +13,9 @@ luxorasap/utils/dataframe/__init__.py,sha256=dU_RwTTOi6F3mlhM-0MYWM_qexBN9BmmKc_
|
|
|
13
13
|
luxorasap/utils/dataframe/reader.py,sha256=Vzjdw-AeS1lnWEHQ8RZNh0kK93NWTp0NWVi_B6mN5N0,616
|
|
14
14
|
luxorasap/utils/dataframe/transforms.py,sha256=Bm_cv9L9923QIXH82Fa_M4pM94f2AJRPu62Vv_i7tto,1684
|
|
15
15
|
luxorasap/utils/storage/__init__.py,sha256=U3XRq94yzRp3kgBSUcRzs2tQgJ4o8h8a1ZzwiscA5XM,67
|
|
16
|
-
luxorasap/utils/storage/blob.py,sha256=
|
|
17
|
-
luxorasap-0.1.
|
|
18
|
-
luxorasap-0.1.
|
|
19
|
-
luxorasap-0.1.
|
|
20
|
-
luxorasap-0.1.
|
|
21
|
-
luxorasap-0.1.
|
|
16
|
+
luxorasap/utils/storage/blob.py,sha256=MVGOXnZR62jJPNWIM8sH_-DF-WuxMFVlpmi1llfos78,3949
|
|
17
|
+
luxorasap-0.1.16.dist-info/METADATA,sha256=57mpWpSd3Frlwy4wQCOa6wPcn5ADTIeXRu3_NBZ3RsE,3804
|
|
18
|
+
luxorasap-0.1.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
luxorasap-0.1.16.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
|
|
20
|
+
luxorasap-0.1.16.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
|
|
21
|
+
luxorasap-0.1.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|