luxorasap 0.1.2__py3-none-any.whl → 0.1.3__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 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.2"
16
+ __version__ = "0.1.3"
17
17
 
18
18
  # ─── Lazy loader ─────────────────────────────────────────────────
19
19
  def __getattr__(name: str) -> ModuleType:
@@ -1,7 +1,7 @@
1
1
  """Wrapper para as APIs do BTG Pactual."""
2
2
 
3
3
  from .auth import get_access_token, BTGApiError
4
- from .reports import request_portfolio, await_report_ticket_result, process_zip_to_dfs, request_investors_transactions_report
4
+ from .reports import request_portfolio, await_report_ticket_result, process_zip_to_dfs, request_investors_transactions_report, request_fundflow_report
5
5
  from .trades import submit_offshore_equity_trades, await_transaction_ticket_result
6
6
 
7
7
  __all__ = [
@@ -12,5 +12,6 @@ __all__ = [
12
12
  "submit_offshore_equity_trades",
13
13
  "await_transaction_ticket_result",
14
14
  "process_zip_to_dfs",
15
- "request_investors_transactions_report"
15
+ "request_investors_transactions_report",
16
+ "request_fundflow_report",
16
17
  ]
@@ -16,7 +16,8 @@ __all__ = [
16
16
  "check_report_ticket",
17
17
  "await_report_ticket_result",
18
18
  "process_zip_to_dfs",
19
- "request_investors_transactions_report"
19
+ "request_investors_transactions_report",
20
+ "request_fundflow_report"
20
21
  ]
21
22
 
22
23
  _REPORT_ENDPOINT = "https://funds.btgpactual.com/reports/Portfolio"
@@ -24,6 +25,7 @@ _TICKET_ENDPOINT = "https://funds.btgpactual.com/reports/Ticket"
24
25
  _INVESTOR_TX_ENDPOINT = (
25
26
  "https://funds.btgpactual.com/reports/RTA/InvestorTransactionsFileReport"
26
27
  )
28
+ _FUNDFLOW_ENDPOINT = "https://funds.btgpactual.com/reports/RTA/FundFlow"
27
29
  _REPORT_TYPES = {"excel": 10, "xml5": 81, "pdf": 2}
28
30
 
29
31
 
@@ -105,6 +107,15 @@ def check_report_ticket(token: str, ticket: str, *, page: Optional[int] = None)
105
107
  return _download_url(url)
106
108
  except Exception as exc:
107
109
  raise BTGApiError(f"Falha ao interpretar resultado: {exc}") from exc
110
+
111
+ # 4. result pode ser uma lista de dados
112
+ if isinstance(result, list):
113
+ # Vamos tentar transformar num dataframe e retornar
114
+ try:
115
+ df = pd.DataFrame(result)
116
+ return df
117
+ except Exception as exc:
118
+ raise BTGApiError(f"Falha ao converter resultado em DataFrame: {exc}") from exc
108
119
 
109
120
  raise BTGApiError("Formato de resposta desconhecido")
110
121
 
@@ -186,4 +197,43 @@ def request_investors_transactions_report( token: str, query_date: dt.date, *,
186
197
  return r.json()["ticket"]
187
198
  raise BTGApiError(
188
199
  f"Erro InvestorTransactionsFileReport: {r.status_code} – {r.text}"
189
- )
200
+ )
201
+
202
+
203
+ def request_fundflow_report( token: str, start_date: dt.date,
204
+ end_date: dt.date, *, fund_name: str = "", date_type: str = "LIQUIDACAO", page_size: int = 100) -> str:
205
+ """Dispara geração do **Fund Flow** (RTA) e devolve *ticket*.
206
+
207
+ Args:
208
+ token: JWT obtido via :pyfunc:`luxorasap.btgapi.get_access_token`.
209
+ start_date,end_date: Datas do intervalo desejado.
210
+ fund_name: Nome do fundo conforme BTG. String vazia retorna as movimentacoes para todos os fundos.
211
+ date_type: Enum da API (`LIQUIDACAO`, `MOVIMENTO`, etc.).
212
+ page_size: Página retornada por chamada (default 100).
213
+
214
+ Returns
215
+ -------
216
+ str
217
+ ID do ticket a ser acompanhado em :pyfunc:`await_fundflow_ticket_result`.
218
+ """
219
+
220
+ body = {
221
+ "contract": {
222
+ "startDate": f"{start_date}T00:00:00Z",
223
+ "endDate": f"{end_date}T00:00:00Z",
224
+ "dateType": date_type,
225
+ "fundName": fund_name,
226
+ },
227
+ "pageSize": page_size,
228
+ "webhookEndpoint": "string",
229
+ }
230
+
231
+ r = requests.post(
232
+ _FUNDFLOW_ENDPOINT,
233
+ headers={"X-SecureConnect-Token": token, "Content-Type": "application/json"},
234
+ json=body,
235
+ timeout=30,
236
+ )
237
+ if r.ok:
238
+ return r.json()["ticket"]
239
+ raise BTGApiError(f"Erro FundFlow: {r.status_code} - {r.text}")
@@ -20,8 +20,15 @@ def save_table(
20
20
  index_name: str = "index",
21
21
  normalize_columns: bool = True,
22
22
  directory: str = "enriched/parquet",
23
+ override=False
23
24
  ):
24
25
  """Salva DataFrame como Parquet em ADLS (sobrescrevendo)."""
26
+
27
+ if override == False:
28
+ lq = LuxorQuery()
29
+ if lq.table_exists(table_name):
30
+ return
31
+
25
32
  df = prep_for_save(df, index=index, index_name=index_name, normalize=normalize_columns)
26
33
  _client.write_df(df.astype(str), f"{directory}/{table_name}.parquet")
27
34
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luxorasap
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: Luxor’s unified toolbox for data ingestion, querying and analytics.
5
5
  Author-email: Luxor Group <backoffice@luxor.com.br>
6
6
  License: Proprietary – All rights reserved
@@ -1,12 +1,12 @@
1
- luxorasap/__init__.py,sha256=Y5nnDcLGJ3_HtgLuOZcpM_FwSUlFBjrylPnr8xjAPIw,1355
2
- luxorasap/btgapi/__init__.py,sha256=DISzvHp-J7oeNq_PhmCt-_ZRBCaUgkQ9k2wtJLm-kgs,563
1
+ luxorasap/__init__.py,sha256=Zv3_ZOZLgZtlPZbbKiM743UmDx6FN7-iHv4U5qUlro4,1355
2
+ luxorasap/btgapi/__init__.py,sha256=QUlfb5oiBY6K1Q5x4-a-x2wECe1At5wc2962I5odOJk,620
3
3
  luxorasap/btgapi/auth.py,sha256=2TLKZdVlJgfSItOvB7GoPnH6gndkWWqSIyE4VDSYRgo,1873
4
- luxorasap/btgapi/reports.py,sha256=WSuJws9foki4i6URa9muKasOvzD6G11b-GVKvl9V5BA,6186
4
+ luxorasap/btgapi/reports.py,sha256=UEk5QAl4cS6vdxXyliyg-weT0C1mILE1bqilPRDuHPE,7975
5
5
  luxorasap/btgapi/trades.py,sha256=1Cn1RMjaHO073YHJFeN2XRxYElQH7A98GIfUVy0VmSg,5987
6
6
  luxorasap/datareader/__init__.py,sha256=41RAvbrQ4R6oj67S32CrKqolx0CJ2W8cbOF6g5Cqm2g,120
7
7
  luxorasap/datareader/core.py,sha256=LpXe5g4lZpfEqaz_gjjHizVA-vPEjBi5yJKg_7K0Nkw,153205
8
8
  luxorasap/ingest/__init__.py,sha256=XhxDTN2ar-u6UCPhnxNU_to-nWiit-SpQ6cA_N9eMSs,795
9
- luxorasap/ingest/cloud/__init__.py,sha256=MfnEYUav0AD6oxs92ghE8TtxdqcQkb_VB6z706m-2nw,1727
9
+ luxorasap/ingest/cloud/__init__.py,sha256=lbb3GweA8m0mQuH64HCKwO5FLwih4orU7i9KNhWWAkk,1867
10
10
  luxorasap/ingest/legacy_local/dataloader.py,sha256=zKPhuiBSFwkuWN6d8g2s60KkbVk1R_1cGMCtQM9j-0c,11908
11
11
  luxorasap/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  luxorasap/utils/dataframe/__init__.py,sha256=dU_RwTTOi6F3mlhM-0MYWM_qexBN9BmmKc_yrDE1Lwc,207
@@ -14,8 +14,8 @@ luxorasap/utils/dataframe/reader.py,sha256=Vzjdw-AeS1lnWEHQ8RZNh0kK93NWTp0NWVi_B
14
14
  luxorasap/utils/dataframe/transforms.py,sha256=Bm_cv9L9923QIXH82Fa_M4pM94f2AJRPu62Vv_i7tto,1684
15
15
  luxorasap/utils/storage/__init__.py,sha256=U3XRq94yzRp3kgBSUcRzs2tQgJ4o8h8a1ZzwiscA5XM,67
16
16
  luxorasap/utils/storage/blob.py,sha256=pcEixGxwXM9y5iPPpkX__ySWq0milghJGketYZlRL-0,3171
17
- luxorasap-0.1.2.dist-info/METADATA,sha256=imZHJdmbV6ClMwMi29J3rsJTmfVZ7bip5S_aW9ew6Xk,6994
18
- luxorasap-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- luxorasap-0.1.2.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
20
- luxorasap-0.1.2.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
21
- luxorasap-0.1.2.dist-info/RECORD,,
17
+ luxorasap-0.1.3.dist-info/METADATA,sha256=gom3LK0bhLeQS83_rCGv7xfmw6MnoFPzh46tL5jNqwg,6994
18
+ luxorasap-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ luxorasap-0.1.3.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
20
+ luxorasap-0.1.3.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
21
+ luxorasap-0.1.3.dist-info/RECORD,,