btgsolutions-dataservices-python-client 4.5.0__tar.gz → 4.6.0__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.
Files changed (49) hide show
  1. {btgsolutions_dataservices_python_client-4.5.0/btgsolutions_dataservices_python_client.egg-info → btgsolutions_dataservices_python_client-4.6.0}/PKG-INFO +24 -15
  2. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/README.md +116 -94
  3. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/__init__.py +1 -1
  4. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_catalog.py +38 -18
  5. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_companies.py +17 -7
  6. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_ownership.py +15 -7
  7. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/bulk_data.py +40 -2
  8. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0/btgsolutions_dataservices_python_client.egg-info}/PKG-INFO +25 -16
  9. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/LICENSE +0 -0
  10. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/MANIFEST.in +0 -0
  11. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/config.py +0 -0
  12. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/exceptions.py +0 -0
  13. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/__init__.py +0 -0
  14. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_funds.py +0 -0
  15. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_macro_markets.py +0 -0
  16. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_metadata.py +0 -0
  17. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/alternative_data_people.py +0 -0
  18. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/authenticator.py +0 -0
  19. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/book_scope.py +0 -0
  20. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/broker_analytics.py +0 -0
  21. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/broker_reference.py +0 -0
  22. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/company_data.py +0 -0
  23. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
  24. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/dataservices_catalog.py +0 -0
  25. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/hfn.py +0 -0
  26. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/historical_candles.py +0 -0
  27. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/historical_candles_crypto.py +0 -0
  28. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/intraday_candles.py +0 -0
  29. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
  30. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/public_sources.py +0 -0
  31. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/quotes.py +0 -0
  32. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/reference_data.py +0 -0
  33. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/stock_loan.py +0 -0
  34. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/ticker_last_event.py +0 -0
  35. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/rest/ticker_last_event_polling.py +0 -0
  36. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/websocket/__init__.py +0 -0
  37. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/websocket/broker_analytics.py +0 -0
  38. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
  39. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/websocket/market_data_feed.py +0 -0
  40. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +0 -0
  41. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
  42. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +0 -0
  43. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
  44. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices_python_client.egg-info/requires.txt +0 -0
  45. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
  46. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/pyproject.toml +0 -0
  47. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/requirements.txt +0 -0
  48. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/setup.cfg +0 -0
  49. {btgsolutions_dataservices_python_client-4.5.0 → btgsolutions_dataservices_python_client-4.6.0}/setup.py +0 -0
@@ -1,25 +1,12 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: btgsolutions_dataservices_python_client
3
- Version: 4.5.0
3
+ Version: 4.6.0
4
4
  Summary: Python package containing several classes and data for extracting and manipulating market and trading data.
5
5
  Home-page: https://github.com/BTG-Pactual-Solutions/btgsolutions-dataservices-python-client
6
6
  Author: BTG Solutions Data Services powered by BTG Pactual Solutions
7
7
  Requires-Python: >=3.9,<3.15
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
- Requires-Dist: pandas>=2.2.2
11
- Requires-Dist: websocket-client>=1.8.0
12
- Requires-Dist: PyJWT>=2.8.0
13
- Requires-Dist: requests>=2.32.3
14
- Requires-Dist: pyarrow>=17.0.0
15
- Dynamic: author
16
- Dynamic: description
17
- Dynamic: description-content-type
18
- Dynamic: home-page
19
- Dynamic: license-file
20
- Dynamic: requires-dist
21
- Dynamic: requires-python
22
- Dynamic: summary
23
10
 
24
11
  # BTG Solutions - Data Services
25
12
 
@@ -351,6 +338,15 @@ bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
351
338
  # bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='instrument-status')
352
339
  ```
353
340
 
341
+ ##### Get Data With Billing Headers
342
+
343
+ ```python
344
+ import btgsolutions_dataservices as btg
345
+ bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
346
+ df, billing_headers = bulk_data.get_data(ticker='PETR4', date='2025-06-20', data_type='trades', return_billing_headers=True)
347
+ # billing_headers = bulk_data.get_data(ticker='PETR4', date='2025-06-20', data_type='trades', dry_run=True)
348
+ ```
349
+
354
350
  ##### Security List
355
351
 
356
352
  ```python
@@ -620,6 +616,12 @@ companies.get_disclosures(company_id='PETR4', document_type='repurchase')
620
616
  companies.get_disclosures(company_id='PETR4', document_type='insider')
621
617
  ```
622
618
 
619
+ For Brazilian governance endpoints, current board and summary responses prefer
620
+ the latest raw FRE filing when available. Returned governance summaries can
621
+ include `latest_reference_date`, `latest_version`, `latest_document_id` and
622
+ `structure_source`; alternate B3 tickers/units such as `BPAC11` can resolve to
623
+ the underlying listed company when covered by the source metadata.
624
+
623
625
  #### Alternative Data - People
624
626
 
625
627
  ```python
@@ -661,6 +663,13 @@ ownership.get_institutional_holders(identifier='VALE3')
661
663
  ownership.get_fund_holders(identifier='PETR4', identifier_type='b3_ticker')
