finbrain-python 0.1.5__tar.gz → 0.1.6__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.
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/.github/workflows/ci.yml +1 -1
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/.github/workflows/release.yml +1 -1
- finbrain_python-0.1.6/CHANGELOG.md +64 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/PKG-INFO +78 -51
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/README.md +74 -51
- finbrain_python-0.1.6/RELEASE.md +112 -0
- finbrain_python-0.1.6/examples/async_example.py +78 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/pyproject.toml +7 -2
- finbrain_python-0.1.6/src/finbrain/aio/__init__.py +5 -0
- finbrain_python-0.1.6/src/finbrain/aio/client.py +168 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/__init__.py +1 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/_utils.py +37 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/analyst_ratings.py +48 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/app_ratings.py +49 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/available.py +41 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/house_trades.py +48 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/insider_transactions.py +40 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/linkedin_data.py +48 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/options.py +48 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/predictions.py +85 -0
- finbrain_python-0.1.6/src/finbrain/aio/endpoints/sentiments.py +55 -0
- finbrain_python-0.1.6/src/finbrain/endpoints/_utils.py +37 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/analyst_ratings.py +4 -10
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/app_ratings.py +4 -12
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/house_trades.py +4 -10
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/linkedin_data.py +4 -10
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/options.py +4 -10
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/sentiments.py +4 -10
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/plotting.py +2 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/PKG-INFO +78 -51
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/SOURCES.txt +17 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/requires.txt +5 -0
- finbrain_python-0.1.6/tests/test_async_client.py +72 -0
- finbrain_python-0.1.6/tests/test_plotting.py +27 -0
- finbrain_python-0.1.5/src/finbrain/aio/client.py +0 -0
- finbrain_python-0.1.5/tests/__init__.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/.gitattributes +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/.gitignore +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/LICENSE +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/setup.cfg +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/__init__.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/client.py +0 -0
- {finbrain_python-0.1.5/src/finbrain/aio → finbrain_python-0.1.6/src/finbrain/endpoints}/__init__.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/available.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/insider_transactions.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/endpoints/predictions.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/exceptions.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain/py.typed +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/dependency_links.txt +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/top_level.txt +0 -0
- {finbrain_python-0.1.5/src/finbrain/endpoints → finbrain_python-0.1.6/tests}/__init__.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/conftest.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_analyst_ratings.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_app_ratings.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_available.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_house_trades.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_insider_transactions.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_linkedin_data.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_options.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_predictions.py +0 -0
- {finbrain_python-0.1.5 → finbrain_python-0.1.6}/tests/test_sentiments.py +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.6] - 2025-10-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Async Support**: Full async/await implementation using `httpx`
|
|
14
|
+
- `AsyncFinBrainClient` with context manager support
|
|
15
|
+
- All 9 endpoints have async equivalents
|
|
16
|
+
- Install with: `pip install finbrain-python[async]`
|
|
17
|
+
- Example: `examples/async_example.py`
|
|
18
|
+
- **Python 3.13 Support**: Added to CI test matrix (now testing 3.9, 3.10, 3.11, 3.12, 3.13)
|
|
19
|
+
- **Async utilities module**: `src/finbrain/aio/endpoints/_utils.py`
|
|
20
|
+
- **Sync utilities module**: `src/finbrain/endpoints/_utils.py`
|
|
21
|
+
- **Plotting tests**: `tests/test_plotting.py`
|
|
22
|
+
- **Async client tests**: `tests/test_async_client.py`
|
|
23
|
+
- **Release guide**: `RELEASE.md` with tag conventions
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
- **Tag Convention**: Now using `v` prefix (e.g., `v0.1.6` instead of `0.1.6`)
|
|
27
|
+
- **GitHub Actions**: Updated to trigger on `v[0-9]*` tags
|
|
28
|
+
- **Code Deduplication**: Consolidated 12 duplicate `_to_datestr()` helpers into 2 utility modules
|
|
29
|
+
- **README**: Added async usage section with examples
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
- **Plotting Error Handling**: `options()` method now raises clear `ValueError` for invalid `kind` parameter instead of `NameError`
|
|
33
|
+
|
|
34
|
+
### Dependencies
|
|
35
|
+
- Added `httpx>=0.24` as optional dependency for async support
|
|
36
|
+
- Added `pytest-asyncio` as dev dependency
|
|
37
|
+
|
|
38
|
+
## [0.1.5] - 2024-09-18
|
|
39
|
+
|
|
40
|
+
Previous releases...
|
|
41
|
+
|
|
42
|
+
## [0.1.4] - 2024-06-25
|
|
43
|
+
|
|
44
|
+
Previous releases...
|
|
45
|
+
|
|
46
|
+
## [0.1.3] - 2024-06-13
|
|
47
|
+
|
|
48
|
+
Previous releases...
|
|
49
|
+
|
|
50
|
+
## [0.1.2] - 2024-06-13
|
|
51
|
+
|
|
52
|
+
Previous releases...
|
|
53
|
+
|
|
54
|
+
## [0.1.1] - 2024-06-13
|
|
55
|
+
|
|
56
|
+
Previous releases...
|
|
57
|
+
|
|
58
|
+
[Unreleased]: https://github.com/ahmetsbilgin/finbrain-python/compare/v0.1.6...HEAD
|
|
59
|
+
[0.1.6]: https://github.com/ahmetsbilgin/finbrain-python/compare/0.1.5...v0.1.6
|
|
60
|
+
[0.1.5]: https://github.com/ahmetsbilgin/finbrain-python/compare/0.1.4...0.1.5
|
|
61
|
+
[0.1.4]: https://github.com/ahmetsbilgin/finbrain-python/compare/0.1.3...0.1.4
|
|
62
|
+
[0.1.3]: https://github.com/ahmetsbilgin/finbrain-python/compare/0.1.2...0.1.3
|
|
63
|
+
[0.1.2]: https://github.com/ahmetsbilgin/finbrain-python/compare/0.1.1...0.1.2
|
|
64
|
+
[0.1.1]: https://github.com/ahmetsbilgin/finbrain-python/releases/tag/0.1.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: finbrain-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Official Python client for the FinBrain API
|
|
5
5
|
Author-email: Ahmet Salim Bilgin <ahmet@finbrain.tech>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -12,9 +12,13 @@ Requires-Dist: typer[all]>=0.12
|
|
|
12
12
|
Requires-Dist: pandas>=2.2
|
|
13
13
|
Requires-Dist: plotly>=6.0
|
|
14
14
|
Requires-Dist: numpy>=1.22.4
|
|
15
|
+
Provides-Extra: async
|
|
16
|
+
Requires-Dist: httpx>=0.24; extra == "async"
|
|
15
17
|
Provides-Extra: dev
|
|
16
18
|
Requires-Dist: pytest; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
17
20
|
Requires-Dist: responses; extra == "dev"
|
|
21
|
+
Requires-Dist: httpx>=0.24; extra == "dev"
|
|
18
22
|
Requires-Dist: build; extra == "dev"
|
|
19
23
|
Requires-Dist: twine; extra == "dev"
|
|
20
24
|
Requires-Dist: ruff; extra == "dev"
|
|
@@ -34,6 +38,7 @@ Fetch deep-learning price predictions, sentiment scores, insider trades, LinkedI
|
|
|
34
38
|
---
|
|
35
39
|
|
|
36
40
|
## ✨ Features
|
|
41
|
+
|
|
37
42
|
- One-line auth (`FinBrainClient(api_key="…")`)
|
|
38
43
|
- Complete endpoint coverage (predictions, sentiments, options, insider, etc.)
|
|
39
44
|
- Transparent retries & custom error hierarchy (`FinBrainError`)
|
|
@@ -45,12 +50,16 @@ Fetch deep-learning price predictions, sentiment scores, insider trades, LinkedI
|
|
|
45
50
|
---
|
|
46
51
|
|
|
47
52
|
## 🚀 Quick start
|
|
53
|
+
|
|
48
54
|
Install the SDK:
|
|
49
|
-
|
|
55
|
+
|
|
56
|
+
```bash
|
|
50
57
|
pip install finbrain-python
|
|
51
58
|
```
|
|
59
|
+
|
|
52
60
|
Create a client and fetch data:
|
|
53
|
-
|
|
61
|
+
|
|
62
|
+
```python
|
|
54
63
|
from finbrain import FinBrainClient
|
|
55
64
|
|
|
56
65
|
fb = FinBrainClient(api_key="YOUR_KEY") # create once, reuse below
|
|
@@ -103,6 +112,45 @@ fb.sentiments.ticker("S&P 500", "AMZN",
|
|
|
103
112
|
as_dataframe=True)
|
|
104
113
|
```
|
|
105
114
|
|
|
115
|
+
## ⚡ Async Usage
|
|
116
|
+
|
|
117
|
+
For async/await support, install with the `async` extra:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install finbrain-python[async]
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Then use `AsyncFinBrainClient` with `httpx`:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
import asyncio
|
|
127
|
+
from finbrain.aio import AsyncFinBrainClient
|
|
128
|
+
|
|
129
|
+
async def main():
|
|
130
|
+
async with AsyncFinBrainClient(api_key="YOUR_KEY") as fb:
|
|
131
|
+
# All methods are async and return the same data structures
|
|
132
|
+
markets = await fb.available.markets()
|
|
133
|
+
|
|
134
|
+
# Fetch predictions
|
|
135
|
+
predictions = await fb.predictions.ticker("AMZN", as_dataframe=True)
|
|
136
|
+
|
|
137
|
+
# Fetch sentiment data
|
|
138
|
+
sentiment = await fb.sentiments.ticker(
|
|
139
|
+
"S&P 500", "AMZN",
|
|
140
|
+
date_from="2025-01-01",
|
|
141
|
+
date_to="2025-06-30",
|
|
142
|
+
as_dataframe=True
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# All other endpoints work the same way
|
|
146
|
+
app_ratings = await fb.app_ratings.ticker("S&P 500", "AMZN", as_dataframe=True)
|
|
147
|
+
analyst_ratings = await fb.analyst_ratings.ticker("S&P 500", "AMZN", as_dataframe=True)
|
|
148
|
+
|
|
149
|
+
asyncio.run(main())
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Note**: The async client uses `httpx.AsyncClient` and must be used with `async with` context manager for proper resource cleanup.
|
|
153
|
+
|
|
106
154
|
## 📈 Plotting
|
|
107
155
|
|
|
108
156
|
Plot helpers in a nutshell
|
|
@@ -111,7 +159,7 @@ Plot helpers in a nutshell
|
|
|
111
159
|
|
|
112
160
|
- `as_json=True` – skips display and returns the figure as a Plotly-JSON string, ready to embed elsewhere.
|
|
113
161
|
|
|
114
|
-
```
|
|
162
|
+
```python
|
|
115
163
|
# ---------- App Ratings Chart - Apple App Store or Google Play Store ----------
|
|
116
164
|
fb.plot.app_ratings("S&P 500", "AMZN",
|
|
117
165
|
store="app", # "play" for Google Play Store
|
|
@@ -147,33 +195,12 @@ To call the API you need an **API key**, obtained by purchasing a **FinBrain API
|
|
|
147
195
|
2. Copy the key from your dashboard.
|
|
148
196
|
3. Pass it once when you create the client:
|
|
149
197
|
|
|
150
|
-
```
|
|
198
|
+
```python
|
|
151
199
|
from finbrain import FinBrainClient
|
|
152
200
|
fb = FinBrainClient(api_key="YOUR_KEY")
|
|
153
201
|
```
|
|
154
202
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
import asyncio, os
|
|
159
|
-
from finbrain.aio import FinBrainAsyncClient async
|
|
160
|
-
def main():
|
|
161
|
-
async with FinBrainAsyncClient(api_key=os.getenv("FINBRAIN_API_KEY")) as fb:
|
|
162
|
-
data = await fb.sentiments.ticker("S&P 500", "AMZN")
|
|
163
|
-
print(list(data["sentimentAnalysis"].items())[:3])
|
|
164
|
-
|
|
165
|
-
asyncio.run(main())
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### CLI (currently under development)
|
|
169
|
-
|
|
170
|
-
```
|
|
171
|
-
export FINBRAIN_API_KEY=your_key
|
|
172
|
-
finbrain markets
|
|
173
|
-
finbrain predict AAPL --type daily
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
----------
|
|
203
|
+
---
|
|
177
204
|
|
|
178
205
|
## 📚 Supported endpoints
|
|
179
206
|
|
|
@@ -191,11 +218,11 @@ finbrain predict AAPL --type daily
|
|
|
191
218
|
| LinkedIn | `client.linkedin_data.ticker()` | `/linkedindata/{MARKET}/{TICKER}` |
|
|
192
219
|
| Options – Put/Call | `client.options.put_call()` | `/putcalldata/{MARKET}/{TICKER}` |
|
|
193
220
|
|
|
194
|
-
|
|
221
|
+
---
|
|
195
222
|
|
|
196
223
|
## 🛠️ Error-handling
|
|
197
224
|
|
|
198
|
-
```
|
|
225
|
+
```python
|
|
199
226
|
from finbrain.exceptions import BadRequest
|
|
200
227
|
try:
|
|
201
228
|
fb.predictions.ticker("MSFT", prediction_type="weekly")
|
|
@@ -212,24 +239,24 @@ except BadRequest as exc:
|
|
|
212
239
|
| 405 | `MethodNotAllowed` | HTTP method not supported on endpoint |
|
|
213
240
|
| 500 | `ServerError` | FinBrain internal error |
|
|
214
241
|
|
|
215
|
-
|
|
242
|
+
---
|
|
216
243
|
|
|
217
244
|
## 🔄 Versioning & release
|
|
218
245
|
|
|
219
|
-
-
|
|
220
|
-
|
|
221
|
-
- Version auto-generated from Git tags (setuptools-scm)
|
|
246
|
+
- Semantic Versioning (`MAJOR.MINOR.PATCH`)
|
|
222
247
|
|
|
223
|
-
|
|
224
|
-
|
|
248
|
+
- Version auto-generated from Git tags (setuptools-scm)
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git tag -a v0.2.0 -m "Add options.chain endpoint"
|
|
225
252
|
git push --tags # GitHub Actions builds & uploads to PyPI
|
|
226
253
|
```
|
|
227
254
|
|
|
228
|
-
|
|
255
|
+
---
|
|
229
256
|
|
|
230
257
|
## 🧑💻 Development
|
|
231
258
|
|
|
232
|
-
```
|
|
259
|
+
```bash
|
|
233
260
|
git clone https://github.com/finbrain-tech/finbrain-python
|
|
234
261
|
cd finbrain-python
|
|
235
262
|
python -m venv .venv && source .venv/bin/activate
|
|
@@ -243,35 +270,35 @@ pytest -q # unit tests (mocked)
|
|
|
243
270
|
|
|
244
271
|
Set `FINBRAIN_LIVE_KEY`, then run:
|
|
245
272
|
|
|
246
|
-
```
|
|
273
|
+
```bash
|
|
247
274
|
pytest -m integration
|
|
248
275
|
```
|
|
249
|
-
|
|
276
|
+
|
|
277
|
+
---
|
|
250
278
|
|
|
251
279
|
## 🤝 Contributing
|
|
252
280
|
|
|
253
|
-
1.
|
|
254
|
-
|
|
255
|
-
2. Add tests & run `ruff --fix`
|
|
256
|
-
|
|
257
|
-
3. Ensure `pytest` & CI pass
|
|
258
|
-
|
|
259
|
-
4. Open a PR — thanks!
|
|
260
|
-
|
|
281
|
+
1. Fork → create a feature branch
|
|
261
282
|
|
|
262
|
-
|
|
283
|
+
2. Add tests & run `ruff --fix`
|
|
284
|
+
|
|
285
|
+
3. Ensure `pytest` & CI pass
|
|
286
|
+
|
|
287
|
+
4. Open a PR — thanks!
|
|
288
|
+
|
|
289
|
+
---
|
|
263
290
|
|
|
264
291
|
## 🔒 Security
|
|
265
292
|
|
|
266
|
-
Please report vulnerabilities to
|
|
293
|
+
Please report vulnerabilities to **<info@finbrain.tech>**.
|
|
267
294
|
We respond within 48 hours.
|
|
268
295
|
|
|
269
|
-
|
|
296
|
+
---
|
|
270
297
|
|
|
271
298
|
## 📜 License
|
|
272
299
|
|
|
273
300
|
MIT — see [LICENSE](LICENSE).
|
|
274
301
|
|
|
275
|
-
|
|
302
|
+
---
|
|
276
303
|
|
|
277
304
|
© 2025 FinBrain Technologies — Built with ❤️ for the quant community.
|
|
@@ -12,6 +12,7 @@ Fetch deep-learning price predictions, sentiment scores, insider trades, LinkedI
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
## ✨ Features
|
|
15
|
+
|
|
15
16
|
- One-line auth (`FinBrainClient(api_key="…")`)
|
|
16
17
|
- Complete endpoint coverage (predictions, sentiments, options, insider, etc.)
|
|
17
18
|
- Transparent retries & custom error hierarchy (`FinBrainError`)
|
|
@@ -23,12 +24,16 @@ Fetch deep-learning price predictions, sentiment scores, insider trades, LinkedI
|
|
|
23
24
|
---
|
|
24
25
|
|
|
25
26
|
## 🚀 Quick start
|
|
27
|
+
|
|
26
28
|
Install the SDK:
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
```bash
|
|
28
31
|
pip install finbrain-python
|
|
29
32
|
```
|
|
33
|
+
|
|
30
34
|
Create a client and fetch data:
|
|
31
|
-
|
|
35
|
+
|
|
36
|
+
```python
|
|
32
37
|
from finbrain import FinBrainClient
|
|
33
38
|
|
|
34
39
|
fb = FinBrainClient(api_key="YOUR_KEY") # create once, reuse below
|
|
@@ -81,6 +86,45 @@ fb.sentiments.ticker("S&P 500", "AMZN",
|
|
|
81
86
|
as_dataframe=True)
|
|
82
87
|
```
|
|
83
88
|
|
|
89
|
+
## ⚡ Async Usage
|
|
90
|
+
|
|
91
|
+
For async/await support, install with the `async` extra:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install finbrain-python[async]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Then use `AsyncFinBrainClient` with `httpx`:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import asyncio
|
|
101
|
+
from finbrain.aio import AsyncFinBrainClient
|
|
102
|
+
|
|
103
|
+
async def main():
|
|
104
|
+
async with AsyncFinBrainClient(api_key="YOUR_KEY") as fb:
|
|
105
|
+
# All methods are async and return the same data structures
|
|
106
|
+
markets = await fb.available.markets()
|
|
107
|
+
|
|
108
|
+
# Fetch predictions
|
|
109
|
+
predictions = await fb.predictions.ticker("AMZN", as_dataframe=True)
|
|
110
|
+
|
|
111
|
+
# Fetch sentiment data
|
|
112
|
+
sentiment = await fb.sentiments.ticker(
|
|
113
|
+
"S&P 500", "AMZN",
|
|
114
|
+
date_from="2025-01-01",
|
|
115
|
+
date_to="2025-06-30",
|
|
116
|
+
as_dataframe=True
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# All other endpoints work the same way
|
|
120
|
+
app_ratings = await fb.app_ratings.ticker("S&P 500", "AMZN", as_dataframe=True)
|
|
121
|
+
analyst_ratings = await fb.analyst_ratings.ticker("S&P 500", "AMZN", as_dataframe=True)
|
|
122
|
+
|
|
123
|
+
asyncio.run(main())
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Note**: The async client uses `httpx.AsyncClient` and must be used with `async with` context manager for proper resource cleanup.
|
|
127
|
+
|
|
84
128
|
## 📈 Plotting
|
|
85
129
|
|
|
86
130
|
Plot helpers in a nutshell
|
|
@@ -89,7 +133,7 @@ Plot helpers in a nutshell
|
|
|
89
133
|
|
|
90
134
|
- `as_json=True` – skips display and returns the figure as a Plotly-JSON string, ready to embed elsewhere.
|
|
91
135
|
|
|
92
|
-
```
|
|
136
|
+
```python
|
|
93
137
|
# ---------- App Ratings Chart - Apple App Store or Google Play Store ----------
|
|
94
138
|
fb.plot.app_ratings("S&P 500", "AMZN",
|
|
95
139
|
store="app", # "play" for Google Play Store
|
|
@@ -125,33 +169,12 @@ To call the API you need an **API key**, obtained by purchasing a **FinBrain API
|
|
|
125
169
|
2. Copy the key from your dashboard.
|
|
126
170
|
3. Pass it once when you create the client:
|
|
127
171
|
|
|
128
|
-
```
|
|
172
|
+
```python
|
|
129
173
|
from finbrain import FinBrainClient
|
|
130
174
|
fb = FinBrainClient(api_key="YOUR_KEY")
|
|
131
175
|
```
|
|
132
176
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
```
|
|
136
|
-
import asyncio, os
|
|
137
|
-
from finbrain.aio import FinBrainAsyncClient async
|
|
138
|
-
def main():
|
|
139
|
-
async with FinBrainAsyncClient(api_key=os.getenv("FINBRAIN_API_KEY")) as fb:
|
|
140
|
-
data = await fb.sentiments.ticker("S&P 500", "AMZN")
|
|
141
|
-
print(list(data["sentimentAnalysis"].items())[:3])
|
|
142
|
-
|
|
143
|
-
asyncio.run(main())
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### CLI (currently under development)
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
export FINBRAIN_API_KEY=your_key
|
|
150
|
-
finbrain markets
|
|
151
|
-
finbrain predict AAPL --type daily
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
----------
|
|
177
|
+
---
|
|
155
178
|
|
|
156
179
|
## 📚 Supported endpoints
|
|
157
180
|
|
|
@@ -169,11 +192,11 @@ finbrain predict AAPL --type daily
|
|
|
169
192
|
| LinkedIn | `client.linkedin_data.ticker()` | `/linkedindata/{MARKET}/{TICKER}` |
|
|
170
193
|
| Options – Put/Call | `client.options.put_call()` | `/putcalldata/{MARKET}/{TICKER}` |
|
|
171
194
|
|
|
172
|
-
|
|
195
|
+
---
|
|
173
196
|
|
|
174
197
|
## 🛠️ Error-handling
|
|
175
198
|
|
|
176
|
-
```
|
|
199
|
+
```python
|
|
177
200
|
from finbrain.exceptions import BadRequest
|
|
178
201
|
try:
|
|
179
202
|
fb.predictions.ticker("MSFT", prediction_type="weekly")
|
|
@@ -190,24 +213,24 @@ except BadRequest as exc:
|
|
|
190
213
|
| 405 | `MethodNotAllowed` | HTTP method not supported on endpoint |
|
|
191
214
|
| 500 | `ServerError` | FinBrain internal error |
|
|
192
215
|
|
|
193
|
-
|
|
216
|
+
---
|
|
194
217
|
|
|
195
218
|
## 🔄 Versioning & release
|
|
196
219
|
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
- Version auto-generated from Git tags (setuptools-scm)
|
|
220
|
+
- Semantic Versioning (`MAJOR.MINOR.PATCH`)
|
|
200
221
|
|
|
201
|
-
|
|
202
|
-
|
|
222
|
+
- Version auto-generated from Git tags (setuptools-scm)
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
git tag -a v0.2.0 -m "Add options.chain endpoint"
|
|
203
226
|
git push --tags # GitHub Actions builds & uploads to PyPI
|
|
204
227
|
```
|
|
205
228
|
|
|
206
|
-
|
|
229
|
+
---
|
|
207
230
|
|
|
208
231
|
## 🧑💻 Development
|
|
209
232
|
|
|
210
|
-
```
|
|
233
|
+
```bash
|
|
211
234
|
git clone https://github.com/finbrain-tech/finbrain-python
|
|
212
235
|
cd finbrain-python
|
|
213
236
|
python -m venv .venv && source .venv/bin/activate
|
|
@@ -221,35 +244,35 @@ pytest -q # unit tests (mocked)
|
|
|
221
244
|
|
|
222
245
|
Set `FINBRAIN_LIVE_KEY`, then run:
|
|
223
246
|
|
|
224
|
-
```
|
|
247
|
+
```bash
|
|
225
248
|
pytest -m integration
|
|
226
249
|
```
|
|
227
|
-
|
|
250
|
+
|
|
251
|
+
---
|
|
228
252
|
|
|
229
253
|
## 🤝 Contributing
|
|
230
254
|
|
|
231
|
-
1.
|
|
232
|
-
|
|
233
|
-
2. Add tests & run `ruff --fix`
|
|
234
|
-
|
|
235
|
-
3. Ensure `pytest` & CI pass
|
|
236
|
-
|
|
237
|
-
4. Open a PR — thanks!
|
|
238
|
-
|
|
255
|
+
1. Fork → create a feature branch
|
|
239
256
|
|
|
240
|
-
|
|
257
|
+
2. Add tests & run `ruff --fix`
|
|
258
|
+
|
|
259
|
+
3. Ensure `pytest` & CI pass
|
|
260
|
+
|
|
261
|
+
4. Open a PR — thanks!
|
|
262
|
+
|
|
263
|
+
---
|
|
241
264
|
|
|
242
265
|
## 🔒 Security
|
|
243
266
|
|
|
244
|
-
Please report vulnerabilities to
|
|
267
|
+
Please report vulnerabilities to **<info@finbrain.tech>**.
|
|
245
268
|
We respond within 48 hours.
|
|
246
269
|
|
|
247
|
-
|
|
270
|
+
---
|
|
248
271
|
|
|
249
272
|
## 📜 License
|
|
250
273
|
|
|
251
274
|
MIT — see [LICENSE](LICENSE).
|
|
252
275
|
|
|
253
|
-
|
|
276
|
+
---
|
|
254
277
|
|
|
255
|
-
© 2025 FinBrain Technologies — Built with ❤️ for the quant community.
|
|
278
|
+
© 2025 FinBrain Technologies — Built with ❤️ for the quant community.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Release Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to create a new release for finbrain-python.
|
|
4
|
+
|
|
5
|
+
## Tag Convention
|
|
6
|
+
|
|
7
|
+
Starting from v0.1.6, we use **`v`-prefixed tags** (e.g., `v0.1.6`, `v0.2.0`, `v1.0.0`).
|
|
8
|
+
|
|
9
|
+
## Release Process
|
|
10
|
+
|
|
11
|
+
### 1. Update CHANGELOG.md
|
|
12
|
+
|
|
13
|
+
Edit `CHANGELOG.md` and move items from `[Unreleased]` to a new version section:
|
|
14
|
+
|
|
15
|
+
```markdown
|
|
16
|
+
## [0.1.6] - 2025-01-15
|
|
17
|
+
### Added
|
|
18
|
+
- Your new features
|
|
19
|
+
### Changed
|
|
20
|
+
- Your changes
|
|
21
|
+
### Fixed
|
|
22
|
+
- Your bug fixes
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. Create and Push Tag
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git add CHANGELOG.md
|
|
29
|
+
git commit -m "Release v0.1.6"
|
|
30
|
+
git tag -a v0.1.6 -m "Release v0.1.6: Brief description"
|
|
31
|
+
git push origin main
|
|
32
|
+
git push origin v0.1.6
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 3. GitHub Actions (Automated)
|
|
36
|
+
|
|
37
|
+
GitHub Actions will automatically:
|
|
38
|
+
- Build the wheel and source distribution
|
|
39
|
+
- Upload to TestPyPI first
|
|
40
|
+
- Upload to production PyPI
|
|
41
|
+
|
|
42
|
+
### 4. Create GitHub Release (Manual)
|
|
43
|
+
|
|
44
|
+
1. Go to: https://github.com/ahmetsbilgin/finbrain-python/releases/new
|
|
45
|
+
2. Select tag: `v0.1.6`
|
|
46
|
+
3. Title: `v0.1.6 - Brief Description`
|
|
47
|
+
4. Copy the relevant section from `CHANGELOG.md` into the description
|
|
48
|
+
5. Click "Publish release"
|
|
49
|
+
|
|
50
|
+
### 5. Verify
|
|
51
|
+
|
|
52
|
+
- Check PyPI: https://pypi.org/project/finbrain-python/
|
|
53
|
+
- Test installation: `pip install finbrain-python==0.1.6`
|
|
54
|
+
|
|
55
|
+
## How setuptools-scm Works
|
|
56
|
+
|
|
57
|
+
- Tag `v0.1.6` → Package version `0.1.6`
|
|
58
|
+
- The `v` prefix is automatically stripped
|
|
59
|
+
|
|
60
|
+
### Previous Tag Convention
|
|
61
|
+
|
|
62
|
+
Earlier releases used tags without the `v` prefix (e.g., `0.1.0`, `0.1.4`). Both formats work with setuptools-scm, but going forward we standardize on `v`-prefixed tags for consistency with common practices.
|
|
63
|
+
|
|
64
|
+
### Workflow Trigger
|
|
65
|
+
|
|
66
|
+
The GitHub Actions release workflow triggers on: `tags: ['v[0-9]*']`
|
|
67
|
+
|
|
68
|
+
This matches:
|
|
69
|
+
|
|
70
|
+
- ✅ `v0.1.0`
|
|
71
|
+
- ✅ `v1.2.3`
|
|
72
|
+
- ✅ `v10.20.30`
|
|
73
|
+
- ❌ `0.1.0` (old format, won't trigger)
|
|
74
|
+
- ❌ `version-0.1.0` (won't trigger)
|
|
75
|
+
|
|
76
|
+
### Version Scheme
|
|
77
|
+
|
|
78
|
+
We follow **Semantic Versioning** (semver):
|
|
79
|
+
|
|
80
|
+
- `MAJOR.MINOR.PATCH`
|
|
81
|
+
- **MAJOR**: Breaking changes
|
|
82
|
+
- **MINOR**: New features, backward compatible
|
|
83
|
+
- **PATCH**: Bug fixes, backward compatible
|
|
84
|
+
|
|
85
|
+
### Examples
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Patch release (bug fixes)
|
|
89
|
+
git tag -a v0.1.5 -m "Fix retry logic in async client"
|
|
90
|
+
|
|
91
|
+
# Minor release (new features)
|
|
92
|
+
git tag -a v0.2.0 -m "Add async support"
|
|
93
|
+
|
|
94
|
+
# Major release (breaking changes)
|
|
95
|
+
git tag -a v1.0.0 -m "Stable API release"
|
|
96
|
+
|
|
97
|
+
# Push the tag
|
|
98
|
+
git push origin <tag-name>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Checking Current Version
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# See all tags
|
|
105
|
+
git tag -l
|
|
106
|
+
|
|
107
|
+
# See latest tag
|
|
108
|
+
git describe --tags --abbrev=0
|
|
109
|
+
|
|
110
|
+
# Check what version setuptools-scm will generate
|
|
111
|
+
python -m setuptools_scm
|
|
112
|
+
```
|