From 2730654c6e82085efdafdf7a72bc87d4147c7a97 Mon Sep 17 00:00:00 2001 From: AndresXLP Date: Fri, 11 Jul 2025 11:11:16 -0500 Subject: [PATCH] feat(adem): add support for DMNR and PRNR attributes in ASIC file definitions - bump ASIC version to 0.4.3 - resolve case sensitivity issue for PTB constant - update tests --- src/asic/VERSION | 2 +- src/asic/files/definitions/adem.py | 6 ++++-- src/asic/files/file.py | 2 +- tests/TEST_ASIC_FILE_CONFIG.jsonl | 2 +- tests/conftest.py | 4 ++-- tests/test_adem.py | 3 ++- tests/test_ptb.py | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/asic/VERSION b/src/asic/VERSION index f7abe27..70d5b25 100644 --- a/src/asic/VERSION +++ b/src/asic/VERSION @@ -1 +1 @@ -0.4.2 \ No newline at end of file +0.4.3 \ No newline at end of file diff --git a/src/asic/files/definitions/adem.py b/src/asic/files/definitions/adem.py index 658b4dc..a542b54 100644 --- a/src/asic/files/definitions/adem.py +++ b/src/asic/files/definitions/adem.py @@ -97,13 +97,15 @@ def preprocess(self, target: Path | BytesIO | StringIO) -> pd.DataFrame: EPSC: Código SIC del agente comercializador CODIGO: DMRE: demanda regulada + DMNR: demanda no regulada PRRE: perdidas reguladas + PRNR: perdidas no reguladas """ total = self.read(target) total["FECHA"] = f"{self.year:04d}-{self.month:02d}-{self.day:02d}" filter = np.full(total.index.shape, True) - filter = filter & (total["CODIGO"].isin(["DMRE", "PRRE"])) + filter = filter & (total["CODIGO"].isin(["DMRE", "PRRE","DMNR","PRNR"])) total = total[filter] total["FECHA"] = pd.to_datetime( @@ -145,6 +147,6 @@ def preprocess(self, target: Path | BytesIO | StringIO) -> pd.DataFrame: ) ] total.columns = cols # type: ignore - return_cols = ["FECHA_HORA", "AGENTE", "DMRE_VALOR", "PRRE_VALOR"] + return_cols = ["FECHA_HORA", "AGENTE", "DMRE_VALOR", "PRRE_VALOR","DMNR_VALOR","PRNR_VALOR"] return total[return_cols] diff --git a/src/asic/files/file.py b/src/asic/files/file.py index ccd20cb..58b59b0 100644 --- a/src/asic/files/file.py +++ b/src/asic/files/file.py @@ -71,7 +71,7 @@ class FileKind(str, enum.Enum): SNTIE = "sntie" AFAC = "afac" DSPCTTOS = "dspcttos" - PTB = "ptb" + PTB = "PTB" # LDCBMR = "ldcbmr" # PUBFC = "pubfc" diff --git a/tests/TEST_ASIC_FILE_CONFIG.jsonl b/tests/TEST_ASIC_FILE_CONFIG.jsonl index c466df8..4b66a4b 100644 --- a/tests/TEST_ASIC_FILE_CONFIG.jsonl +++ b/tests/TEST_ASIC_FILE_CONFIG.jsonl @@ -19,4 +19,4 @@ {"code":"trsm", "visibility": "public","name_pattern":"(?Ptrsm)(?P[0-9]{2}).(?P[a-zA-Z0-9]+)","location_pattern":"/RUTA/PUBLICA/DEL/FTP/(?P[0-9]{4})-(?P[0-9]{2})/","description":"Contiene información de indicadores económicos, energéticos y financieros."} {"code":"afac", "visibility": "public","name_pattern":"(?Pafac)(?P[0-9]{2}).(?P[a-zA-Z0-9]+)","location_pattern":"/RUTA/PUBLICA/DEL/FTP/(?P[0-9]{4})-(?P[0-9]{2})/","description":"Muestra para cada uno de los agentes, todos los conceptos de la liquidación del Mercado Colombiano, con los cuales se pueden consolidar las Compras y Ventas Totales del Agente para un proceso de liquidación o ajuste mensual."} {"code":"tserv", "visibility": "public","name_pattern":"(?Ptserv)(?P[0-9]{2}).(?P[a-zA-Z0-9]+)","location_pattern":"/RUTA/PUBLICA/DEL/FTP/(?P[0-9]{4})-(?P[0-9]{2})/","description":"Contiene el soporte a la liquidación de servicios CND, s y FAZNI."} -{"code":"ptb", "visibility": "public", "name_pattern":"(?Pptb)(?P[0-9]{2})(?P[0-9]{2}).(?P[a-zA-Z0-9]+)","location_pattern":"/RUTA/PUBLICA/DEL/FTP/(?P[0-9]{4})-(?P[0-9]{2})/","description":"El PTB considera tres techos en las transacciones en bolsa cuando el precio de bolsa es mayor a cualquiera de los precios de escasez."} +{"code":"PTB", "visibility": "public", "name_pattern":"(?PPTB)(?P[0-9]{2})(?P[0-9]{2}).(?P[a-zA-Z0-9]+)","location_pattern":"/RUTA/PUBLICA/DEL/FTP/(?P[0-9]{4})-(?P[0-9]{2})/","description":"El PTB considera tres techos en las transacciones en bolsa cuando el precio de bolsa es mayor a cualquiera de los precios de escasez."} diff --git a/tests/conftest.py b/tests/conftest.py index 81ac526..c523366 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -160,9 +160,9 @@ "version": "003", "agent": "xxxc", }, - "ptb": { + "PTB": { "path": "/RUTA/PUBLICA/DEL/FTP/2025-04/PTB0401.txf", - "kind": "ptb", + "kind": "PTB", "visibility": "public", "year": 2025, "month": 4, diff --git a/tests/test_adem.py b/tests/test_adem.py index 2e77b54..a83c08c 100644 --- a/tests/test_adem.py +++ b/tests/test_adem.py @@ -38,4 +38,5 @@ def test_adem_read(adem_file: ADEM, local_adem_file): @TESTFILES def test_adem_preprocess(adem_file: ADEM, local_adem_file): long_data = adem_file.preprocess(local_adem_file) - assert len(long_data) == 1128 + print(len(long_data)) + assert len(long_data) == 1536 diff --git a/tests/test_ptb.py b/tests/test_ptb.py index f8797b4..d60826a 100644 --- a/tests/test_ptb.py +++ b/tests/test_ptb.py @@ -9,7 +9,7 @@ @fixture def ptb_remote_path(): - ptb_path = ALL_FILES["ptb"]["path"] + ptb_path = ALL_FILES["PTB"]["path"] path = pathlib.PureWindowsPath(ptb_path) return path