662
664
  ```
663
665
 
666
+ For Brazilian ownership/free-float endpoints, current control and free-float
667
+ responses use the latest FRE source document/version for the selected reference
668
+ date when available. Repeated older source documents are deduplicated where
669
+ possible, while distinct rows for the same holder across classes, roles or
670
+ ownership categories are preserved. Zero free-float or independence percentages
671
+ can be valid source values, not missing data.
672
+
664
673
  #### Alternative Data - Macro & Markets
665
674
 
666
675
  ```python
@@ -328,6 +328,15 @@ bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
328
328
  # bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='instrument-status')
329
329
  ```
330
330
 
331
+ ##### Get Data With Billing Headers
332
+
333
+ ```python
334
+ import btgsolutions_dataservices as btg
335
+ bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
336
+ df, billing_headers = bulk_data.get_data(ticker='PETR4', date='2025-06-20', data_type='trades', return_billing_headers=True)
337
+ # billing_headers = bulk_data.get_data(ticker='PETR4', date='2025-06-20', data_type='trades', dry_run=True)
338
+ ```
339
+
331
340
  ##### Security List
332
341
 
333
342
  ```python
@@ -494,71 +503,71 @@ company_data.interims(ticker='PETR4')
494
503
 
495
504
  ```python
496
505
  import btgsolutions_dataservices as btg
497
- company_data = btg.CompanyData(api_key='YOUR_API_KEY')
498
- company_data.all_financial_tables(ticker='PETR4')
499
- ```
500
-
501
- #### REST Technical Catalogs
502
-
503
- Technical endpoint descriptions for REST APIs are exported by the package so
504
- MCPs and other connectors can reuse the same source of truth instead of
505
- duplicating endpoint semantics locally.
506
-
507
- ```python
508
- from btgsolutions_dataservices.rest import (
509
- DATASERVICES_ENDPOINTS,
510
- DATASERVICES_ENDPOINT_RELATIONSHIPS,
511
- get_dataservices_tool_description,
512
- )
513
-
514
- print(get_dataservices_tool_description("get_quotes"))
515
- print(get_dataservices_tool_description("get_book_scope"))
516
- ```
517
-
518
- The Data Services catalog covers quotes, candles, intraday trades, last events,
519
- reference data, corporate events, company fundamental data, HFN news,
520
- stock-loan data, bulk market data, broker reference, broker analytics and
521
- book-scope endpoints. It documents parameters, endpoint relationships such as
522
- available-ticker discovery before market-data calls, broker-reference discovery
523
- before broker analytics, HFN filter discovery before news queries, corporate
524
- events before adjusted price analysis, and book-scope constraints for
525
- microstructure analysis.
526
-
527
- The REST catalogs also document cross-domain relationships between Public
528
- Sources and market-data services: company directory resolution feeds ticker
529
- reference, quotes, candles, stock-loan, broker analytics and book-scope tools;
530
- sector classification feeds peer-market comparisons; fund holdings feed
531
- underlying ticker market analysis; ownership/free-float feeds liquidity context;
532
- and disclosures, official notices, HFN news and corporate events feed event
533
- window analysis.
534
-
535
- #### Alternative Data - Metadata
536
-
537
- Technical endpoint descriptions for the public-sources alternative-data APIs are
538
- exported by the package so MCPs and other connectors can reuse the same source
539
- of truth:
540
-
541
- ```python
542
- from btgsolutions_dataservices.rest import (
543
- PUBLIC_SOURCES_ENDPOINTS,
544
- PUBLIC_SOURCES_ENDPOINT_RELATIONSHIPS,
545
- get_public_sources_tool_description,
546
- )
547
-
548
- print(get_public_sources_tool_description("get_company_board"))
549
- ```
550
-
551
- The catalog documents endpoint parameters, known data gaps, excluded endpoints,
552
- and relationships such as: company metadata resolving identifiers for governance
553
- and ownership calls; macro indicator metadata feeding macro observations; asset
554
- metadata feeding maximum-theoretical-margin calls; financial statement type
555
- metadata feeding statement queries; assemblies and ownership notices feeding
556
- notice summaries; and fund holdings/asset fund holders linking funds with
557
- company tickers.
558
-
559
- ```python
560
- import btgsolutions_dataservices as btg
561
- meta = btg.AlternativeDataMetadata(api_key='YOUR_API_KEY')
506
+ company_data = btg.CompanyData(api_key='YOUR_API_KEY')
507
+ company_data.all_financial_tables(ticker='PETR4')
508
+ ```
509
+
510
+ #### REST Technical Catalogs
511
+
512
+ Technical endpoint descriptions for REST APIs are exported by the package so
513
+ MCPs and other connectors can reuse the same source of truth instead of
514
+ duplicating endpoint semantics locally.
515
+
516
+ ```python
517
+ from btgsolutions_dataservices.rest import (
518
+ DATASERVICES_ENDPOINTS,
519
+ DATASERVICES_ENDPOINT_RELATIONSHIPS,
520
+ get_dataservices_tool_description,
521
+ )
522
+
523
+ print(get_dataservices_tool_description("get_quotes"))
524
+ print(get_dataservices_tool_description("get_book_scope"))
525
+ ```
526
+
527
+ The Data Services catalog covers quotes, candles, intraday trades, last events,
528
+ reference data, corporate events, company fundamental data, HFN news,
529
+ stock-loan data, bulk market data, broker reference, broker analytics and
530
+ book-scope endpoints. It documents parameters, endpoint relationships such as
531
+ available-ticker discovery before market-data calls, broker-reference discovery
532
+ before broker analytics, HFN filter discovery before news queries, corporate
533
+ events before adjusted price analysis, and book-scope constraints for
534
+ microstructure analysis.
535
+
536
+ The REST catalogs also document cross-domain relationships between Public
537
+ Sources and market-data services: company directory resolution feeds ticker
538
+ reference, quotes, candles, stock-loan, broker analytics and book-scope tools;
539
+ sector classification feeds peer-market comparisons; fund holdings feed
540
+ underlying ticker market analysis; ownership/free-float feeds liquidity context;
541
+ and disclosures, official notices, HFN news and corporate events feed event
542
+ window analysis.
543
+
544
+ #### Alternative Data - Metadata
545
+
546
+ Technical endpoint descriptions for the public-sources alternative-data APIs are
547
+ exported by the package so MCPs and other connectors can reuse the same source
548
+ of truth:
549
+
550
+ ```python
551
+ from btgsolutions_dataservices.rest import (
552
+ PUBLIC_SOURCES_ENDPOINTS,
553
+ PUBLIC_SOURCES_ENDPOINT_RELATIONSHIPS,
554
+ get_public_sources_tool_description,
555
+ )
556
+
557
+ print(get_public_sources_tool_description("get_company_board"))
558
+ ```
559
+
560
+ The catalog documents endpoint parameters, known data gaps, excluded endpoints,
561
+ and relationships such as: company metadata resolving identifiers for governance
562
+ and ownership calls; macro indicator metadata feeding macro observations; asset
563
+ metadata feeding maximum-theoretical-margin calls; financial statement type
564
+ metadata feeding statement queries; assemblies and ownership notices feeding
565
+ notice summaries; and fund holdings/asset fund holders linking funds with
566
+ company tickers.
567
+
568
+ ```python
569
+ import btgsolutions_dataservices as btg
570
+ meta = btg.AlternativeDataMetadata(api_key='YOUR_API_KEY')
562
571
  meta.get_company_directory(query='PETROBRAS', jurisdiction='BR')
563
572
  meta.list_companies(query='PETROBRAS', jurisdiction='BR')
564
573
  meta.list_etfs(query='BOVA')
@@ -581,22 +590,28 @@ companies = btg.AlternativeDataCompanies(api_key='YOUR_API_KEY')
581
590
  companies.list_companies(query='PETROBRAS', jurisdiction='BR')
582
591
  companies.get_board(company_id='VALE3', body='board')
583
592
  companies.get_governance_summary(company_id='ITUB4')
584
- companies.get_governance_history(company_id='PETR4', start_date='2023-01-01', end_date='2024-12-31')
585
- companies.get_governance_documents(company_id='PETR4', start_date='2024-01-01', end_date='2024-12-31')
586
- companies.get_governance_compensation(company_id='VALE3', fiscal_year='2024')
587
- companies.get_governance_related_party(company_id='ITUB4')
588
- companies.get_governance_beneficial_ownership(company_id='AAPL') # UK PSC / US SEC proxy data; not BR listed-company ownership
589
- companies.get_corporate_registry(company_id='PETR4', direction='partners')
590
- companies.get_corporate_registry(company_id='PETR4', direction='investees')
591
- companies.get_insider_trades(company_id='AAPL', start_date='2024-01-01', end_date='2024-12-31')
592
- companies.get_board_changes(company_id='VALE3', event='elected')
593
+ companies.get_governance_history(company_id='PETR4', start_date='2023-01-01', end_date='2024-12-31')
594
+ companies.get_governance_documents(company_id='PETR4', start_date='2024-01-01', end_date='2024-12-31')
595
+ companies.get_governance_compensation(company_id='VALE3', fiscal_year='2024')
596
+ companies.get_governance_related_party(company_id='ITUB4')
597
+ companies.get_governance_beneficial_ownership(company_id='AAPL') # UK PSC / US SEC proxy data; not BR listed-company ownership
598
+ companies.get_corporate_registry(company_id='PETR4', direction='partners')
599
+ companies.get_corporate_registry(company_id='PETR4', direction='investees')
600
+ companies.get_insider_trades(company_id='AAPL', start_date='2024-01-01', end_date='2024-12-31')
601
+ companies.get_board_changes(company_id='VALE3', event='elected')
593
602
  companies.get_assemblies(company_id='PINE4')
594
- companies.get_financial_statements(company_id='PETR4', statement='income_statement', quarter='4T24')
595
- companies.get_financial_notes(company_id='VALE3', quarter='4T24')
603
+ companies.get_financial_statements(company_id='PETR4', statement='income_statement', quarter='4T24')
604
+ companies.get_financial_notes(company_id='VALE3', quarter='4T24')
596
605
  companies.get_disclosures(company_id='PETR4', document_type='repurchase')
597
606
  companies.get_disclosures(company_id='PETR4', document_type='insider')
598
607
  ```
