david-data 0.1.0__py3-none-any.whl
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/__init__.py +41 -0
- david_data/_http.py +172 -0
- david_data/_pandas.py +27 -0
- david_data/_version.py +1 -0
- david_data/client.py +125 -0
- david_data/errors.py +121 -0
- david_data/py.typed +0 -0
- david_data/resources/__init__.py +27 -0
- david_data/resources/base.py +62 -0
- david_data/resources/company.py +59 -0
- david_data/resources/documents.py +129 -0
- david_data/resources/estimates.py +132 -0
- david_data/resources/financials.py +248 -0
- david_data/resources/macro.py +66 -0
- david_data/resources/metadata.py +37 -0
- david_data/resources/ownership.py +153 -0
- david_data/resources/prices.py +79 -0
- david_data/resources/scenarios.py +78 -0
- david_data-0.1.0.dist-info/METADATA +171 -0
- david_data-0.1.0.dist-info/RECORD +22 -0
- david_data-0.1.0.dist-info/WHEEL +4 -0
- david_data-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, List, Optional
|
|
4
|
+
|
|
5
|
+
from .base import Resource
|
|
6
|
+
|
|
7
|
+
DateLike = Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Insiders(Resource):
|
|
11
|
+
"""Insider trading: Form-4 style trades and aggregated transactions."""
|
|
12
|
+
|
|
13
|
+
def trades(
|
|
14
|
+
self,
|
|
15
|
+
*,
|
|
16
|
+
scenario_id: Optional[str] = None,
|
|
17
|
+
ticker: Optional[str] = None,
|
|
18
|
+
name: Optional[str] = None,
|
|
19
|
+
transaction_type: Optional[str] = None,
|
|
20
|
+
filing_date_gte: Optional[DateLike] = None,
|
|
21
|
+
filing_date_lte: Optional[DateLike] = None,
|
|
22
|
+
limit: int = 50,
|
|
23
|
+
offset: int = 0,
|
|
24
|
+
) -> List[dict]:
|
|
25
|
+
return self._get(
|
|
26
|
+
"/insider-trades",
|
|
27
|
+
params={
|
|
28
|
+
"scenario_id": self._scenario(scenario_id),
|
|
29
|
+
"ticker": ticker,
|
|
30
|
+
"name": name,
|
|
31
|
+
"transaction_type": transaction_type,
|
|
32
|
+
"filing_date_gte": filing_date_gte,
|
|
33
|
+
"filing_date_lte": filing_date_lte,
|
|
34
|
+
"limit": limit,
|
|
35
|
+
"offset": offset,
|
|
36
|
+
},
|
|
37
|
+
unwrap="insider_trades",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def transactions(
|
|
41
|
+
self,
|
|
42
|
+
*,
|
|
43
|
+
scenario_id: Optional[str] = None,
|
|
44
|
+
ticker: Optional[str] = None,
|
|
45
|
+
limit: int = 50,
|
|
46
|
+
offset: int = 0,
|
|
47
|
+
) -> List[dict]:
|
|
48
|
+
return self._get(
|
|
49
|
+
"/insider-transactions",
|
|
50
|
+
params={
|
|
51
|
+
"scenario_id": self._scenario(scenario_id),
|
|
52
|
+
"ticker": ticker,
|
|
53
|
+
"limit": limit,
|
|
54
|
+
"offset": offset,
|
|
55
|
+
},
|
|
56
|
+
unwrap="insider_transactions",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class Institutional(Resource):
|
|
61
|
+
"""13F institutional holdings and the investor directory."""
|
|
62
|
+
|
|
63
|
+
def holdings(
|
|
64
|
+
self,
|
|
65
|
+
*,
|
|
66
|
+
scenario_id: Optional[str] = None,
|
|
67
|
+
ticker: Optional[str] = None,
|
|
68
|
+
filer_cik: Optional[str] = None,
|
|
69
|
+
report_period_gte: Optional[DateLike] = None,
|
|
70
|
+
report_period_lte: Optional[DateLike] = None,
|
|
71
|
+
limit: int = 50,
|
|
72
|
+
offset: int = 0,
|
|
73
|
+
) -> List[dict]:
|
|
74
|
+
return self._get(
|
|
75
|
+
"/institutional-holdings",
|
|
76
|
+
params={
|
|
77
|
+
"scenario_id": self._scenario(scenario_id),
|
|
78
|
+
"ticker": ticker,
|
|
79
|
+
"filer_cik": filer_cik,
|
|
80
|
+
"report_period_gte": report_period_gte,
|
|
81
|
+
"report_period_lte": report_period_lte,
|
|
82
|
+
"limit": limit,
|
|
83
|
+
"offset": offset,
|
|
84
|
+
},
|
|
85
|
+
unwrap="institutional_holdings",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def investors(self, *, scenario_id: Optional[str] = None, name: Optional[str] = None) -> Any:
|
|
89
|
+
return self._get(
|
|
90
|
+
"/institutional-holdings/investors",
|
|
91
|
+
params={"scenario_id": self._scenario(scenario_id), "name": name},
|
|
92
|
+
unwrap="investors",
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def tickers(self, *, scenario_id: Optional[str] = None) -> List[str]:
|
|
96
|
+
return self._get(
|
|
97
|
+
"/institutional-holdings/tickers",
|
|
98
|
+
params={"scenario_id": self._scenario(scenario_id)},
|
|
99
|
+
unwrap="tickers",
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class IndexFunds(Resource):
|
|
104
|
+
"""Index-fund constituents and the reverse holding lookup."""
|
|
105
|
+
|
|
106
|
+
def list(
|
|
107
|
+
self,
|
|
108
|
+
*,
|
|
109
|
+
scenario_id: Optional[str] = None,
|
|
110
|
+
ticker: Optional[str] = None,
|
|
111
|
+
holding: Optional[str] = None,
|
|
112
|
+
as_of: Optional[DateLike] = None,
|
|
113
|
+
limit: int = 50,
|
|
114
|
+
offset: int = 0,
|
|
115
|
+
) -> Any:
|
|
116
|
+
return self._get(
|
|
117
|
+
"/index-funds",
|
|
118
|
+
params={
|
|
119
|
+
"scenario_id": self._scenario(scenario_id),
|
|
120
|
+
"ticker": ticker,
|
|
121
|
+
"holding": holding,
|
|
122
|
+
"as_of": as_of,
|
|
123
|
+
"limit": limit,
|
|
124
|
+
"offset": offset,
|
|
125
|
+
},
|
|
126
|
+
unwrap="index_funds",
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
def tickers(self) -> List[str]:
|
|
130
|
+
return self._get("/index-funds/tickers", unwrap="tickers")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class CorporateActions(Resource):
|
|
134
|
+
"""Splits, dividends, and other corporate actions."""
|
|
135
|
+
|
|
136
|
+
def list(
|
|
137
|
+
self,
|
|
138
|
+
*,
|
|
139
|
+
scenario_id: Optional[str] = None,
|
|
140
|
+
ticker: Optional[str] = None,
|
|
141
|
+
limit: int = 50,
|
|
142
|
+
offset: int = 0,
|
|
143
|
+
) -> List[dict]:
|
|
144
|
+
return self._get(
|
|
145
|
+
"/corporate-actions",
|
|
146
|
+
params={
|
|
147
|
+
"scenario_id": self._scenario(scenario_id),
|
|
148
|
+
"ticker": ticker,
|
|
149
|
+
"limit": limit,
|
|
150
|
+
"offset": offset,
|
|
151
|
+
},
|
|
152
|
+
unwrap="corporate_actions",
|
|
153
|
+
)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, List, Optional
|
|
4
|
+
|
|
5
|
+
from .base import Resource
|
|
6
|
+
|
|
7
|
+
DateLike = Any # str ("YYYY-MM-DD") or datetime.date
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Prices(Resource):
|
|
11
|
+
"""Daily OHLCV price history, point-in-time snapshots, and market-wide views."""
|
|
12
|
+
|
|
13
|
+
def get(
|
|
14
|
+
self,
|
|
15
|
+
ticker: str,
|
|
16
|
+
*,
|
|
17
|
+
scenario_id: Optional[str] = None,
|
|
18
|
+
interval: str = "day",
|
|
19
|
+
start_date: Optional[DateLike] = None,
|
|
20
|
+
end_date: Optional[DateLike] = None,
|
|
21
|
+
include_components: bool = False,
|
|
22
|
+
limit: int = 1000,
|
|
23
|
+
offset: int = 0,
|
|
24
|
+
) -> List[dict]:
|
|
25
|
+
"""Return a list of OHLCV bars for ``ticker``.
|
|
26
|
+
|
|
27
|
+
``include_components=True`` adds the synthetic return-decomposition fields.
|
|
28
|
+
For real data (``scenario_id="real"``) intraday intervals such as
|
|
29
|
+
``"minute"``, ``"5minute"`` and ``"hour"`` are also accepted.
|
|
30
|
+
"""
|
|
31
|
+
return self._get(
|
|
32
|
+
"/prices",
|
|
33
|
+
params={
|
|
34
|
+
"scenario_id": self._scenario(scenario_id),
|
|
35
|
+
"ticker": ticker,
|
|
36
|
+
"interval": interval,
|
|
37
|
+
"start_date": start_date,
|
|
38
|
+
"end_date": end_date,
|
|
39
|
+
"include_components": include_components,
|
|
40
|
+
"limit": limit,
|
|
41
|
+
"offset": offset,
|
|
42
|
+
},
|
|
43
|
+
unwrap="prices",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def snapshot(self, ticker: str, *, as_of: DateLike, scenario_id: Optional[str] = None) -> dict:
|
|
47
|
+
"""Return the single price bar in effect for ``ticker`` on ``as_of``."""
|
|
48
|
+
return self._get(
|
|
49
|
+
"/prices/snapshot",
|
|
50
|
+
params={"scenario_id": self._scenario(scenario_id), "ticker": ticker, "as_of": as_of},
|
|
51
|
+
unwrap="snapshot",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def market_snapshot(
|
|
55
|
+
self,
|
|
56
|
+
*,
|
|
57
|
+
as_of: Optional[DateLike] = None,
|
|
58
|
+
scenario_id: Optional[str] = None,
|
|
59
|
+
limit: int = 500,
|
|
60
|
+
offset: int = 0,
|
|
61
|
+
) -> dict:
|
|
62
|
+
"""Return a cross-section of the latest prices across the whole universe."""
|
|
63
|
+
return self._get(
|
|
64
|
+
"/prices/snapshot/market",
|
|
65
|
+
params={
|
|
66
|
+
"scenario_id": self._scenario(scenario_id),
|
|
67
|
+
"as_of": as_of,
|
|
68
|
+
"limit": limit,
|
|
69
|
+
"offset": offset,
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def tickers(self, *, scenario_id: Optional[str] = None) -> List[str]:
|
|
74
|
+
"""List every ticker with price coverage in the scenario."""
|
|
75
|
+
return self._get(
|
|
76
|
+
"/prices/tickers",
|
|
77
|
+
params={"scenario_id": self._scenario(scenario_id)},
|
|
78
|
+
unwrap="tickers",
|
|
79
|
+
)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, List, Optional
|
|
4
|
+
|
|
5
|
+
from .base import Resource
|
|
6
|
+
|
|
7
|
+
DateLike = Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Scenarios(Resource):
|
|
11
|
+
"""Discover and generate scenarios (synthetic worlds).
|
|
12
|
+
|
|
13
|
+
Every data call takes a ``scenario_id``. List the available worlds here, or
|
|
14
|
+
generate new ones on demand, then pass the id to the other resource groups.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def list(
|
|
18
|
+
self,
|
|
19
|
+
*,
|
|
20
|
+
status: Optional[str] = None,
|
|
21
|
+
path_mode: Optional[str] = None,
|
|
22
|
+
min_ticker_count: Optional[int] = None,
|
|
23
|
+
max_scenario_day_count: Optional[int] = None,
|
|
24
|
+
healthy_only: bool = False,
|
|
25
|
+
limit: int = 50,
|
|
26
|
+
offset: int = 0,
|
|
27
|
+
) -> List[dict]:
|
|
28
|
+
return self._get(
|
|
29
|
+
"/scenarios",
|
|
30
|
+
params={
|
|
31
|
+
"status": status,
|
|
32
|
+
"path_mode": path_mode,
|
|
33
|
+
"min_ticker_count": min_ticker_count,
|
|
34
|
+
"max_scenario_day_count": max_scenario_day_count,
|
|
35
|
+
"healthy_only": healthy_only,
|
|
36
|
+
"limit": limit,
|
|
37
|
+
"offset": offset,
|
|
38
|
+
},
|
|
39
|
+
unwrap="scenarios",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def get(self, scenario_id: str) -> dict:
|
|
43
|
+
return self._get(f"/scenarios/{scenario_id}", unwrap="scenario")
|
|
44
|
+
|
|
45
|
+
def manifest(self, scenario_id: str) -> dict:
|
|
46
|
+
return self._get(f"/scenarios/{scenario_id}/manifest", unwrap="manifest")
|
|
47
|
+
|
|
48
|
+
def validation(self, scenario_id: str) -> dict:
|
|
49
|
+
return self._get(f"/scenarios/{scenario_id}/validation", unwrap="validation_report")
|
|
50
|
+
|
|
51
|
+
def dataset_quality(
|
|
52
|
+
self,
|
|
53
|
+
scenario_id: str,
|
|
54
|
+
*,
|
|
55
|
+
ticker: Optional[str] = None,
|
|
56
|
+
sample_limit: int = 5,
|
|
57
|
+
offset: int = 0,
|
|
58
|
+
) -> dict:
|
|
59
|
+
return self._get(
|
|
60
|
+
f"/scenarios/{scenario_id}/dataset-quality",
|
|
61
|
+
params={"ticker": ticker, "sample_limit": sample_limit, "offset": offset},
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# -- generation -------------------------------------------------------
|
|
65
|
+
def create(self, *, start_date: DateLike, **options: Any) -> dict:
|
|
66
|
+
"""Create a single scenario. See the API docs for the full option set
|
|
67
|
+
(``ticker_count``, ``scenario_theme``, ``path_mode``, ``seed``, …)."""
|
|
68
|
+
return self._post("/scenarios", json={"start_date": start_date, **options})
|
|
69
|
+
|
|
70
|
+
def bulk_generate(self, *, start_date: DateLike, count: int = 1, **options: Any) -> dict:
|
|
71
|
+
return self._post(
|
|
72
|
+
"/scenarios/bulk", json={"start_date": start_date, "count": count, **options}
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def generate_library(self, *, start_date: DateLike, count: int = 24, **options: Any) -> dict:
|
|
76
|
+
return self._post(
|
|
77
|
+
"/scenarios/library", json={"start_date": start_date, "count": count, **options}
|
|
78
|
+
)
|
|
@@ -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,22 @@
|
|
|
1
|
+
david_data/__init__.py,sha256=cZsNzJYDRIiqqUdeZICu0lK_MmMkg-76HH4ISdOTXjE,912
|
|
2
|
+
david_data/_http.py,sha256=OmkuIhw0pBe3t2vEe5gSc_iAa3B9Vod40UK-oHYsy18,5457
|
|
3
|
+
david_data/_pandas.py,sha256=BMVSKSmeJSRK9NzdRYfbHoZ19JD8U7SR1_VAafW5FnU,1030
|
|
4
|
+
david_data/_version.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
|
|
5
|
+
david_data/client.py,sha256=_s4h9bQumfJAm903-l3GyxJ71aYVH4HdmNpF_Om71jo,4784
|
|
6
|
+
david_data/errors.py,sha256=ccMpQ2TtTnZf6ih2gkDXgOJE0MEAmJWsboFxSRiD32E,3654
|
|
7
|
+
david_data/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
david_data/resources/__init__.py,sha256=QKO9OzJN6_psVX4W-qLjm_L8o9AG5uZCyAPVeO0JCXg,602
|
|
9
|
+
david_data/resources/base.py,sha256=WdAP9OVr7-NGZ7659SHNzP1W4qV7pO5_X_22QYhMmDU,2029
|
|
10
|
+
david_data/resources/company.py,sha256=v9cB3OM7V-Ds7Frwma0Cs4VMbkhoefC3MXsRYOSeA08,1713
|
|
11
|
+
david_data/resources/documents.py,sha256=BKE5mcxuP2ijWKPnmgG9mCvLJb4xnXGI-aIxPj3iQN8,3988
|
|
12
|
+
david_data/resources/estimates.py,sha256=VMZTyoo-1j65o4AU9um3uFwnyQWEs8GfuPbNIRVsqLQ,3676
|
|
13
|
+
david_data/resources/financials.py,sha256=pEVXe1boq_iWnBoROlt0pm1vVAMT0XQKb9O3wpg3L1w,8731
|
|
14
|
+
david_data/resources/macro.py,sha256=Vp7BDFUUmtcfVSP2opmYEsWbVr825tWXtYsk3_kLPQ8,2002
|
|
15
|
+
david_data/resources/metadata.py,sha256=7pnjXAbimuCdq63w2MsxDuCQjJP1I5YqkRCZwhBEBfY,1195
|
|
16
|
+
david_data/resources/ownership.py,sha256=OVGt-ELp0jPi5v2mmOE73qnrZt6H-_QOBjs_kQeZcdI,4484
|
|
17
|
+
david_data/resources/prices.py,sha256=hHVRTrQPTMIGx7pMe-Pk7U_uO0trowCJ9t_fqAusRDI,2608
|
|
18
|
+
david_data/resources/scenarios.py,sha256=Vr0Gjb7wHqldcFN_ilXQ6DCDFNMz5LGU5mnDq6rrBt0,2746
|
|
19
|
+
david_data-0.1.0.dist-info/METADATA,sha256=Bm5BqSYpPHu599xBBPxo7d2zO0QAeIQKZb3Hk29KKGE,5671
|
|
20
|
+
david_data-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
21
|
+
david_data-0.1.0.dist-info/licenses/LICENSE,sha256=IwuRgB1JQvlTCQacMywgbEOXFzMhXn9MROVryVK2iXo,1067
|
|
22
|
+
david_data-0.1.0.dist-info/RECORD,,
|
|
@@ -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.
|