brasa-marketdata 0.1.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 (161) hide show
  1. brasa_marketdata-0.1.0/.gitignore +143 -0
  2. brasa_marketdata-0.1.0/LICENSE +21 -0
  3. brasa_marketdata-0.1.0/PKG-INFO +158 -0
  4. brasa_marketdata-0.1.0/README.md +132 -0
  5. brasa_marketdata-0.1.0/brasa/__init__.py +83 -0
  6. brasa_marketdata-0.1.0/brasa/cli.py +1504 -0
  7. brasa_marketdata-0.1.0/brasa/downloaders/__init__.py +35 -0
  8. brasa_marketdata-0.1.0/brasa/downloaders/downloaders.py +278 -0
  9. brasa_marketdata-0.1.0/brasa/downloaders/helpers.py +242 -0
  10. brasa_marketdata-0.1.0/brasa/engine/__init__.py +224 -0
  11. brasa_marketdata-0.1.0/brasa/engine/api.py +922 -0
  12. brasa_marketdata-0.1.0/brasa/engine/cache.py +993 -0
  13. brasa_marketdata-0.1.0/brasa/engine/catalog.py +565 -0
  14. brasa_marketdata-0.1.0/brasa/engine/core.py +73 -0
  15. brasa_marketdata-0.1.0/brasa/engine/dependency_graph.py +968 -0
  16. brasa_marketdata-0.1.0/brasa/engine/dependency_resolver.py +363 -0
  17. brasa_marketdata-0.1.0/brasa/engine/doctor.py +1900 -0
  18. brasa_marketdata-0.1.0/brasa/engine/download.py +190 -0
  19. brasa_marketdata-0.1.0/brasa/engine/download_plan.py +714 -0
  20. brasa_marketdata-0.1.0/brasa/engine/exceptions.py +76 -0
  21. brasa_marketdata-0.1.0/brasa/engine/layers.py +80 -0
  22. brasa_marketdata-0.1.0/brasa/engine/orchestrator.py +573 -0
  23. brasa_marketdata-0.1.0/brasa/engine/parsers.py +185 -0
  24. brasa_marketdata-0.1.0/brasa/engine/pipeline/__init__.py +77 -0
  25. brasa_marketdata-0.1.0/brasa/engine/pipeline/context.py +141 -0
  26. brasa_marketdata-0.1.0/brasa/engine/pipeline/context_protocol.py +39 -0
  27. brasa_marketdata-0.1.0/brasa/engine/pipeline/etl_context.py +65 -0
  28. brasa_marketdata-0.1.0/brasa/engine/pipeline/etl_executor.py +234 -0
  29. brasa_marketdata-0.1.0/brasa/engine/pipeline/etl_results.py +24 -0
  30. brasa_marketdata-0.1.0/brasa/engine/pipeline/etl_steps.py +9 -0
  31. brasa_marketdata-0.1.0/brasa/engine/pipeline/executor.py +143 -0
  32. brasa_marketdata-0.1.0/brasa/engine/pipeline/registry.py +110 -0
  33. brasa_marketdata-0.1.0/brasa/engine/pipeline/step.py +116 -0
  34. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/__init__.py +29 -0
  35. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/b3_steps.py +705 -0
  36. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/column_steps.py +197 -0
  37. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/custom_steps.py +145 -0
  38. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/etl_steps.py +703 -0
  39. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/html_steps.py +122 -0
  40. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/io_steps.py +213 -0
  41. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/shared_transforms.py +472 -0
  42. brasa_marketdata-0.1.0/brasa/engine/pipeline/steps/transform_steps.py +472 -0
  43. brasa_marketdata-0.1.0/brasa/engine/pipeline_map.py +201 -0
  44. brasa_marketdata-0.1.0/brasa/engine/processing.py +240 -0
  45. brasa_marketdata-0.1.0/brasa/engine/reporting.py +959 -0
  46. brasa_marketdata-0.1.0/brasa/engine/resources.py +19 -0
  47. brasa_marketdata-0.1.0/brasa/engine/template.py +876 -0
  48. brasa_marketdata-0.1.0/brasa/engine/update_strategy.py +468 -0
  49. brasa_marketdata-0.1.0/brasa/etl.py +1189 -0
  50. brasa_marketdata-0.1.0/brasa/fieldsets/__init__.py +49 -0
  51. brasa_marketdata-0.1.0/brasa/fieldsets/adapters/__init__.py +13 -0
  52. brasa_marketdata-0.1.0/brasa/fieldsets/adapters/pandas_adapter.py +668 -0
  53. brasa_marketdata-0.1.0/brasa/fieldsets/adapters/pyarrow_adapter.py +397 -0
  54. brasa_marketdata-0.1.0/brasa/fieldsets/adapters/unified_reader.py +175 -0
  55. brasa_marketdata-0.1.0/brasa/fieldsets/exceptions.py +27 -0
  56. brasa_marketdata-0.1.0/brasa/fieldsets/field.py +335 -0
  57. brasa_marketdata-0.1.0/brasa/fieldsets/fieldset.py +543 -0
  58. brasa_marketdata-0.1.0/brasa/fieldsets/type_parser.py +523 -0
  59. brasa_marketdata-0.1.0/brasa/files/sql/create-dataset-catalog.sql +21 -0
  60. brasa_marketdata-0.1.0/brasa/files/sql/create-meta-db.sql +24 -0
  61. brasa_marketdata-0.1.0/brasa/files/templates/anbima/anbima-index-imab.yaml +64 -0
  62. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-cash-dividends-events.yaml +228 -0
  63. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-cash-dividends.yaml +104 -0
  64. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-companies-capital.yaml +88 -0
  65. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-companies-names.yaml +45 -0
  66. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-companies-symbols.yaml +91 -0
  67. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-company-details.yaml +130 -0
  68. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-company-info.yaml +204 -0
  69. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-stock-events.yaml +105 -0
  70. brasa_marketdata-0.1.0/brasa/files/templates/b3/companies/b3-subscription-events.yaml +117 -0
  71. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/CenariosCurva.yaml +57 -0
  72. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/b3-curves-dap-standard-returns.yaml +5 -0
  73. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/b3-curves-dap-standard.yaml +8 -0
  74. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/b3-curves-dap.yaml +5 -0
  75. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/b3-curves-di1-standard-returns.yaml +38 -0
  76. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/b3-curves-di1-standard.yaml +47 -0
  77. brasa_marketdata-0.1.0/brasa/files/templates/b3/curves/b3-curves-di1.yaml +88 -0
  78. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-cotahist-daily.yaml +137 -0
  79. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-cotahist-yearly.yaml +137 -0
  80. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-cotahist.yaml +17 -0
  81. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-equities-etfs-returns.yaml +72 -0
  82. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-equities-instrument-assets.yaml +50 -0
  83. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-equities-register.yaml +125 -0
  84. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-equities-returns.yaml +110 -0
  85. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-equities-spot-market.yaml +33 -0
  86. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-listed-funds-consolidated.yaml +51 -0
  87. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-listed-funds.yaml +69 -0
  88. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities/b3-otc-trade-information.yaml +127 -0
  89. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities-options/b3-equities-volatility-surface.yaml +59 -0
  90. brasa_marketdata-0.1.0/brasa/files/templates/b3/equities-options/b3-equity-options.yaml +59 -0
  91. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures-dap-first-generic.yaml +7 -0
  92. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures-dap.yaml +46 -0
  93. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures-di1-consolidated.yaml +24 -0
  94. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures-register.yaml +100 -0
  95. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures-settlement-prices-consolidated.yaml +44 -0
  96. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures-settlement-prices.yaml +90 -0
  97. brasa_marketdata-0.1.0/brasa/files/templates/b3/futures/b3-futures.yaml +130 -0
  98. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-adjusted-prices.yaml +9 -0
  99. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-composition-consolidated.yaml +17 -0
  100. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-composition.yaml +83 -0
  101. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-current-portfolio-consolidated.yaml +12 -0
  102. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-current-portfolio.yaml +115 -0
  103. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-historical-prices-pivot-longer.yaml +55 -0
  104. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-historical-prices.yaml +103 -0
  105. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-returns.yaml +5 -0
  106. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-theoretical-portfolio-consolidated.yaml +12 -0
  107. brasa_marketdata-0.1.0/brasa/files/templates/b3/indexes/b3-indexes-theoretical-portfolio.yaml +95 -0
  108. brasa_marketdata-0.1.0/brasa/files/templates/b3/intraday/b3-trades-intraday-consolidated.yaml +33 -0
  109. brasa_marketdata-0.1.0/brasa/files/templates/b3/intraday/b3-trades-intraday-derivatives.yaml +75 -0
  110. brasa_marketdata-0.1.0/brasa/files/templates/b3/intraday/b3-trades-intraday-equities.yaml +75 -0
  111. brasa_marketdata-0.1.0/brasa/files/templates/b3/intraday/b3-trades-intraday.yaml +89 -0
  112. brasa_marketdata-0.1.0/brasa/files/templates/b3/lending/b3-lending-open-position.yaml +34 -0
  113. brasa_marketdata-0.1.0/brasa/files/templates/b3/lending/b3-lending-trades.yaml +80 -0
  114. brasa_marketdata-0.1.0/brasa/files/templates/b3/lending/b3-loan-balance.yaml +34 -0
  115. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-bdin.yaml +624 -0
  116. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-bvbg028.yaml +1576 -0
  117. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-bvbg086.yaml +147 -0
  118. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-bvbg087.yaml +171 -0
  119. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-derivatives-daily.yaml +424 -0
  120. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-economic-indicators-fwf.yaml +72 -0
  121. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-economic-indicators.yaml +68 -0
  122. brasa_marketdata-0.1.0/brasa/files/templates/b3/raw/b3-registered-contracts.yaml +162 -0
  123. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-currencies-returns.yaml +7 -0
  124. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-currency-data.yaml +5 -0
  125. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-currency.yaml +65 -0
  126. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-data.yaml +5 -0
  127. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-sgs-consolidated.yaml +45 -0
  128. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-sgs-data.yaml +28 -0
  129. brasa_marketdata-0.1.0/brasa/files/templates/bcb/bcb-sgs.yaml +49 -0
  130. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-companies.yaml +216 -0
  131. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-corporate-events.yaml +194 -0
  132. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-industry-sectors.yaml +237 -0
  133. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-ohlc-prices.yaml +12 -0
  134. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-prices.yaml +16 -0
  135. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-returns-symbols-changes.yaml +44 -0
  136. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-returns.yaml +26 -0
  137. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-symbol-changes.yaml +132 -0
  138. brasa_marketdata-0.1.0/brasa/files/templates/brasa/brasa-symbol-spans-analysis.yaml +120 -0
  139. brasa_marketdata-0.1.0/brasa/files/templates/cvm/cvm-companies-registration.yaml +224 -0
  140. brasa_marketdata-0.1.0/brasa/parsers/__init__.py +0 -0
  141. brasa_marketdata-0.1.0/brasa/parsers/anbima/__init__.py +4 -0
  142. brasa_marketdata-0.1.0/brasa/parsers/anbima/debentures.py +59 -0
  143. brasa_marketdata-0.1.0/brasa/parsers/anbima/tpf.py +105 -0
  144. brasa_marketdata-0.1.0/brasa/parsers/b3/__init__.py +17 -0
  145. brasa_marketdata-0.1.0/brasa/parsers/b3/bvbg028.py +152 -0
  146. brasa_marketdata-0.1.0/brasa/parsers/b3/bvbg086.py +87 -0
  147. brasa_marketdata-0.1.0/brasa/parsers/b3/bvbg087.py +99 -0
  148. brasa_marketdata-0.1.0/brasa/parsers/b3/cdi.py +34 -0
  149. brasa_marketdata-0.1.0/brasa/parsers/b3/cotahist.py +80 -0
  150. brasa_marketdata-0.1.0/brasa/parsers/b3/futures_settlement_prices.py +112 -0
  151. brasa_marketdata-0.1.0/brasa/parsers/b3/indic.py +17 -0
  152. brasa_marketdata-0.1.0/brasa/parsers/b3/stock_indexes.py +51 -0
  153. brasa_marketdata-0.1.0/brasa/parsers/fwf.py +176 -0
  154. brasa_marketdata-0.1.0/brasa/parsers/td.py +51 -0
  155. brasa_marketdata-0.1.0/brasa/parsers/util.py +93 -0
  156. brasa_marketdata-0.1.0/brasa/queries.py +1010 -0
  157. brasa_marketdata-0.1.0/brasa/readers/__init__.py +53 -0
  158. brasa_marketdata-0.1.0/brasa/readers/csv.py +87 -0
  159. brasa_marketdata-0.1.0/brasa/readers/helpers.py +673 -0
  160. brasa_marketdata-0.1.0/brasa/util.py +474 -0
  161. brasa_marketdata-0.1.0/pyproject.toml +202 -0