599
608
 
609
+ For Brazilian governance endpoints, current board and summary responses prefer
610
+ the latest raw FRE filing when available. Returned governance summaries can
611
+ include `latest_reference_date`, `latest_version`, `latest_document_id` and
612
+ `structure_source`; alternate B3 tickers/units such as `BPAC11` can resolve to
613
+ the underlying listed company when covered by the source metadata.
614
+
600
615
  #### Alternative Data - People
601
616
 
602
617
  ```python
@@ -610,14 +625,14 @@ people.get_appointments(person_id='slug:Jean Paul Lemann', group_by='company')
610
625
 
611
626
  ```python
612
627
  import btgsolutions_dataservices as btg
613
- funds = btg.AlternativeDataFunds(api_key='YOUR_API_KEY')
614
- funds.list_etfs(query='BOVA')
615
- funds.get_holdings(fund_id='BOVA11', reference_date='2024-12-31')
616
- funds.get_exposures(fund_id='BOVA11', exposure_type='asset_class')
617
- funds.get_history(fund_id='BOVA11', start_date='2024-01-01', end_date='2024-12-31')
618
- funds.get_lookthrough(fund_id='BOVA11')
619
- # Manager aggregation requires an exact covered manager CNPJ/name, not ETF issuer slugs, ETF tickers or fund CNPJs.
620
- # funds.get_manager_aggregate_holdings(manager_id='...')
628
+ funds = btg.AlternativeDataFunds(api_key='YOUR_API_KEY')
629
+ funds.list_etfs(query='BOVA')
630
+ funds.get_holdings(fund_id='BOVA11', reference_date='2024-12-31')
631
+ funds.get_exposures(fund_id='BOVA11', exposure_type='asset_class')
632
+ funds.get_history(fund_id='BOVA11', start_date='2024-01-01', end_date='2024-12-31')
633
+ funds.get_lookthrough(fund_id='BOVA11')
634
+ # Manager aggregation requires an exact covered manager CNPJ/name, not ETF issuer slugs, ETF tickers or fund CNPJs.
635
+ # funds.get_manager_aggregate_holdings(manager_id='...')
621
636
  ```
622
637
 
623
638
  #### Alternative Data - Ownership
@@ -638,22 +653,29 @@ ownership.get_institutional_holders(identifier='VALE3')
638
653
  ownership.get_fund_holders(identifier='PETR4', identifier_type='b3_ticker')
639
654
  ```
