finbrain-python 0.1.4__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.4 → finbrain_python-0.1.6}/.github/workflows/ci.yml +1 -1
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/.github/workflows/release.yml +1 -1
- finbrain_python-0.1.6/CHANGELOG.md +64 -0
- {finbrain_python-0.1.4/src/finbrain_python.egg-info → finbrain_python-0.1.6}/PKG-INFO +83 -54
- finbrain_python-0.1.4/PKG-INFO → finbrain_python-0.1.6/README.md +78 -75
- finbrain_python-0.1.6/RELEASE.md +112 -0
- finbrain_python-0.1.6/examples/async_example.py +78 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/pyproject.toml +11 -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.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/analyst_ratings.py +4 -10
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/app_ratings.py +4 -12
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/house_trades.py +4 -10
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/linkedin_data.py +4 -10
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/options.py +4 -10
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/sentiments.py +4 -10
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/plotting.py +2 -0
- finbrain_python-0.1.6/src/finbrain/py.typed +1 -0
- finbrain_python-0.1.4/README.md → finbrain_python-0.1.6/src/finbrain_python.egg-info/PKG-INFO +105 -54
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/SOURCES.txt +18 -0
- {finbrain_python-0.1.4 → 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.4/src/finbrain/aio/client.py +0 -0
- finbrain_python-0.1.4/tests/__init__.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/.gitattributes +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/.gitignore +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/LICENSE +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/setup.cfg +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/__init__.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/client.py +0 -0
- {finbrain_python-0.1.4/src/finbrain/aio → finbrain_python-0.1.6/src/finbrain/endpoints}/__init__.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/available.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/insider_transactions.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/endpoints/predictions.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain/exceptions.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/dependency_links.txt +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/src/finbrain_python.egg-info/top_level.txt +0 -0
- {finbrain_python-0.1.4/src/finbrain/endpoints → finbrain_python-0.1.6/tests}/__init__.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/conftest.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_analyst_ratings.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_app_ratings.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_available.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_house_trades.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_insider_transactions.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_linkedin_data.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_options.py +0 -0
- {finbrain_python-0.1.4 → finbrain_python-0.1.6}/tests/test_predictions.py +0 -0
- {finbrain_python-0.1.4 → 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
|
|
@@ -120,15 +168,17 @@ fb.plot.app_ratings("S&P 500", "AMZN",
|
|
|
120
168
|
|
|
121
169
|
# ---------- LinkedIn Metrics Chart ----------
|
|
122
170
|
fb.plot.linkedin("S&P 500", "AMZN",
|
|
123
|
-
date_from="2025-01-01",
|
|
171
|
+
date_from="2025-01-01",
|
|
172
|
+
date_to="2025-06-30")
|
|
124
173
|
|
|
125
174
|
# ---------- Put-Call Ratio Chart ----------
|
|
126
175
|
fb.plot.options("S&P 500", "AMZN",
|
|
127
176
|
kind="put_call",
|
|
128
|
-
date_from="2025-01-01",
|
|
177
|
+
date_from="2025-01-01",
|
|
178
|
+
date_to="2025-06-30")
|
|
129
179
|
|
|
130
180
|
# ---------- Predictions Chart ----------
|
|
131
|
-
fb.plot.predictions("AMZN")
|
|
181
|
+
fb.plot.predictions("AMZN") # prediction_type="monthly" for monthly predictions
|
|
132
182
|
|
|
133
183
|
# ---------- Sentiments Chart ----------
|
|
134
184
|
fb.plot.sentiments("S&P 500", "AMZN",
|
|
@@ -145,33 +195,12 @@ To call the API you need an **API key**, obtained by purchasing a **FinBrain API
|
|
|
145
195
|
2. Copy the key from your dashboard.
|
|
146
196
|
3. Pass it once when you create the client:
|
|
147
197
|
|
|
148
|
-
```
|
|
198
|
+
```python
|
|
149
199
|
from finbrain import FinBrainClient
|
|
150
200
|
fb = FinBrainClient(api_key="YOUR_KEY")
|
|
151
201
|
```
|
|
152
202
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
import asyncio, os
|
|
157
|
-
from finbrain.aio import FinBrainAsyncClient async
|
|
158
|
-
def main():
|
|
159
|
-
async with FinBrainAsyncClient(api_key=os.getenv("FINBRAIN_API_KEY")) as fb:
|
|
160
|
-
data = await fb.sentiments.ticker("S&P 500", "AMZN")
|
|
161
|
-
print(list(data["sentimentAnalysis"].items())[:3])
|
|
162
|
-
|
|
163
|
-
asyncio.run(main())
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### CLI (currently under development)
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
export FINBRAIN_API_KEY=your_key
|
|
170
|
-
finbrain markets
|
|
171
|
-
finbrain predict AAPL --type daily
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
----------
|
|
203
|
+
---
|
|
175
204
|
|
|
176
205
|
## 📚 Supported endpoints
|
|
177
206
|
|
|
@@ -189,11 +218,11 @@ finbrain predict AAPL --type daily
|
|
|
189
218
|
| LinkedIn | `client.linkedin_data.ticker()` | `/linkedindata/{MARKET}/{TICKER}` |
|
|
190
219
|
| Options – Put/Call | `client.options.put_call()` | `/putcalldata/{MARKET}/{TICKER}` |
|
|
191
220
|
|
|
192
|
-
|
|
221
|
+
---
|
|
193
222
|
|
|
194
223
|
## 🛠️ Error-handling
|
|
195
224
|
|
|
196
|
-
```
|
|
225
|
+
```python
|
|
197
226
|
from finbrain.exceptions import BadRequest
|
|
198
227
|
try:
|
|
199
228
|
fb.predictions.ticker("MSFT", prediction_type="weekly")
|
|
@@ -210,24 +239,24 @@ except BadRequest as exc:
|
|
|
210
239
|
| 405 | `MethodNotAllowed` | HTTP method not supported on endpoint |
|
|
211
240
|
| 500 | `ServerError` | FinBrain internal error |
|
|
212
241
|
|
|
213
|
-
|
|
242
|
+
---
|
|
214
243
|
|
|
215
244
|
## 🔄 Versioning & release
|
|
216
245
|
|
|
217
|
-
-
|
|
218
|
-
|
|
219
|
-
- Version auto-generated from Git tags (setuptools-scm)
|
|
246
|
+
- Semantic Versioning (`MAJOR.MINOR.PATCH`)
|
|
220
247
|
|
|
221
|
-
|
|
222
|
-
|
|
248
|
+
- Version auto-generated from Git tags (setuptools-scm)
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git tag -a v0.2.0 -m "Add options.chain endpoint"
|
|
223
252
|
git push --tags # GitHub Actions builds & uploads to PyPI
|
|
224
253
|
```
|
|
225
254
|
|
|
226
|
-
|
|
255
|
+
---
|
|
227
256
|
|
|
228
257
|
## 🧑💻 Development
|
|
229
258
|
|
|
230
|
-
```
|
|
259
|
+
```bash
|
|
231
260
|
git clone https://github.com/finbrain-tech/finbrain-python
|
|
232
261
|
cd finbrain-python
|
|
233
262
|
python -m venv .venv && source .venv/bin/activate
|
|
@@ -241,35 +270,35 @@ pytest -q # unit tests (mocked)
|
|
|
241
270
|
|
|
242
271
|
Set `FINBRAIN_LIVE_KEY`, then run:
|
|
243
272
|
|
|
244
|
-
```
|
|
273
|
+
```bash
|
|
245
274
|
pytest -m integration
|
|
246
275
|
```
|
|
247
|
-
|
|
276
|
+
|
|
277
|
+
---
|
|
248
278
|
|
|
249
279
|
## 🤝 Contributing
|
|
250
280
|
|
|
251
|
-
1.
|
|
252
|
-
|
|
253
|
-
2. Add tests & run `ruff --fix`
|
|
254
|
-
|
|
255
|
-
3. Ensure `pytest` & CI pass
|
|
256
|
-
|
|
257
|
-
4. Open a PR — thanks!
|
|
258
|
-
|
|
281
|
+
1. Fork → create a feature branch
|
|
259
282
|
|
|
260
|
-
|
|
283
|
+
2. Add tests & run `ruff --fix`
|
|
284
|
+
|
|
285
|
+
3. Ensure `pytest` & CI pass
|
|
286
|
+
|
|
287
|
+
4. Open a PR — thanks!
|
|
288
|
+
|
|
289
|
+
---
|
|
261
290
|
|
|
262
291
|
## 🔒 Security
|
|
263
292
|
|
|
264
|
-
Please report vulnerabilities to
|
|
293
|
+
Please report vulnerabilities to **<info@finbrain.tech>**.
|
|
265
294
|
We respond within 48 hours.
|
|
266
295
|
|
|
267
|
-
|
|
296
|
+
---
|
|
268
297
|
|
|
269
298
|
## 📜 License
|
|
270
299
|
|
|
271
300
|
MIT — see [LICENSE](LICENSE).
|
|
272
301
|
|
|
273
|
-
|
|
302
|
+
---
|
|
274
303
|
|
|
275
304
|
© 2025 FinBrain Technologies — Built with ❤️ for the quant community.
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: finbrain-python
|
|
3
|
-
Version: 0.1.4
|
|
4
|
-
Summary: Official Python client for the FinBrain API
|
|
5
|
-
Author-email: Ahmet Salim Bilgin <ahmet@finbrain.tech>
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Requires-Python: >=3.9
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: requests>=2.31
|
|
11
|
-
Requires-Dist: typer[all]>=0.12
|
|
12
|
-
Requires-Dist: pandas>=2.2
|
|
13
|
-
Requires-Dist: plotly>=6.0
|
|
14
|
-
Requires-Dist: numpy>=1.22.4
|
|
15
|
-
Provides-Extra: dev
|
|
16
|
-
Requires-Dist: pytest; extra == "dev"
|
|
17
|
-
Requires-Dist: responses; extra == "dev"
|
|
18
|
-
Requires-Dist: build; extra == "dev"
|
|
19
|
-
Requires-Dist: twine; extra == "dev"
|
|
20
|
-
Requires-Dist: ruff; extra == "dev"
|
|
21
|
-
Dynamic: license-file
|
|
22
|
-
|
|
23
1
|
# FinBrain Python SDK <!-- omit in toc -->
|
|
24
2
|
|
|
25
3
|
[](https://pypi.org/project/finbrain-python/)
|
|
@@ -34,6 +12,7 @@ Fetch deep-learning price predictions, sentiment scores, insider trades, LinkedI
|
|
|
34
12
|
---
|
|
35
13
|
|
|
36
14
|
## ✨ Features
|
|
15
|
+
|
|
37
16
|
- One-line auth (`FinBrainClient(api_key="…")`)
|
|
38
17
|
- Complete endpoint coverage (predictions, sentiments, options, insider, etc.)
|
|
39
18
|
- Transparent retries & custom error hierarchy (`FinBrainError`)
|
|
@@ -45,12 +24,16 @@ Fetch deep-learning price predictions, sentiment scores, insider trades, LinkedI
|
|
|
45
24
|
---
|
|
46
25
|
|
|
47
26
|
## 🚀 Quick start
|
|
27
|
+
|
|
48
28
|
Install the SDK:
|
|
49
|
-
|
|
29
|
+
|
|
30
|
+
```bash
|
|
50
31
|
pip install finbrain-python
|
|
51
32
|
```
|
|
33
|
+
|
|
52
34
|
Create a client and fetch data:
|
|
53
|
-
|
|
35
|
+
|
|
36
|
+
```python
|
|
54
37
|
from finbrain import FinBrainClient
|
|
55
38
|
|
|
56
39
|
fb = FinBrainClient(api_key="YOUR_KEY") # create once, reuse below
|
|
@@ -103,6 +86,45 @@ fb.sentiments.ticker("S&P 500", "AMZN",
|
|
|
103
86
|
as_dataframe=True)
|
|
104
87
|
```
|
|
105
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
|
+
|
|
106
128
|
## 📈 Plotting
|
|
107
129
|
|
|
108
130
|
Plot helpers in a nutshell
|
|
@@ -111,7 +133,7 @@ Plot helpers in a nutshell
|
|
|
111
133
|
|
|
112
134
|
- `as_json=True` – skips display and returns the figure as a Plotly-JSON string, ready to embed elsewhere.
|
|
113
135
|
|
|
114
|
-
```
|
|
136
|
+
```python
|
|
115
137
|
# ---------- App Ratings Chart - Apple App Store or Google Play Store ----------
|
|
116
138
|
fb.plot.app_ratings("S&P 500", "AMZN",
|
|
117
139
|
store="app", # "play" for Google Play Store
|
|
@@ -120,15 +142,17 @@ fb.plot.app_ratings("S&P 500", "AMZN",
|
|
|
120
142
|
|
|
121
143
|
# ---------- LinkedIn Metrics Chart ----------
|
|
122
144
|
fb.plot.linkedin("S&P 500", "AMZN",
|
|
123
|
-
date_from="2025-01-01",
|
|
145
|
+
date_from="2025-01-01",
|
|
146
|
+
date_to="2025-06-30")
|
|
124
147
|
|
|
125
148
|
# ---------- Put-Call Ratio Chart ----------
|
|
126
149
|
fb.plot.options("S&P 500", "AMZN",
|
|
127
150
|
kind="put_call",
|
|
128
|
-
date_from="2025-01-01",
|
|
151
|
+
date_from="2025-01-01",
|
|
152
|
+
date_to="2025-06-30")
|
|
129
153
|
|
|
130
154
|
# ---------- Predictions Chart ----------
|
|
131
|
-
fb.plot.predictions("AMZN")
|
|
155
|
+
fb.plot.predictions("AMZN") # prediction_type="monthly" for monthly predictions
|
|
132
156
|
|
|
133
157
|
# ---------- Sentiments Chart ----------
|
|
134
158
|
fb.plot.sentiments("S&P 500", "AMZN",
|
|
@@ -145,33 +169,12 @@ To call the API you need an **API key**, obtained by purchasing a **FinBrain API
|
|
|
145
169
|
2. Copy the key from your dashboard.
|
|
146
170
|
3. Pass it once when you create the client:
|
|
147
171
|
|
|
148
|
-
```
|
|
172
|
+
```python
|
|
149
173
|
from finbrain import FinBrainClient
|
|
150
174
|
fb = FinBrainClient(api_key="YOUR_KEY")
|
|
151
175
|
```
|
|
152
176
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
import asyncio, os
|
|
157
|
-
from finbrain.aio import FinBrainAsyncClient async
|
|
158
|
-
def main():
|
|
159
|
-
async with FinBrainAsyncClient(api_key=os.getenv("FINBRAIN_API_KEY")) as fb:
|
|
160
|
-
data = await fb.sentiments.ticker("S&P 500", "AMZN")
|
|
161
|
-
print(list(data["sentimentAnalysis"].items())[:3])
|
|
162
|
-
|
|
163
|
-
asyncio.run(main())
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### CLI (currently under development)
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
export FINBRAIN_API_KEY=your_key
|
|
170
|
-
finbrain markets
|
|
171
|
-
finbrain predict AAPL --type daily
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
----------
|
|
177
|
+
---
|
|
175
178
|
|
|
176
179
|
## 📚 Supported endpoints
|
|
177
180
|
|
|
@@ -189,11 +192,11 @@ finbrain predict AAPL --type daily
|
|
|
189
192
|
| LinkedIn | `client.linkedin_data.ticker()` | `/linkedindata/{MARKET}/{TICKER}` |
|
|
190
193
|
| Options – Put/Call | `client.options.put_call()` | `/putcalldata/{MARKET}/{TICKER}` |
|
|
191
194
|
|
|
192
|
-
|
|
195
|
+
---
|
|
193
196
|
|
|
194
197
|
## 🛠️ Error-handling
|
|
195
198
|
|
|
196
|
-
```
|
|
199
|
+
```python
|
|
197
200
|
from finbrain.exceptions import BadRequest
|
|
198
201
|
try:
|
|
199
202
|
fb.predictions.ticker("MSFT", prediction_type="weekly")
|
|
@@ -210,24 +213,24 @@ except BadRequest as exc:
|
|
|
210
213
|
| 405 | `MethodNotAllowed` | HTTP method not supported on endpoint |
|
|
211
214
|
| 500 | `ServerError` | FinBrain internal error |
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
---
|
|
214
217
|
|
|
215
218
|
## 🔄 Versioning & release
|
|
216
219
|
|
|
217
|
-
-
|
|
218
|
-
|
|
219
|
-
- Version auto-generated from Git tags (setuptools-scm)
|
|
220
|
+
- Semantic Versioning (`MAJOR.MINOR.PATCH`)
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
- Version auto-generated from Git tags (setuptools-scm)
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
git tag -a v0.2.0 -m "Add options.chain endpoint"
|
|
223
226
|
git push --tags # GitHub Actions builds & uploads to PyPI
|
|
224
227
|
```
|
|
225
228
|
|
|
226
|
-
|
|
229
|
+
---
|
|
227
230
|
|
|
228
231
|
## 🧑💻 Development
|
|
229
232
|
|
|
230
|
-
```
|
|
233
|
+
```bash
|
|
231
234
|
git clone https://github.com/finbrain-tech/finbrain-python
|
|
232
235
|
cd finbrain-python
|
|
233
236
|
python -m venv .venv && source .venv/bin/activate
|
|
@@ -241,35 +244,35 @@ pytest -q # unit tests (mocked)
|
|
|
241
244
|
|
|
242
245
|
Set `FINBRAIN_LIVE_KEY`, then run:
|
|
243
246
|
|
|
244
|
-
```
|
|
247
|
+
```bash
|
|
245
248
|
pytest -m integration
|
|
246
249
|
```
|
|
247
|
-
|
|
250
|
+
|
|
251
|
+
---
|
|
248
252
|
|
|
249
253
|
## 🤝 Contributing
|
|
250
254
|
|
|
251
|
-
1.
|
|
252
|
-
|
|
253
|
-
2. Add tests & run `ruff --fix`
|
|
254
|
-
|
|
255
|
-
3. Ensure `pytest` & CI pass
|
|
256
|
-
|
|
257
|
-
4. Open a PR — thanks!
|
|
258
|
-
|
|
255
|
+
1. Fork → create a feature branch
|
|
259
256
|
|
|
260
|
-
|
|
257
|
+
2. Add tests & run `ruff --fix`
|
|
258
|
+
|
|
259
|
+
3. Ensure `pytest` & CI pass
|
|
260
|
+
|
|
261
|
+
4. Open a PR — thanks!
|
|
262
|
+
|
|
263
|
+
---
|
|
261
264
|
|
|
262
265
|
## 🔒 Security
|
|
263
266
|
|
|
264
|
-
Please report vulnerabilities to
|
|
267
|
+
Please report vulnerabilities to **<info@finbrain.tech>**.
|
|
265
268
|
We respond within 48 hours.
|
|
266
269
|
|
|
267
|
-
|
|
270
|
+
---
|
|
268
271
|
|
|
269
272
|
## 📜 License
|
|
270
273
|
|
|
271
274
|
MIT — see [LICENSE](LICENSE).
|
|
272
275
|
|
|
273
|
-
|
|
276
|
+
---
|
|
274
277
|
|
|
275
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
|
+
```
|