@@ -0,0 +1,143 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # Git worktrees
132
+ .worktrees/
133
+
134
+ data/big-files/BDIN.zip
135
+ data/big-files/OpcoesAcoesEmAberto.zip
136
+ legacy/
137
+ .brasa-cache/
138
+ .vscode/launch.json
139
+
140
+ # Generated skill lockfile and script outputs
141
+ skills-lock.json
142
+ scripts/out/
143
+ tmp/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Wilson Freitas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.4
2
+ Name: brasa-marketdata
3
+ Version: 0.1.0
4
+ Summary: Python library to extract finance market data from brazillian financial institutions: B3, ANBIMA, Tesouro Direto, CVM.
5
+ Author-email: wilsonfreitas <wilson.freitas@gmail.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: beautifulsoup4>=4.12.2
10
+ Requires-Dist: bizdays>=1.0.15
11
+ Requires-Dist: duckdb>=1.2.0
12
+ Requires-Dist: html5lib>=1.1
13
+ Requires-Dist: lxml>=4.9.2
14
+ Requires-Dist: numpy>=2.0.0
15
+ Requires-Dist: openpyxl>=3.1.5
16
+ Requires-Dist: pandas>=2.0.0
17
+ Requires-Dist: progressbar2>=4.3.2
18
+ Requires-Dist: pyarrow>=19.0.0
19
+ Requires-Dist: python-bcb>=0.3.2
20
+ Requires-Dist: pyyaml>=6.0
21
+ Requires-Dist: regexparser>=0.1.0
22
+ Requires-Dist: requests>=2.28.0
23
+ Requires-Dist: rich>=13.0.0
24
+ Requires-Dist: xlrd>=2.0.1
25
+ Description-Content-Type: text/markdown
26
+
27
+ # brasa
28
+
29
+ Extract finance market data from brazillian financial institutions: B3, ANBIMA, Tesouro Direto, CVM.
30
+
31
+ ## Installation
32
+
33
+ Install from PyPI:
34
+
35
+ pip install brasa
36
+
37
+ Or directly from GitHub (latest `main`):
38
+
39
+ pip install git+https://github.com/wilsonfreitas/brasa.git
40
+
41
+ With `uv`:
42
+
43
+ uv add brasa
44
+ uv add git+https://github.com/wilsonfreitas/brasa.git
45
+
46
+ ## Cache location (`BRASA_DATA_PATH`)
47
+
48
+ brasa stores everything — raw downloads, parsed parquet, and the metadata DB —
49
+ under a single *brasa home*, resolved from the `BRASA_DATA_PATH` environment
50
+ variable (falling back to `./.brasa-cache`).
51
+
52
+ A common setup keeps one central home exported globally (e.g. in `~/.env.local`).
53
+ For a one-off, project-local dataset, create a separate home and point at it for
54
+ the current shell only — a per-shell `export` shadows the global value:
55
+
56
+ BRASA_DATA_PATH=./brasa-home uv run python -m brasa.cli setup
57
+
58
+ `setup` then prints the exact line to activate that home:
59
+
60
+ Brasa home ready at /abs/path/to/brasa-home
61
+
62
+ To use this home in your shell:
63
+ export BRASA_DATA_PATH="/abs/path/to/brasa-home"
64
+
65
+ Run that `export` and every `brasa` command in the session uses the project-local
66
+ home; open a new shell to return to the central one.
67
+
68
+ ## Changelog
69
+
70
+ ### Deterministic Download Status Codes
71
+
72
+ Every download attempt is now classified with a single, unambiguous status code
73
+ persisted in the `download_trials` table:
74
+
75
+ | Symbol | Name | Trigger |
76
+ |--------|------------|---------------------------------------------------|
77
+ | `.` | PASSED | Successful download |
78
+ | `F` | FAILED | Expected failure (`DownloadException`) |
79
+ | `E` | ERROR | Unexpected exception |
80
+ | `S` | SKIPPED | Skipped (cache hit / invalid / duplicated) |
81
+ | `D` | DUPLICATED | Raw folder already exists |
82
+ | `I` | INVALID | Content validation failure |
83
+ | `W` | WARNING | Success with warnings |
84
+
85
+ **DB migration**: Existing caches are upgraded automatically on startup.
86
+ Legacy `downloaded=1` rows become `PASSED`; `downloaded=0` become `FAILED`.
87
+ A standalone migration script is also available:
88
+
89
+ ```bash
90
+ uv run python scripts/migrate_download_trials_status.py
91
+ ```
92
+
93
+ See [docs/USER_GUIDE.md](docs/USER_GUIDE.md#download-status-codes) for full details.
94
+
95
+ ### Import Local Files (`import_marketdata` / `brasa import`)
96
+
97
+ Files with no download URL — a one-off vendor file, a manually-provided upload,
98
+ or a corrected file for backfill — can now be imported using the same
99
+ validate → gzip → checksum-dedup → parse → store engine as `download`. Only
100
+ the acquisition step changes: bytes are read from disk instead of HTTP.
101
+
102
+ ```bash
103
+ # Backfill a single date into a template that normally downloads via HTTP
104
+ brasa import b3-cotahist-daily --path /data/backfill/COTAHIST_D02012024.TXT --arg refdate=2024-01-02
105
+
106
+ # Bulk import one file per business day using a date pattern
107
+ brasa import my-daily-template --path '/data/prices/%Y-%m-%d.csv' --arg refdate=@2026-06-01:2026-06-30
108
+ ```
109
+
110
+ ```python
111
+ from brasa import import_marketdata
112
+
113
+ import_marketdata("b3-cotahist-daily", path="/data/backfill/COTAHIST_D02012024.TXT", refdate="2024-01-02")
114
+ ```
115
+
116
+ See [docs/CLI.md](docs/CLI.md#import), [docs/API_REFERENCE.md](docs/API_REFERENCE.md#data-import),
117
+ and [docs/TEMPLATES.md](docs/TEMPLATES.md#importing-local-files-importer) for full details.
118
+
119
+ ## Publishing to PyPI
120
+
121
+ brasa is built with [hatchling](https://hatch.pypa.io/) and published manually.
122
+ Templates and SQL DDL are bundled inside the package (`brasa/files/`), so the
123
+ built wheel is self-contained.
124
+
125
+ 1. Bump `version` in `pyproject.toml` (the repo ships a `0.0.1` placeholder).
126
+ 2. Build the wheel and sdist:
127
+
128
+ ```bash
129
+ uv build
130
+ ```
131
+
132
+ Distributions are written to `dist/`.
133
+
134
+ 3. (Optional) Verify the wheel bundles the data files:
135
+
136
+ ```bash
137
+ BRASA_BUILD_TEST=1 uv run pytest tests/test_packaging_wheel.py -v
138
+ ```
139
+
140
+ 4. (Optional) Smoke-test in a clean environment:
141
+
142
+ ```bash
143
+ python -m venv /tmp/brasa-smoke
144
+ /tmp/brasa-smoke/bin/pip install dist/brasa-*.whl
145
+ /tmp/brasa-smoke/bin/python -c "import brasa; from brasa.engine.template import list_templates; print(len(list_templates()))"
146
+ ```
147
+
148
+ 5. Publish:
149
+
150
+ ```bash
151
+ # TestPyPI dry-run first (recommended)
152
+ uv publish --publish-url https://test.pypi.org/legacy/ --token "$TEST_PYPI_TOKEN"
153
+ # Production
154
+ uv publish --token "$UV_PUBLISH_TOKEN"
155
+ ```
156
+
157
+ A PyPI API token can be supplied via `--token`, the `UV_PUBLISH_TOKEN`
158
+ environment variable, or `~/.pypirc`.
@@ -0,0 +1,132 @@
1
+ # brasa
2
+
3
+ Extract finance market data from brazillian financial institutions: B3, ANBIMA, Tesouro Direto, CVM.
4
+
5
+ ## Installation
6
+
7
+ Install from PyPI:
8
+
9
+ pip install brasa
10
+
11
+ Or directly from GitHub (latest `main`):
12
+
13
+ pip install git+https://github.com/wilsonfreitas/brasa.git
14
+
15
+ With `uv`:
16
+
17
+ uv add brasa
18
+ uv add git+https://github.com/wilsonfreitas/brasa.git
19
+
20
+ ## Cache location (`BRASA_DATA_PATH`)
21
+
22
+ brasa stores everything — raw downloads, parsed parquet, and the metadata DB —
23
+ under a single *brasa home*, resolved from the `BRASA_DATA_PATH` environment
24
+ variable (falling back to `./.brasa-cache`).
25
+
26
+ A common setup keeps one central home exported globally (e.g. in `~/.env.local`).
27
+ For a one-off, project-local dataset, create a separate home and point at it for
28
+ the current shell only — a per-shell `export` shadows the global value:
29
+
30
+ BRASA_DATA_PATH=./brasa-home uv run python -m brasa.cli setup
31
+
32
+ `setup` then prints the exact line to activate that home:
33
+
34
+ Brasa home ready at /abs/path/to/brasa-home
35
+
36
+ To use this home in your shell:
37
+ export BRASA_DATA_PATH="/abs/path/to/brasa-home"
38
+
39
+ Run that `export` and every `brasa` command in the session uses the project-local
40
+ home; open a new shell to return to the central one.
41
+
42
+ ## Changelog
43
+
44
+ ### Deterministic Download Status Codes
45
+
46
+ Every download attempt is now classified with a single, unambiguous status code
47
+ persisted in the `download_trials` table:
48
+
49
+ | Symbol | Name | Trigger |
50
+ |--------|------------|---------------------------------------------------|
51
+ | `.` | PASSED | Successful download |
52
+ | `F` | FAILED | Expected failure (`DownloadException`) |
53
+ | `E` | ERROR | Unexpected exception |
54
+ | `S` | SKIPPED | Skipped (cache hit / invalid / duplicated) |
55
+ | `D` | DUPLICATED | Raw folder already exists |
56
+ | `I` | INVALID | Content validation failure |
57
+ | `W` | WARNING | Success with warnings |
58
+
59
+ **DB migration**: Existing caches are upgraded automatically on startup.
60
+ Legacy `downloaded=1` rows become `PASSED`; `downloaded=0` become `FAILED`.
61
+ A standalone migration script is also available:
62
+
63
+ ```bash
64
+ uv run python scripts/migrate_download_trials_status.py
65
+ ```
66
+
67
+ See [docs/USER_GUIDE.md](docs/USER_GUIDE.md#download-status-codes) for full details.
68
+
69
+ ### Import Local Files (`import_marketdata` / `brasa import`)
70
+
71
+ Files with no download URL — a one-off vendor file, a manually-provided upload,
72
+ or a corrected file for backfill — can now be imported using the same
73
+ validate → gzip → checksum-dedup → parse → store engine as `download`. Only
74
+ the acquisition step changes: bytes are read from disk instead of HTTP.
75
+
76
+ ```bash
77
+ # Backfill a single date into a template that normally downloads via HTTP
78
+ brasa import b3-cotahist-daily --path /data/backfill/COTAHIST_D02012024.TXT --arg refdate=2024-01-02
79
+
80
+ # Bulk import one file per business day using a date pattern
81
+ brasa import my-daily-template --path '/data/prices/%Y-%m-%d.csv' --arg refdate=@2026-06-01:2026-06-30
82
+ ```
83
+
84
+ ```python
85
+ from brasa import import_marketdata
86
+
87
+ import_marketdata("b3-cotahist-daily", path="/data/backfill/COTAHIST_D02012024.TXT", refdate="2024-01-02")
88
+ ```
89
+
90
+ See [docs/CLI.md](docs/CLI.md#import), [docs/API_REFERENCE.md](docs/API_REFERENCE.md#data-import),
91
+ and [docs/TEMPLATES.md](docs/TEMPLATES.md#importing-local-files-importer) for full details.
92
+
93
+ ## Publishing to PyPI
94
+
95
+ brasa is built with [hatchling](https://hatch.pypa.io/) and published manually.
96
+ Templates and SQL DDL are bundled inside the package (`brasa/files/`), so the
97
+ built wheel is self-contained.
98
+
99
+ 1. Bump `version` in `pyproject.toml` (the repo ships a `0.0.1` placeholder).
100
+ 2. Build the wheel and sdist:
101
+
102
+ ```bash
103
+ uv build
104
+ ```
105
+
106
+ Distributions are written to `dist/`.
107
+
108
+ 3. (Optional) Verify the wheel bundles the data files:
109
+
110
+ ```bash
111
+ BRASA_BUILD_TEST=1 uv run pytest tests/test_packaging_wheel.py -v
112
+ ```
113
+
114
+ 4. (Optional) Smoke-test in a clean environment:
115
+
116
+ ```bash
117
+ python -m venv /tmp/brasa-smoke
118
+ /tmp/brasa-smoke/bin/pip install dist/brasa-*.whl
119
+ /tmp/brasa-smoke/bin/python -c "import brasa; from brasa.engine.template import list_templates; print(len(list_templates()))"
120
+ ```
121
+
122
+ 5. Publish:
123
+
124
+ ```bash
125
+ # TestPyPI dry-run first (recommended)
126
+ uv publish --publish-url https://test.pypi.org/legacy/ --token "$TEST_PYPI_TOKEN"
127
+ # Production
128
+ uv publish --token "$UV_PUBLISH_TOKEN"
129
+ ```
130
+
131
+ A PyPI API token can be supplied via `--token`, the `UV_PUBLISH_TOKEN`
132
+ environment variable, or `~/.pypirc`.
@@ -0,0 +1,83 @@
1
+ from .engine import (
2
+ CacheManager,
3
+ DatasetCatalog,
4
+ DatasetInfo,
5
+ DownloadPlan,
6
+ DownloadPlanReport,
7
+ ExecutionPlan,
8
+ ExecutionStep,
9
+ MigrationReport,
10
+ OrchestratorReport,
11
+ PipelineOrchestrator,
12
+ RunAllReport,
13
+ TaskReport,
14
+ TemplateDependencyGraph,
15
+ Verbosity,
16
+ download_marketdata,
17
+ execute_download_plan,
18
+ get_dependency_graph,
19
+ get_execution_plan,
20
+ get_marketdata,
21
+ import_marketdata,
22
+ process_etl,
23
+ process_marketdata,
24
+ retrieve_template,
25
+ sync_catalog_from_disk,
26
+ )
27
+ from .queries import (
28
+ BrasaDB,
29
+ create_all_views,
30
+ describe,
31
+ describe_dataset,
32
+ get_dataset,
33
+ get_industry_sectors,
34
+ get_prices,
35
+ get_returns,
36
+ get_symbols,
37
+ list_datasets,
38
+ list_sql_tables,
39
+ show,
40
+ sql,
41
+ write_dataset,
42
+ )
43
+
44
+ __all__ = [
45
+ "BrasaDB",
46
+ "CacheManager",
47
+ "DatasetCatalog",
48
+ "DatasetInfo",
49
+ "DownloadPlan",
50
+ "DownloadPlanReport",
51
+ "ExecutionPlan",
52
+ "ExecutionStep",
53
+ "MigrationReport",
54
+ "OrchestratorReport",
55
+ "PipelineOrchestrator",
56
+ "RunAllReport",
57
+ "TaskReport",
58
+ "TemplateDependencyGraph",
59
+ "Verbosity",
60
+ "create_all_views",
61
+ "describe",
62
+ "describe_dataset",
63
+ "download_marketdata",
64
+ "execute_download_plan",
65
+ "get_dataset",
66
+ "get_dependency_graph",
67
+ "get_execution_plan",
68
+ "get_industry_sectors",
69
+ "get_marketdata",
70
+ "get_prices",
71
+ "get_returns",
72
+ "get_symbols",
73
+ "import_marketdata",
74
+ "list_datasets",
75
+ "list_sql_tables",
76
+ "process_etl",
77
+ "process_marketdata",
78
+ "retrieve_template",
79
+ "show",
80
+ "sql",
81
+ "sync_catalog_from_disk",
82
+ "write_dataset",
83
+ ]