640
655
 
656
+ For Brazilian ownership/free-float endpoints, current control and free-float
657
+ responses use the latest FRE source document/version for the selected reference
658
+ date when available. Repeated older source documents are deduplicated where
659
+ possible, while distinct rows for the same holder across classes, roles or
660
+ ownership categories are preserved. Zero free-float or independence percentages
661
+ can be valid source values, not missing data.
662
+
641
663
  #### Alternative Data - Macro & Markets
642
664
 
643
665
  ```python
644
666
  import btgsolutions_dataservices as btg
645
667
  macro = btg.AlternativeDataMacroMarkets(api_key='YOUR_API_KEY')
646
668
  macro.get_macro_indicators(indicator='selic')
647
- macro.get_macro_indicators(indicator='ipca_contributions', start_date='2024-01', end_date='2024-12')
648
- macro.get_macro_indicators(indicator='gdp', type='yoy')
649
- macro.get_macro_indicators(indicator='comexstat', year='2024', state='SP')
650
- macro.get_macro_indicators(indicator='comexstat', aggregate='states', start_date='2024-01', end_date='2024-12')
651
- macro.get_macro_indicators(indicator='comexstat', aggregate='timeline', group_by='country', state='SP')
652
- macro.get_macro_indicators(indicator='rreo', year='2024', period='6')
653
- macro.get_maximum_theoretical_margin(asset='PETR4', report_date='2024-12-31')
654
- macro.get_dpmfi(start_date='2024-01', end_date='2024-12', status='dados_oficiais')
655
- macro.get_dpmfi(snapshot_date='2026-06-24', limit=10) # reproducible scoped snapshot
656
- macro.get_dpmfi_composition(bond_type='IPCA')
669
+ macro.get_macro_indicators(indicator='ipca_contributions', start_date='2024-01', end_date='2024-12')
670
+ macro.get_macro_indicators(indicator='gdp', type='yoy')
671
+ macro.get_macro_indicators(indicator='comexstat', year='2024', state='SP')
672
+ macro.get_macro_indicators(indicator='comexstat', aggregate='states', start_date='2024-01', end_date='2024-12')
673
+ macro.get_macro_indicators(indicator='comexstat', aggregate='timeline', group_by='country', state='SP')
674
+ macro.get_macro_indicators(indicator='rreo', year='2024', period='6')
675
+ macro.get_maximum_theoretical_margin(asset='PETR4', report_date='2024-12-31')
676
+ macro.get_dpmfi(start_date='2024-01', end_date='2024-12', status='dados_oficiais')
677
+ macro.get_dpmfi(snapshot_date='2026-06-24', limit=10) # reproducible scoped snapshot
678
+ macro.get_dpmfi_composition(bond_type='IPCA')
657
679
  ```
