david-data 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.
- david_data-0.1.0/.github/workflows/ci.yml +28 -0
- david_data-0.1.0/.github/workflows/publish.yml +68 -0
- david_data-0.1.0/.gitignore +13 -0
- david_data-0.1.0/CHANGELOG.md +20 -0
- david_data-0.1.0/LICENSE +21 -0
- david_data-0.1.0/PKG-INFO +171 -0
- david_data-0.1.0/README.md +143 -0
- david_data-0.1.0/RELEASING.md +59 -0
- david_data-0.1.0/examples/quickstart.py +44 -0
- david_data-0.1.0/openapi-reference.json +6387 -0
- david_data-0.1.0/pyproject.toml +48 -0
- david_data-0.1.0/src/david_data/__init__.py +41 -0
- david_data-0.1.0/src/david_data/_http.py +172 -0
- david_data-0.1.0/src/david_data/_pandas.py +27 -0
- david_data-0.1.0/src/david_data/_version.py +1 -0
- david_data-0.1.0/src/david_data/client.py +125 -0
- david_data-0.1.0/src/david_data/errors.py +121 -0
- david_data-0.1.0/src/david_data/py.typed +0 -0
- david_data-0.1.0/src/david_data/resources/__init__.py +27 -0
- david_data-0.1.0/src/david_data/resources/base.py +62 -0
- david_data-0.1.0/src/david_data/resources/company.py +59 -0
- david_data-0.1.0/src/david_data/resources/documents.py +129 -0
- david_data-0.1.0/src/david_data/resources/estimates.py +132 -0
- david_data-0.1.0/src/david_data/resources/financials.py +248 -0
- david_data-0.1.0/src/david_data/resources/macro.py +66 -0
- david_data-0.1.0/src/david_data/resources/metadata.py +37 -0
- david_data-0.1.0/src/david_data/resources/ownership.py +153 -0
- david_data-0.1.0/src/david_data/resources/prices.py +79 -0
- david_data-0.1.0/src/david_data/resources/scenarios.py +78 -0
- david_data-0.1.0/tests/conftest.py +40 -0
- david_data-0.1.0/tests/test_client.py +182 -0
- david_data-0.1.0/tests/test_live_integration.py +67 -0
- david_data-0.1.0/tests/test_resources.py +131 -0
- david_data-0.1.0/tests/test_transport.py +110 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- name: Install
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
- name: Lint
|
|
26
|
+
run: ruff check src tests
|
|
27
|
+
- name: Test
|
|
28
|
+
run: pytest -q
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Publishes on a GitHub Release. Uses PyPI Trusted Publishing (OIDC) — no API
|
|
4
|
+
# token secret required. Configure the trusted publisher once on PyPI (see
|
|
5
|
+
# RELEASING.md), then cutting a release does the rest.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
inputs:
|
|
12
|
+
target:
|
|
13
|
+
description: "Where to publish"
|
|
14
|
+
default: testpypi
|
|
15
|
+
type: choice
|
|
16
|
+
options: [testpypi, pypi]
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
- name: Build sdist and wheel
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip build twine
|
|
29
|
+
python -m build
|
|
30
|
+
twine check dist/*
|
|
31
|
+
- uses: actions/upload-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: dist
|
|
34
|
+
path: dist/
|
|
35
|
+
|
|
36
|
+
publish-pypi:
|
|
37
|
+
needs: build
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
if: github.event_name == 'release' || inputs.target == 'pypi'
|
|
40
|
+
environment:
|
|
41
|
+
name: pypi
|
|
42
|
+
url: https://pypi.org/p/david-data
|
|
43
|
+
permissions:
|
|
44
|
+
id-token: write # required for trusted publishing
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/download-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: dist
|
|
49
|
+
path: dist/
|
|
50
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
51
|
+
|
|
52
|
+
publish-testpypi:
|
|
53
|
+
needs: build
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
|
|
56
|
+
environment:
|
|
57
|
+
name: testpypi
|
|
58
|
+
url: https://test.pypi.org/p/david-data
|
|
59
|
+
permissions:
|
|
60
|
+
id-token: write
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/download-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: dist
|
|
65
|
+
path: dist/
|
|
66
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
67
|
+
with:
|
|
68
|
+
repository-url: https://test.pypi.org/legacy/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `david-data` are documented here. This project follows
|
|
4
|
+
[Semantic Versioning](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [0.1.0] - 2026-06-24
|
|
7
|
+
|
|
8
|
+
Initial release.
|
|
9
|
+
|
|
10
|
+
- `DavidData` client over the David Data API (`https://api.davidhf.com`).
|
|
11
|
+
- Resource groups: `prices`, `financials`, `company`, `news`, `filings`,
|
|
12
|
+
`earnings`, `analyst`, `events`, `insiders`, `institutional`, `index_funds`,
|
|
13
|
+
`corporate_actions`, `macro`, `scenarios`, `metadata`.
|
|
14
|
+
- Data calls are keyed by `scenario_id` (a synthetic world). Set a default once
|
|
15
|
+
on the client or pass it per call; omitting it raises a clear error.
|
|
16
|
+
- FMP-style returns (parsed JSON with the response envelope unwrapped) and an
|
|
17
|
+
optional `to_df()` pandas helper (`pip install david-data[pandas]`).
|
|
18
|
+
- Typed exception hierarchy under `DavidDataError`; automatic retry of `429`
|
|
19
|
+
and transient `5xx` responses with exponential backoff (honours `Retry-After`).
|
|
20
|
+
- `dd.get()` / `dd.post()` escape hatches for any endpoint.
|
david_data-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Data
|
|
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,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: david-data
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python client for the David Data financial-data API (api.davidhf.com).
|
|
5
|
+
Project-URL: Homepage, https://davidhf.com
|
|
6
|
+
Project-URL: Documentation, https://api.davidhf.com/docs
|
|
7
|
+
Project-URL: Source, https://github.com/davidhf/david-data-python
|
|
8
|
+
Author-email: David Data <investors@davidhf.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: api,david-data,finance,fundamentals,market-data,stocks
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: httpx>=0.24
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pandas>=1.5; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
25
|
+
Provides-Extra: pandas
|
|
26
|
+
Requires-Dist: pandas>=1.5; extra == 'pandas'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# David Data — Python SDK
|
|
30
|
+
|
|
31
|
+
Official Python client for the [David Data](https://davidhf.com) financial-data
|
|
32
|
+
API (`https://api.davidhf.com`). One consistent interface for **real** market
|
|
33
|
+
data and **synthetic** scenarios — prices, fundamentals, filings, news,
|
|
34
|
+
earnings, analyst & insider data, 13F holdings, and macro series.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install david-data # core (httpx only)
|
|
38
|
+
pip install david-data[pandas] # + DataFrame helpers
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
Every data call is keyed by a **`scenario_id`** — a synthetic world. Pick one,
|
|
44
|
+
then pull data from it.
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from david_data import DavidData
|
|
48
|
+
|
|
49
|
+
dd = DavidData(api_key="sk_...") # or set DAVID_DATA_API_KEY
|
|
50
|
+
|
|
51
|
+
# 1. Find a scenario
|
|
52
|
+
scenario = dd.scenarios.list(limit=1)[0]
|
|
53
|
+
sid = scenario["id"]
|
|
54
|
+
print(scenario["name"])
|
|
55
|
+
|
|
56
|
+
# 2. Pull data from it
|
|
57
|
+
bars = dd.prices.get("AAPL", scenario_id=sid, start_date="2024-01-01")
|
|
58
|
+
income = dd.financials.income_statements("AAPL", scenario_id=sid, period="quarterly", limit=5)
|
|
59
|
+
news = dd.news.list(ticker="AAPL", scenario_id=sid, limit=10)
|
|
60
|
+
|
|
61
|
+
print(bars[0]) # {'ticker': 'AAPL', 'open': ..., 'close': ..., 'volume': ...}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Repeating `scenario_id=` on every call gets old — set it once on the client and
|
|
65
|
+
omit it thereafter:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
dd = DavidData(api_key="sk_...", scenario_id=sid)
|
|
69
|
+
dd.prices.get("AAPL") # uses the client default
|
|
70
|
+
dd.prices.get("AAPL", scenario_id="other-world") # override per call
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Calling a data endpoint with no `scenario_id` (and no client default) raises a
|
|
74
|
+
clear error instead of guessing.
|
|
75
|
+
|
|
76
|
+
Set the key once via the environment and you can skip the argument entirely:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
export DAVID_DATA_API_KEY="sk_..."
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from david_data import DavidData
|
|
84
|
+
dd = DavidData()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Returns
|
|
88
|
+
|
|
89
|
+
Methods return parsed JSON — a `list` of record dicts for collection endpoints,
|
|
90
|
+
a `dict` for single-object endpoints — exactly like the underlying API, with the
|
|
91
|
+
envelope unwrapped for you (`dd.prices.get(...)` gives you the list of bars
|
|
92
|
+
directly). Convert any result to a DataFrame:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from david_data import to_df
|
|
96
|
+
df = to_df(dd.prices.get("AAPL", start_date="2024-01-01"))
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Scenarios
|
|
100
|
+
|
|
101
|
+
A scenario is a self-contained synthetic world with its own universe of
|
|
102
|
+
companies, prices, fundamentals, filings, and events. Browse what's available,
|
|
103
|
+
or generate new ones:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
for s in dd.scenarios.list(limit=10):
|
|
107
|
+
print(s["id"], "-", s["name"])
|
|
108
|
+
|
|
109
|
+
# Inspect one
|
|
110
|
+
dd.scenarios.get(sid)
|
|
111
|
+
dd.scenarios.manifest(sid) # tickers, date range, coverage
|
|
112
|
+
|
|
113
|
+
# Generate your own
|
|
114
|
+
created = dd.scenarios.create(start_date="2024-01-01", ticker_count=25)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## What you can pull
|
|
118
|
+
|
|
119
|
+
| Group | Examples |
|
|
120
|
+
|-------|----------|
|
|
121
|
+
| `dd.prices` | `get`, `snapshot`, `market_snapshot`, `tickers` |
|
|
122
|
+
| `dd.financials` | `income_statements`, `balance_sheets`, `cash_flow_statements`, `metrics`, `segments`, `as_reported`, `kpi_metrics`, `screener`, `line_items` |
|
|
123
|
+
| `dd.company` | `list`, `facts`, `tickers`, `ciks` |
|
|
124
|
+
| `dd.news` / `dd.filings` | `list`, `get` / `list`, `items`, `types` |
|
|
125
|
+
| `dd.earnings` / `dd.analyst` | `list`, `calendar` / `estimates`, `notes` |
|
|
126
|
+
| `dd.insiders` / `dd.institutional` | `trades`, `transactions` / `holdings`, `investors` |
|
|
127
|
+
| `dd.index_funds` / `dd.corporate_actions` | `list` |
|
|
128
|
+
| `dd.macro` | `series`, `interest_rates`, `banks` |
|
|
129
|
+
| `dd.events` | `timeline` |
|
|
130
|
+
| `dd.scenarios` | `list`, `get`, `manifest`, `create`, `bulk_generate`, `generate_library` |
|
|
131
|
+
| `dd.metadata` | `sectors`, `scenario_themes`, `scale_presets`, … |
|
|
132
|
+
|
|
133
|
+
Dates accept either ISO strings (`"2024-01-01"`) or `datetime.date` objects.
|
|
134
|
+
|
|
135
|
+
## Errors & retries
|
|
136
|
+
|
|
137
|
+
All exceptions subclass `DavidDataError`. HTTP failures map to specific types:
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from david_data import DavidData, NotFoundError, RateLimitError
|
|
141
|
+
|
|
142
|
+
dd = DavidData()
|
|
143
|
+
try:
|
|
144
|
+
dd.prices.get("AAPL")
|
|
145
|
+
except RateLimitError as e:
|
|
146
|
+
print("slow down; retry after", e.retry_after)
|
|
147
|
+
except NotFoundError:
|
|
148
|
+
print("no such ticker / scenario")
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The client automatically retries `429` and transient `5xx` responses with
|
|
152
|
+
exponential backoff (honouring `Retry-After`); tune with `max_retries=`.
|
|
153
|
+
|
|
154
|
+
## Escape hatch
|
|
155
|
+
|
|
156
|
+
Any endpoint not yet wrapped is reachable directly:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
dd.get("/metadata/institutional-readiness")
|
|
160
|
+
dd.post("/financials/search/screener", json={"scenario_id": "real", "filters": [...]})
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Anything else
|
|
164
|
+
|
|
165
|
+
- `with DavidData() as dd: ...` closes the connection pool on exit.
|
|
166
|
+
- Bring your own `httpx.Client` via `http_client=` for proxies/custom transport.
|
|
167
|
+
- Full endpoint reference: <https://api.davidhf.com/docs>
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
MIT
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# David Data — Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python client for the [David Data](https://davidhf.com) financial-data
|
|
4
|
+
API (`https://api.davidhf.com`). One consistent interface for **real** market
|
|
5
|
+
data and **synthetic** scenarios — prices, fundamentals, filings, news,
|
|
6
|
+
earnings, analyst & insider data, 13F holdings, and macro series.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install david-data # core (httpx only)
|
|
10
|
+
pip install david-data[pandas] # + DataFrame helpers
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
Every data call is keyed by a **`scenario_id`** — a synthetic world. Pick one,
|
|
16
|
+
then pull data from it.
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from david_data import DavidData
|
|
20
|
+
|
|
21
|
+
dd = DavidData(api_key="sk_...") # or set DAVID_DATA_API_KEY
|
|
22
|
+
|
|
23
|
+
# 1. Find a scenario
|
|
24
|
+
scenario = dd.scenarios.list(limit=1)[0]
|
|
25
|
+
sid = scenario["id"]
|
|
26
|
+
print(scenario["name"])
|
|
27
|
+
|
|
28
|
+
# 2. Pull data from it
|
|
29
|
+
bars = dd.prices.get("AAPL", scenario_id=sid, start_date="2024-01-01")
|
|
30
|
+
income = dd.financials.income_statements("AAPL", scenario_id=sid, period="quarterly", limit=5)
|
|
31
|
+
news = dd.news.list(ticker="AAPL", scenario_id=sid, limit=10)
|
|
32
|
+
|
|
33
|
+
print(bars[0]) # {'ticker': 'AAPL', 'open': ..., 'close': ..., 'volume': ...}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Repeating `scenario_id=` on every call gets old — set it once on the client and
|
|
37
|
+
omit it thereafter:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
dd = DavidData(api_key="sk_...", scenario_id=sid)
|
|
41
|
+
dd.prices.get("AAPL") # uses the client default
|
|
42
|
+
dd.prices.get("AAPL", scenario_id="other-world") # override per call
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Calling a data endpoint with no `scenario_id` (and no client default) raises a
|
|
46
|
+
clear error instead of guessing.
|
|
47
|
+
|
|
48
|
+
Set the key once via the environment and you can skip the argument entirely:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
export DAVID_DATA_API_KEY="sk_..."
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from david_data import DavidData
|
|
56
|
+
dd = DavidData()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Returns
|
|
60
|
+
|
|
61
|
+
Methods return parsed JSON — a `list` of record dicts for collection endpoints,
|
|
62
|
+
a `dict` for single-object endpoints — exactly like the underlying API, with the
|
|
63
|
+
envelope unwrapped for you (`dd.prices.get(...)` gives you the list of bars
|
|
64
|
+
directly). Convert any result to a DataFrame:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from david_data import to_df
|
|
68
|
+
df = to_df(dd.prices.get("AAPL", start_date="2024-01-01"))
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Scenarios
|
|
72
|
+
|
|
73
|
+
A scenario is a self-contained synthetic world with its own universe of
|
|
74
|
+
companies, prices, fundamentals, filings, and events. Browse what's available,
|
|
75
|
+
or generate new ones:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
for s in dd.scenarios.list(limit=10):
|
|
79
|
+
print(s["id"], "-", s["name"])
|
|
80
|
+
|
|
81
|
+
# Inspect one
|
|
82
|
+
dd.scenarios.get(sid)
|
|
83
|
+
dd.scenarios.manifest(sid) # tickers, date range, coverage
|
|
84
|
+
|
|
85
|
+
# Generate your own
|
|
86
|
+
created = dd.scenarios.create(start_date="2024-01-01", ticker_count=25)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## What you can pull
|
|
90
|
+
|
|
91
|
+
| Group | Examples |
|
|
92
|
+
|-------|----------|
|
|
93
|
+
| `dd.prices` | `get`, `snapshot`, `market_snapshot`, `tickers` |
|
|
94
|
+
| `dd.financials` | `income_statements`, `balance_sheets`, `cash_flow_statements`, `metrics`, `segments`, `as_reported`, `kpi_metrics`, `screener`, `line_items` |
|
|
95
|
+
| `dd.company` | `list`, `facts`, `tickers`, `ciks` |
|
|
96
|
+
| `dd.news` / `dd.filings` | `list`, `get` / `list`, `items`, `types` |
|
|
97
|
+
| `dd.earnings` / `dd.analyst` | `list`, `calendar` / `estimates`, `notes` |
|
|
98
|
+
| `dd.insiders` / `dd.institutional` | `trades`, `transactions` / `holdings`, `investors` |
|
|
99
|
+
| `dd.index_funds` / `dd.corporate_actions` | `list` |
|
|
100
|
+
| `dd.macro` | `series`, `interest_rates`, `banks` |
|
|
101
|
+
| `dd.events` | `timeline` |
|
|
102
|
+
| `dd.scenarios` | `list`, `get`, `manifest`, `create`, `bulk_generate`, `generate_library` |
|
|
103
|
+
| `dd.metadata` | `sectors`, `scenario_themes`, `scale_presets`, … |
|
|
104
|
+
|
|
105
|
+
Dates accept either ISO strings (`"2024-01-01"`) or `datetime.date` objects.
|
|
106
|
+
|
|
107
|
+
## Errors & retries
|
|
108
|
+
|
|
109
|
+
All exceptions subclass `DavidDataError`. HTTP failures map to specific types:
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from david_data import DavidData, NotFoundError, RateLimitError
|
|
113
|
+
|
|
114
|
+
dd = DavidData()
|
|
115
|
+
try:
|
|
116
|
+
dd.prices.get("AAPL")
|
|
117
|
+
except RateLimitError as e:
|
|
118
|
+
print("slow down; retry after", e.retry_after)
|
|
119
|
+
except NotFoundError:
|
|
120
|
+
print("no such ticker / scenario")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The client automatically retries `429` and transient `5xx` responses with
|
|
124
|
+
exponential backoff (honouring `Retry-After`); tune with `max_retries=`.
|
|
125
|
+
|
|
126
|
+
## Escape hatch
|
|
127
|
+
|
|
128
|
+
Any endpoint not yet wrapped is reachable directly:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
dd.get("/metadata/institutional-readiness")
|
|
132
|
+
dd.post("/financials/search/screener", json={"scenario_id": "real", "filters": [...]})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Anything else
|
|
136
|
+
|
|
137
|
+
- `with DavidData() as dd: ...` closes the connection pool on exit.
|
|
138
|
+
- Bring your own `httpx.Client` via `http_client=` for proxies/custom transport.
|
|
139
|
+
- Full endpoint reference: <https://api.davidhf.com/docs>
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Releasing `david-data` to PyPI
|
|
2
|
+
|
|
3
|
+
The repo publishes with **PyPI Trusted Publishing** (OIDC). No long-lived API
|
|
4
|
+
token is stored anywhere — GitHub Actions mints a short-lived token at publish
|
|
5
|
+
time. You configure the trust relationship once.
|
|
6
|
+
|
|
7
|
+
## One-time setup
|
|
8
|
+
|
|
9
|
+
### 1. Create the PyPI trusted publisher
|
|
10
|
+
|
|
11
|
+
You can do this *before* the project exists on PyPI ("pending publisher").
|
|
12
|
+
|
|
13
|
+
1. Log in to <https://pypi.org> → your account → **Publishing**.
|
|
14
|
+
2. Under "Add a new pending publisher", enter:
|
|
15
|
+
- **PyPI Project Name:** `david-data`
|
|
16
|
+
- **Owner:** `David-Hedgefund`
|
|
17
|
+
- **Repository name:** `david-data-python`
|
|
18
|
+
- **Workflow name:** `publish.yml`
|
|
19
|
+
- **Environment name:** `pypi`
|
|
20
|
+
3. Save. Repeat on <https://test.pypi.org> with environment `testpypi` if you
|
|
21
|
+
want a staging target.
|
|
22
|
+
|
|
23
|
+
### 2. Create the GitHub environments
|
|
24
|
+
|
|
25
|
+
In the GitHub repo → **Settings → Environments**, create environments named
|
|
26
|
+
`pypi` (and optionally `testpypi`). No secrets needed. Optionally add required
|
|
27
|
+
reviewers so a release waits for manual approval.
|
|
28
|
+
|
|
29
|
+
## Cutting a release
|
|
30
|
+
|
|
31
|
+
1. Bump the version in **two** places (keep them in sync):
|
|
32
|
+
- `pyproject.toml` → `[project] version`
|
|
33
|
+
- `src/david_data/_version.py` → `__version__`
|
|
34
|
+
2. Update `CHANGELOG.md`.
|
|
35
|
+
3. Commit and tag:
|
|
36
|
+
```bash
|
|
37
|
+
git commit -am "Release v0.1.1"
|
|
38
|
+
git tag v0.1.1
|
|
39
|
+
git push && git push --tags
|
|
40
|
+
```
|
|
41
|
+
4. On GitHub → **Releases → Draft a new release**, choose the tag, publish.
|
|
42
|
+
5. The `publish.yml` workflow builds, runs `twine check`, and publishes to PyPI.
|
|
43
|
+
|
|
44
|
+
## Dry run to TestPyPI
|
|
45
|
+
|
|
46
|
+
GitHub → **Actions → Publish to PyPI → Run workflow**, choose `testpypi`. Then:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install --index-url https://test.pypi.org/simple/ \
|
|
50
|
+
--extra-index-url https://pypi.org/simple/ david-data
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Build locally
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python -m pip install build twine
|
|
57
|
+
python -m build # -> dist/david_data-*.whl and *.tar.gz
|
|
58
|
+
twine check dist/*
|
|
59
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Minimal end-to-end example.
|
|
2
|
+
|
|
3
|
+
Run against the live API:
|
|
4
|
+
export DAVID_DATA_API_KEY="sk_..."
|
|
5
|
+
python examples/quickstart.py
|
|
6
|
+
|
|
7
|
+
Or against a local dev server:
|
|
8
|
+
export DAVID_DATA_API_KEY="dev_key_123"
|
|
9
|
+
export DAVID_DATA_BASE_URL="http://localhost:8099"
|
|
10
|
+
python examples/quickstart.py
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from david_data import DavidData, to_df
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> None:
|
|
17
|
+
with DavidData() as dd:
|
|
18
|
+
print("health:", dd.health())
|
|
19
|
+
|
|
20
|
+
# Every data call is keyed by a scenario_id — grab one to work with.
|
|
21
|
+
scenarios = dd.scenarios.list(limit=1)
|
|
22
|
+
if not scenarios:
|
|
23
|
+
print("no scenarios available on this server")
|
|
24
|
+
return
|
|
25
|
+
sid = scenarios[0]["id"]
|
|
26
|
+
print("\nusing scenario:", sid, "-", scenarios[0].get("name"))
|
|
27
|
+
|
|
28
|
+
ticker = (dd.prices.tickers(scenario_id=sid) or ["AAPL"])[0]
|
|
29
|
+
|
|
30
|
+
bars = dd.prices.get(ticker, scenario_id=sid, limit=5)
|
|
31
|
+
print(f"\n{len(bars)} price bars for {ticker}; first:")
|
|
32
|
+
print(bars[0] if bars else "(none)")
|
|
33
|
+
|
|
34
|
+
income = dd.financials.income_statements(ticker, scenario_id=sid, period="quarterly", limit=3)
|
|
35
|
+
print("\nincome statements as a DataFrame:")
|
|
36
|
+
print(to_df(income))
|
|
37
|
+
|
|
38
|
+
print("\nlatest news headlines:")
|
|
39
|
+
for article in dd.news.list(ticker=ticker, scenario_id=sid, limit=3):
|
|
40
|
+
print(" -", article.get("title") or article.get("headline"))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
main()
|