658
680
 
659
681
  `AlternativeDataMacroMarkets` exposes the public-sources market-data endpoint for B3 maximum theoretical margin. The direct market-data `investor-categories` endpoint is intentionally not exposed in this package.
@@ -1,4 +1,4 @@
1
- __version__ = "4.5.0"
1
+ __version__ = "4.6.0"
2
2
 
3
3
  from .websocket import *
4
4
  from .rest import *
@@ -53,12 +53,16 @@ PUBLIC_SOURCES_DATA_GAPS: dict[str, str] = {
53
53
  "can change matches."
54
54
  ),
55
55
  "get_company_board": (
56
- "For Brazilian companies, body='board' can include Conselho Fiscal rows "
56
+ "For Brazilian companies, current board/executive composition prefers "
57
+ "the latest raw FRE rows over older materialized snapshots and orders "
58
+ "FRE versions numerically. body='board' can include Conselho Fiscal rows "
57
59
  "alongside Conselho de Administracao rows depending on the filing. For "
58
60
  "a board-of-directors answer, filter returned rows by governance_body "
59
- "or role to keep Conselho de Administracao only. Committee responses "
60
- "can include broad aggregates such as Outros Comites; do not infer "
61
- "granular committee names unless they are present in returned fields."
61
+ "or role to keep Conselho de Administracao only. body='executive' "
62
+ "deduplicates mixed board/executive rows by person where possible. "
63
+ "Committee responses can include broad aggregates such as Outros "
64
+ "Comites; do not infer granular committee names unless they are present "
65
+ "in returned fields."
62
66
  ),
63
67
  "get_board_changes": (
64
68
  "Brazilian board-change rows can be materialized from FRE snapshot "
@@ -108,10 +112,11 @@ PUBLIC_SOURCES_DATA_GAPS: dict[str, str] = {
108
112
  "get_ownership_free_float and get_ownership_official_notices when this "
109
113
  "endpoint returns no rows. "
110
114
  "This endpoint does not synthesize top holders from current ownership "
111
- "or free-float tables. Some responses can include multiple rows for "
112
- "the same holder across share classes, ownership categories, filings "
113
- "or source protocols; inspect category, class, protocol/source and "
114
- "reference date before aggregating percentages."
115
+ "or free-float tables. The API deduplicates repeated rows from older "
116
+ "FRE source documents for the same reference date where possible, while "
117
+ "preserving distinct rows for the same holder across share classes, "
118
+ "ownership categories or roles; inspect category, class, protocol/source "
119
+ "and reference date before aggregating percentages."
115
120
  ),
116
121
  "ownership_reporting_dates": (
117
122
  "Brazilian ownership and free-float reference_date fields often come "
@@ -119,7 +124,9 @@ PUBLIC_SOURCES_DATA_GAPS: dict[str, str] = {
119
124
  "structures. They are reporting/reference dates, not necessarily the "
120
125
  "calendar date when the data was loaded or a strict as-of timestamp; a "
121
126
  "reference_date can be after the current calendar date when it denotes "
122
- "a filing year/base period."
127
+ "a filing year/base period. For FRE tables with multiple filed versions "
128
+ "on the same reference date, current control/free-float/governance "
129
+ "responses prefer the latest source document or numeric version."
123
130
  ),
124
131
  "get_ownership_history": (
125
132
  "Ownership history uses the same normalized ownership_snapshot layer as "
@@ -632,9 +639,10 @@ PUBLIC_SOURCES_ENDPOINTS: dict[str, dict[str, Any]] = {
632
639
  "description": (
633
640
  "Get members of a company's governance body. body can be board, "
634
641
  "executive or committee; committee filters a specific committee when "
635
- "body='committee'. For Brazilian filings, body='board' can include "
636
- "Conselho Fiscal rows; filter governance_body/role for Conselho de "
637
- "Administracao when answering board-of-directors questions."
642
+ "body='committee'. For Brazilian filings, latest raw FRE rows are "
643
+ "preferred when present; body='board' can include Conselho Fiscal "
644
+ "rows; filter governance_body/role for Conselho de Administracao "
645
+ "when answering board-of-directors questions."
638
646
  ),
639
647
  "parameters": {
640
648
  "company_id": PUBLIC_SOURCES_CONVENTIONS["company_id"],
@@ -655,8 +663,11 @@ PUBLIC_SOURCES_ENDPOINTS: dict[str, dict[str, Any]] = {
655
663
  "client": "AlternativeDataCompanies",
656
664
  "description": (
657
665
  "Get a compact latest governance snapshot for a company as a "
658
- "composite object. It can include board size, committees, CEO and "
659
- "free-float-related fields when available."
666
+ "composite object. For Brazilian companies, current counts are "
667
+ "derived from the latest raw FRE filing when available and can "
668
+ "include latest_reference_date, latest_version, latest_document_id, "
669
+ "structure_source, board size, independent members, fiscal council "
670
+ "size, executives, committees and CEO."
660
671
  ),
661
672
  "parameters": {"company_id": PUBLIC_SOURCES_CONVENTIONS["company_id"]},
662
673
  "relationships": ["company_resolution", "company_trading_bridge"],
@@ -1170,7 +1181,9 @@ PUBLIC_SOURCES_ENDPOINTS: dict[str, dict[str, Any]] = {
1170
1181
  "description": (
1171
1182
  "Get top shareholders for a company from the normalized "
1172
1183
  "ownership_snapshot layer when shareholder-level snapshots are "
1173
- "available. Brazilian CVM/FRE rows are periodic filing snapshots."
1184
+ "available. Brazilian CVM/FRE rows are periodic filing snapshots; "
1185
+ "older repeated FRE source documents for the same reference date "
1186
+ "are deduplicated where possible."
1174
1187
  ),
1175
1188
  "parameters": {
1176
1189
  "company_id": PUBLIC_SOURCES_CONVENTIONS["company_id"],
@@ -1198,7 +1211,9 @@ PUBLIC_SOURCES_ENDPOINTS: dict[str, dict[str, Any]] = {
1198
1211
  "client": "AlternativeDataOwnership",
1199
1212
  "description": (
1200
1213
  "Get current ownership structure of a listed company as a composite "
1201
- "object. Use this for latest control, free-float and ownership summary context."
1214
+ "object. Use this for latest control, free-float and ownership summary "
1215
+ "context. For Brazilian FRE data, current control/free-float blocks "
1216
+ "prefer the latest source document for the selected reference date."
1202
1217
  ),
1203
1218
  "parameters": {"company_id": PUBLIC_SOURCES_CONVENTIONS["company_id"]},
1204
1219
  "relationships": [
@@ -1335,7 +1350,10 @@ PUBLIC_SOURCES_ENDPOINTS: dict[str, dict[str, Any]] = {
1335
1350
  "description": (
1336
1351
  "Get controlling shareholders, shareholder agreements and control "
1337
1352
  "evidence for a company as a composite object. Use this for who "
1338
- "controls the company, not for all holder positions."
1353
+ "controls the company, not for all holder positions. For Brazilian "
1354
+ "FRE rows, current control holders are restricted to the latest "
1355
+ "source document for the selected reference date when protocols "
1356
+ "identify multiple filed versions."
1339
1357
  ),
1340
1358
  "parameters": {"company_id": PUBLIC_SOURCES_CONVENTIONS["company_id"]},
1341
1359
  "relationships": [
@@ -1351,7 +1369,9 @@ PUBLIC_SOURCES_ENDPOINTS: dict[str, dict[str, Any]] = {
1351
1369
  "client": "AlternativeDataOwnership",
1352
1370
  "description": (
1353
1371
  "Get free-float percentage and share-class details for a company as "
1354
- "a composite object. Use this for investable-float questions."
1372
+ "a composite object. Use this for investable-float questions. "
1373
+ "Brazilian FRE distribution-of-capital versions are ordered "
1374
+ "numerically; returned zero percentages can be valid source values."
1355
1375
  ),
1356
1376
  "parameters": {
1357
1377
  "company_id": PUBLIC_SOURCES_CONVENTIONS["company_id"],
@@ -114,12 +114,16 @@ class AlternativeDataCompanies:
114
114
  Use get_board_changes() for appointment/departure events and
115
115
  get_governance_history() for historical snapshot series.
116
116
 
117
- For Brazilian filings, ``body='board'`` can include Conselho Fiscal
118
- rows alongside Conselho de Administracao rows. For a board-of-directors
119
- answer, filter returned rows by governance_body or role. Committee
120
- responses can include broad aggregate groups such as Outros Comites; do
121
- not infer granular committee names unless they are present in returned
122
- fields.
117
+ For Brazilian filings, the latest FRE raw rows are preferred over
118
+ older materialized snapshots and numeric FRE versions are ordered
119
+ numerically (for example version 13 is newer than version 9).
120
+ ``body='board'`` preserves the historical contract and can include
121
+ Conselho Fiscal rows alongside Conselho de Administracao rows; for a
122
+ board-of-directors answer, filter returned rows by governance_body or
123
+ role. ``body='executive'`` returns one row per person after resolving
124
+ duplicate mixed board/executive FRE rows. Committee responses can
125
+ include broad aggregate groups such as Outros Comites; do not infer
126
+ granular committee names unless they are present in returned fields.
123
127
 
124
128
  Parameters
125
129
  ----------------
@@ -161,7 +165,13 @@ class AlternativeDataCompanies:
161
165
  def get_governance_summary(self, company_id: str) -> dict:
162
166
  """
163
167
  Latest governance snapshot for a company (board size, independence,
164
- committees, CEO name, etc.).
168
+ fiscal council size, executive count, committees, CEO name, etc.).
169
+ For Brazilian companies, the API derives current counts from the
170
+ latest available FRE raw filing when present, exposes
171
+ latest_reference_date/latest_version/latest_document_id and can mark
172
+ structure_source='fre_raw'. This avoids stale materialized summaries
173
+ and fixes B3 tickers that resolve through alternate traded classes
174
+ such as units.
165
175
  Use get_board() for individual directors/officers and
166
176
  AlternativeDataOwnership.get_ownership_free_float() for detailed
167
177
  free-float breakdowns.
@@ -73,10 +73,11 @@ class AlternativeDataOwnership:
73
73
  filter. For Brazilian ownership questions, call get_ownership_current(),
74
74
  get_ownership_control_group(), get_ownership_free_float() and
75
75
  get_ownership_official_notices() when this endpoint returns no rows.
76
- Some responses can include multiple rows for the same holder across
77
- share classes, ownership categories, filings or source protocols;
78
- inspect category, class, protocol/source and reference date before
79
- aggregating percentages.
76
+ The API deduplicates repeated rows from older FRE source documents for
77
+ the same reference date where possible, while still preserving distinct
78
+ rows for the same holder when they represent different share classes,
79
+ ownership categories or roles. Inspect category, class, protocol/source
80
+ and reference date before aggregating percentages.
80
81
 
81
82
  Parameters
82
83
  ----------------
@@ -108,7 +109,9 @@ class AlternativeDataOwnership:
108
109
  Use this as the primary current ownership summary when top-shareholder
109
110
  snapshots are empty or when a compact ownership object is sufficient.
110
111
  Reference dates usually come from CVM/FRE reporting periods or parsed
111
- IR structures and are not necessarily strict as-of timestamps.
112
+ IR structures and are not necessarily strict as-of timestamps. For
113
+ Brazilian FRE data, control/free-float blocks are based on the latest
114
+ source document for the selected reference date when available.
112
115
 
113
116
  Parameters
114
117
  ----------------
@@ -291,7 +294,9 @@ class AlternativeDataOwnership:
291
294
  Use this for who controls the company; use get_shareholder_holdings()
292
295
  for a reverse lookup of one holder across companies.
293
296
  Reference dates usually come from CVM/FRE reporting periods and can
294
- denote a filing year/base period rather than the load date.
297
+ denote a filing year/base period rather than the load date. The API
298
+ filters current control rows to the latest FRE source document for the
299
+ selected reference date when protocols identify multiple filed versions.
295
300
 
296
301
  Parameters
297
302
  ----------------
@@ -306,7 +311,10 @@ class AlternativeDataOwnership:
306
311
  Free float breakdown for a company.
307
312
  Reference dates usually come from CVM/FRE reporting periods or parsed
308
313
  IR structures and can denote a filing year/base period rather than the
309
- load date.
314
+ load date. For Brazilian FRE distribution-of-capital tables, numeric
315
+ versions are ordered numerically so version 13 is treated as newer than
316
+ version 9. Returned zero values can be valid source values rather than
317
+ missing data.
310
318
 
311
319
  Parameters
312
320
  ----------------
@@ -1,5 +1,5 @@
1
1
  import os
2
- from typing import Optional
2
+ from typing import Dict, Optional
3
3
  from ..exceptions import BadResponse
4
4
  import requests
5
5
  from ..config import url_api_v1, url_apis, url_apis_v3
@@ -9,6 +9,25 @@ import pandas as pd
9
9
  from io import BytesIO
10
10
  import pyarrow.parquet as pq
11
11
 
12
+ BILLING_HEADER_NAMES = (
13
+ "X-Dry-Run",
14
+ "X-Billable",
15
+ "X-Requested-Rows",
16
+ "X-Current-Rows",
17
+ "X-Contracted-Limit-Rows",
18
+ "X-Remaining-Rows",
19
+ "X-Already-Billed",
20
+ "X-Would-Exceed-Limit",
21
+ )
22
+
23
+
24
+ def extract_billing_headers(headers) -> Dict[str, str]:
25
+ return {
26
+ header_name: headers.get(header_name)
27
+ for header_name in BILLING_HEADER_NAMES
28
+ if headers.get(header_name) is not None
29
+ }
30
+
12
31
  def download_compressed_file(url, headers):
13
32
 
14
33
  with requests.get(url, headers=headers, stream=True) as response:
@@ -164,7 +183,9 @@ class BulkData:
164
183
  ticker:str,
165
184
  date:str,
166
185
  data_type:str='trades',
167
- raw_data:bool=False
186
+ raw_data:bool=False,
187
+ return_billing_headers:bool=False,
188
+ dry_run:bool=False,
168
189
  ):
169
190
  """
170
191
  This method provides tick-by-tick market data (trades, book events, book snapshots) for a given ticker and date.
@@ -184,11 +205,24 @@ class BulkData:
184
205
  raw_data: bool
185
206
  If false, returns data in a dataframe. If true, returns raw data.
186
207
  Field is not required. Default: False.
208
+ return_billing_headers: bool
209
+ If true, returns billing headers with the data.
210
+ Field is not required. Default: False.
211
+ dry_run: bool
212
+ If true, checks billing quota without downloading data and returns billing headers.
213
+ Field is not required. Default: False.
187
214
  """
188
215
 
189
216
  url = f"{url_apis}/marketdata/bulkdata/{data_type}?ticker={ticker}&date={date}"
217
+ if dry_run:
218
+ url = f"{url}&dry_run=true"
190
219
 
191
220
  response = requests.request("GET", url, headers=self.headers)
221
+ billing_headers = extract_billing_headers(response.headers)
222
+
223
+ if response.status_code == 204 and dry_run:
224
+ return billing_headers
225
+
192
226
  if response.status_code == 200:
193
227
 
194
228
  try:
@@ -198,6 +232,8 @@ class BulkData:
198
232
  parquet_file = pq.ParquetFile(parquet_buffer)
199
233
  df = parquet_file.read().to_pandas()
200
234
 
235
+ if return_billing_headers:
236
+ return df, billing_headers
201
237
  return df
202
238
 
203
239
  else:
@@ -207,6 +243,8 @@ class BulkData:
207
243
  # Write the content to a file
208
244
  with open(filename, 'wb') as file:
209
245
  file.write(response.content)
246
+ if return_billing_headers:
247
+ return billing_headers
210
248
  return None
211
249
 
212
250
  except Exception as e:
@@ -1,25 +1,12 @@
1
- Metadata-Version: 2.4
2
- Name: btgsolutions_dataservices_python_client
3
- Version: 4.5.0
1
+ Metadata-Version: 2.1
2
+ Name: btgsolutions-dataservices-python-client
3
+ Version: 4.6.0
4
4
  Summary: Python package containing several classes and data for extracting and manipulating market and trading data.
5
5
  Home-page: https://github.com/BTG-Pactual-Solutions/btgsolutions-dataservices-python-client
6
6
  Author: BTG Solutions Data Services powered by BTG Pactual Solutions
7
7
  Requires-Python: >=3.9,<3.15
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
- Requires-Dist: pandas>=2.2.2
11
- Requires-Dist: websocket-client>=1.8.0
12
- Requires-Dist: PyJWT>=2.8.0
13
- Requires-Dist: requests>=2.32.3
14
- Requires-Dist: pyarrow>=17.0.0
15
- Dynamic: author
16
- Dynamic: description
17
- Dynamic: description-content-type
18
- Dynamic: home-page
19
- Dynamic: license-file
20
- Dynamic: requires-dist
21
- Dynamic: requires-python
22
- Dynamic: summary
23
10
 
24
11
  # BTG Solutions - Data Services
25
12
 
@@ -351,6 +338,15 @@ bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
351
338
  # bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='instrument-status')
352
339
  ```
353
340
 
341
+ ##### Get Data With Billing Headers
342
+
343
+ ```python
344
+ import btgsolutions_dataservices as btg
345
+ bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
346
+ df, billing_headers = bulk_data.get_data(ticker='PETR4', date='2025-06-20', data_type='trades', return_billing_headers=True)
347
+ # billing_headers = bulk_data.get_data(ticker='PETR4', date='2025-06-20', data_type='trades', dry_run=True)
348
+ ```
349
+
354
350
  ##### Security List
355
351
 
356
352
  ```python
@@ -620,6 +616,12 @@ companies.get_disclosures(company_id='PETR4', document_type='repurchase')
620
616
  companies.get_disclosures(company_id='PETR4', document_type='insider')
621
617
  ```
622
618
 
619
+ For Brazilian governance endpoints, current board and summary responses prefer
620
+ the latest raw FRE filing when available. Returned governance summaries can
621
+ include `latest_reference_date`, `latest_version`, `latest_document_id` and
622
+ `structure_source`; alternate B3 tickers/units such as `BPAC11` can resolve to
623
+ the underlying listed company when covered by the source metadata.
624
+
623
625
  #### Alternative Data - People
624
626
 
625
627
  ```python
@@ -661,6 +663,13 @@ ownership.get_institutional_holders(identifier='VALE3')
661
663
  ownership.get_fund_holders(identifier='PETR4', identifier_type='b3_ticker')
662
664
  ```
663
665
 
666
+ For Brazilian ownership/free-float endpoints, current control and free-float
667
+ responses use the latest FRE source document/version for the selected reference
668
+ date when available. Repeated older source documents are deduplicated where
669
+ possible, while distinct rows for the same holder across classes, roles or
670
+ ownership categories are preserved. Zero free-float or independence percentages
671
+ can be valid source values, not missing data.
672
+
664
673
  #### Alternative Data - Macro & Markets
665
674
 
666
675
  ```python