tickerdb 0.2.2__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. tickerdb-1.0.0/.gitignore +223 -0
  2. tickerdb-1.0.0/CHANGELOG.md +32 -0
  3. tickerdb-1.0.0/LICENSE +21 -0
  4. tickerdb-1.0.0/PKG-INFO +194 -0
  5. tickerdb-1.0.0/README.md +159 -0
  6. tickerdb-1.0.0/openapi.json +24033 -0
  7. {tickerdb-0.2.2 → tickerdb-1.0.0}/pyproject.toml +73 -57
  8. tickerdb-1.0.0/scripts/generate.py +294 -0
  9. tickerdb-1.0.0/src/tickerdb/__init__.py +56 -0
  10. tickerdb-1.0.0/src/tickerdb/_generated.py +1653 -0
  11. tickerdb-1.0.0/src/tickerdb/_transport.py +267 -0
  12. tickerdb-1.0.0/src/tickerdb/_version.py +3 -0
  13. tickerdb-1.0.0/src/tickerdb/auth.py +94 -0
  14. tickerdb-1.0.0/src/tickerdb/client.py +261 -0
  15. tickerdb-1.0.0/src/tickerdb/exceptions.py +92 -0
  16. tickerdb-1.0.0/src/tickerdb/fields.py +1336 -0
  17. tickerdb-1.0.0/src/tickerdb/query.py +112 -0
  18. tickerdb-1.0.0/tests/conftest.py +67 -0
  19. tickerdb-1.0.0/tests/test_client.py +330 -0
  20. tickerdb-1.0.0/tests/test_live.py +65 -0
  21. tickerdb-1.0.0/tests/test_spec.py +104 -0
  22. tickerdb-0.2.2/.claude/settings.local.json +0 -11
  23. tickerdb-0.2.2/.gitattributes +0 -2
  24. tickerdb-0.2.2/.gitignore +0 -11
  25. tickerdb-0.2.2/CHANGELOG.md +0 -48
  26. tickerdb-0.2.2/PKG-INFO +0 -335
  27. tickerdb-0.2.2/README.md +0 -302
  28. tickerdb-0.2.2/examples/smoke_test.py +0 -64
  29. tickerdb-0.2.2/src/tickerdb/__init__.py +0 -76
  30. tickerdb-0.2.2/src/tickerdb/_endpoints.py +0 -124
  31. tickerdb-0.2.2/src/tickerdb/_transport.py +0 -133
  32. tickerdb-0.2.2/src/tickerdb/_version.py +0 -3
  33. tickerdb-0.2.2/src/tickerdb/async_client.py +0 -351
  34. tickerdb-0.2.2/src/tickerdb/client.py +0 -347
  35. tickerdb-0.2.2/src/tickerdb/exceptions.py +0 -81
  36. tickerdb-0.2.2/src/tickerdb/query.py +0 -105
  37. tickerdb-0.2.2/src/tickerdb/types/__init__.py +0 -46
  38. tickerdb-0.2.2/src/tickerdb/types/account.py +0 -34
  39. tickerdb-0.2.2/src/tickerdb/types/common.py +0 -33
  40. tickerdb-0.2.2/src/tickerdb/types/ohlcv.py +0 -40
  41. tickerdb-0.2.2/src/tickerdb/types/search.py +0 -69
  42. tickerdb-0.2.2/src/tickerdb/types/summary.py +0 -55
  43. tickerdb-0.2.2/tests/conftest.py +0 -42
  44. tickerdb-0.2.2/tests/test_client.py +0 -64
  45. tickerdb-0.2.2/tests/test_endpoints.py +0 -59
  46. tickerdb-0.2.2/tests/test_query.py +0 -51
  47. tickerdb-0.2.2/tests/test_transport.py +0 -93
  48. {tickerdb-0.2.2 → tickerdb-1.0.0}/src/tickerdb/py.typed +0 -0
@@ -0,0 +1,223 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # uv
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Conda environments
163
+ conda-meta/
164
+
165
+ # Spyder project settings
166
+ .spyderproject
167
+ .spyproject
168
+
169
+ # Rope project settings
170
+ .ropeproject
171
+
172
+ # mkdocs/Zensical documentation
173
+ /site
174
+
175
+ # mypy
176
+ .mypy_cache/
177
+ .dmypy.json
178
+ dmypy.json
179
+
180
+ # Pyre type checker
181
+ .pyre/
182
+
183
+ # pytype static type analyzer
184
+ .pytype/
185
+
186
+ # Cython debug symbols
187
+ cython_debug/
188
+
189
+ # PyCharm
190
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
191
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
192
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
193
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
194
+ # .idea/
195
+
196
+ # Abstra
197
+ # Abstra is an AI-powered process automation framework.
198
+ # Ignore directories containing user credentials, local state, and settings.
199
+ # Learn more at https://abstra.io/docs
200
+ .abstra/
201
+
202
+ # Visual Studio Code
203
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
204
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
205
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
206
+ # could uncomment the following to ignore the entire vscode folder
207
+ # .vscode/
208
+ # Temporary file for partial code execution
209
+ tempCodeRunnerFile.py
210
+
211
+ # Ruff stuff:
212
+ .ruff_cache/
213
+
214
+ # PyPI configuration file
215
+ .pypirc
216
+
217
+ # Marimo
218
+ marimo/_static/
219
+ marimo/_lsp/
220
+ __marimo__/
221
+
222
+ # Streamlit
223
+ .streamlit/secrets.toml
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2026-11-28
4
+
5
+ A rewrite for the current TickerDB API. It breaks 0.2 code: see "Upgrading from 0.2" in the README.
6
+
7
+ ### Added
8
+
9
+ - Every endpoint of the API as a method: summary, OHLCV, search, universe, history, market, diff,
10
+ statements, insiders, funds, indexes, models, watchlist, schema, status and account.
11
+ - The methods and the field tables are generated from the API's own OpenAPI document
12
+ (`openapi.json`, `scripts/generate.py`), so the library follows the API by regenerating.
13
+ - `iter_...` methods that return every row across pages (cursor, offset and History's page tokens).
14
+ - `Result`: the response as a dict, with `.rows`, `.usage` and `.to_frame()` (pandas).
15
+ - `tickerdb.fields`: every field with its type, band values and description; `fields.find()`.
16
+ - `tickerdb.login()`: device login in the browser; the key is saved for `TickerDB()` to find.
17
+ The key is also read from `TICKERDB_API_KEY`.
18
+ - Retries for network errors and 429, 502, 503 and 504.
19
+ - Lists, dates and booleans as Python values; long History requests are sent as a POST.
20
+
21
+ ### Changed
22
+
23
+ - Methods return the response itself instead of `{"data", "rate_limits"}`.
24
+ - `base_url` is the host (`https://api.tickerdb.com`), without `/v1`.
25
+ - Exceptions follow the API's error types: `InvalidRequestError`, `AuthenticationError`,
26
+ `InsufficientCreditsError` (402), `PlanRestrictedError`, `NotFoundError`, `RateLimitError`,
27
+ `ServiceUnavailableError`.
28
+ - Python 3.10 or newer (3.9 has reached its end of life).
29
+
30
+ ## [0.2.2] - 2026-07-14
31
+
32
+ The last release for the previous API.
tickerdb-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TickerDB
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,194 @@
1
+ Metadata-Version: 2.5
2
+ Name: tickerdb
3
+ Version: 1.0.0
4
+ Summary: Market data for AI agents: point-in-time technicals, fundamentals, SEC filings, insider trades and macro. The official Python client for the TickerDB API.
5
+ Project-URL: Homepage, https://tickerdb.com
6
+ Project-URL: Documentation, https://tickerdb.com/docs
7
+ Project-URL: Repository, https://github.com/tickerdb/tickerdb-python
8
+ Project-URL: Changelog, https://github.com/tickerdb/tickerdb-python/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/tickerdb/tickerdb-python/issues
10
+ Author-email: TickerDB <support@tickerdb.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: api,backtesting,crypto,etf,finance,market-data,point-in-time,sec-filings,stocks
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Office/Business :: Financial :: Investment
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: httpx>=0.24.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pandas>=1.5; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4; extra == 'dev'
32
+ Provides-Extra: pandas
33
+ Requires-Dist: pandas>=1.5; extra == 'pandas'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # TickerDB for Python
37
+
38
+ [![PyPI version](https://img.shields.io/pypi/v/tickerdb.svg)](https://pypi.org/project/tickerdb/)
39
+ [![Python versions](https://img.shields.io/pypi/pyversions/tickerdb.svg)](https://pypi.org/project/tickerdb/)
40
+
41
+ **Market data for AI agents.** Technicals, fundamentals, SEC filings, insider trades and macro, ready to search and backtest. This is the official Python client for the [TickerDB API](https://tickerdb.com/docs).
42
+
43
+ - **10,000+ tickers.** US stocks, ETFs and crypto, daily and weekly.
44
+ - **Full-market screening.** Filter every stock on any field and any date, in one call.
45
+ - **Point in time.** Each date only uses data that was public by then, without lookahead bias.
46
+ - **Direct from the SEC.** Built from SEC EDGAR filings: 10-K, 10-Q, 8-K, Form 4, 13F and N-PORT.
47
+
48
+ **Work 6.2x faster, on 55% fewer tokens.** TickerDB does the computing for you: trends, patterns and valuations for every stock, with their history, as named bands (`momentum_rsi_zone = "oversold"`) plus raw values. So there's no pipeline to build. You just ask for what you want. See the [benchmarks](https://tickerdb.com/benchmarks).
49
+
50
+ ```bash
51
+ pip install "tickerdb[pandas]"
52
+ ```
53
+
54
+ ```python
55
+ import tickerdb
56
+
57
+ tickerdb.login() # once: approve in the browser, the key is saved
58
+ db = tickerdb.TickerDB()
59
+
60
+ db.summary("AAPL")["trend"]["direction"] # 'strong_uptrend'
61
+
62
+ # Screen the whole market, as a DataFrame
63
+ db.search(
64
+ filters=[{"field": "momentum_rsi_zone", "op": "eq", "value": "oversold"},
65
+ {"field": "market_cap_usd", "op": "gt", "value": 10e9}],
66
+ fields=["ticker", "sector", "momentum_rsi_value"],
67
+ ).to_frame()
68
+
69
+ # Every daily bar since 2019, across pages
70
+ bars = tickerdb.frame(db.iter_ohlcv("AAPL", start="2019-01-01", order="asc"))
71
+ ```
72
+
73
+ ## The key
74
+
75
+ `TickerDB()` looks for a key in this order: the `api_key` argument, the `TICKERDB_API_KEY` environment variable, then the key `tickerdb.login()` saved (`~/.config/tickerdb/config.json`, on Windows `%APPDATA%\tickerdb\config.json`). You can also create a key in the [dashboard](https://tickerdb.com/dashboard/keys).
76
+
77
+ ## Methods
78
+
79
+ One method per endpoint, with the endpoint's parameters as keyword arguments. Your editor shows each one's parameters and allowed values.
80
+
81
+ | Method | Endpoint | What it returns |
82
+ | --- | --- | --- |
83
+ | `summary(ticker)` | `/v1/summary/{ticker}` | One asset's full snapshot; also a past date, a date range, or band events |
84
+ | `ohlcv(ticker)` | `/v1/ohlcv/{ticker}` | Daily or weekly price bars |
85
+ | `search()` | `/v1/search` | Assets matching filters, on the latest or any past date |
86
+ | `universe(fields)` | `/v1/universe` | Chosen fields for every asset on one date |
87
+ | `history()` | `/v1/history` | Chosen fields for many assets over a date range |
88
+ | `market()` | `/v1/market` | Market and macro fields per date |
89
+ | `diff(tickers)` | `/v1/diff` | What changed for some tickers |
90
+ | `statements(ticker)`, `statement_lines()` | `/v1/statements` | Financial statements from SEC filings, point in time |
91
+ | `insiders()`, `insider_trades(insider)`, `insider_holdings(insider)` | `/v1/insiders` | Company insiders, 13F institutions, members of Congress |
92
+ | `funds()`, `fund_holdings(fund)`, `fund_holders(ticker)` | `/v1/funds` | Fund holdings from SEC N-PORT filings |
93
+ | `indexes()`, `index_members(index)` | `/v1/indexes` | Index membership on a date |
94
+ | `models()`, `model(slug)`, `model_history(slug)`, `model_holdings(slug)`, `model_trades(slug)`, `models_holdings()` | `/v1/models` | TickerDB's open-source trading models |
95
+ | `watchlist()`, `watchlist_add(tickers)`, `watchlist_remove(tickers)`, `watchlist_diff()` | `/v1/watchlist` | Your watchlist and what changed for it |
96
+ | `schema()`, `status()`, `account()` | | The field list, release times, your plan and usage |
97
+
98
+ Lists can be Python lists (`fields=["ticker", "sector"]`), dates can be `date` objects, and filters are a list of `{"field", "op", "value"}` dicts. The endpoint pages in the [docs](https://tickerdb.com/docs) describe every parameter and response.
99
+
100
+ ## Results
101
+
102
+ Every method returns a `Result`: the response's JSON as a `dict`, with three additions.
103
+
104
+ ```python
105
+ result = db.ohlcv("AAPL", limit=5)
106
+ result["bars"] # the JSON, as documented
107
+ result.rows # the rows, whatever the endpoint calls them
108
+ result.to_frame() # the rows as a pandas DataFrame
109
+ result.usage # {'limit': 200000, 'used': 42, 'remaining': 199958, ...}
110
+ ```
111
+
112
+ ## Paging
113
+
114
+ Endpoints that page have an `iter_...` twin that returns every row, fetching pages as you go:
115
+
116
+ ```python
117
+ for trade in db.iter_insider_trades("jeffrey-p-bezos", start="2024-01-01"):
118
+ ...
119
+
120
+ panel = tickerdb.frame(db.iter_history(
121
+ tickers=["AAPL", "MSFT", "NVDA"],
122
+ fields=["trend_direction", "momentum_rsi_zone", "fundamentals_pe_ratio"],
123
+ timeframe="weekly", start="2019-01-01",
124
+ ))
125
+ ```
126
+
127
+ `max_rows=` stops early. `history()` with thousands of tickers is sent as a POST by itself.
128
+
129
+ ## Fields
130
+
131
+ ```python
132
+ from tickerdb import fields
133
+
134
+ fields.find("rsi zone") # ['momentum_rsi_zone', 'momentum_rsi_zone_prev', ...]
135
+ fields.TICKER["momentum_rsi_zone"].values # ('deep_oversold', 'oversold', 'neutral_low', ...)
136
+ ```
137
+
138
+ `fields.TICKER`, `fields.MARKET` and `fields.MODEL` list every field with its type, band values and description. `db.schema(search="bull flag")` asks the API instead, with full descriptions.
139
+
140
+ ## Search builder
141
+
142
+ ```python
143
+ db.query().eq("trend_direction", "strong_uptrend").gte("market_cap_usd", 2e9) \
144
+ .member_of("sp500").select("ticker", "sector").sort("market_cap_usd").limit(50).execute()
145
+ ```
146
+
147
+ ## Errors
148
+
149
+ ```python
150
+ try:
151
+ db.summary("AAPL", date="2015-01-02")
152
+ except tickerdb.PlanRestrictedError as error: # the date is before your plan's history
153
+ print(error.message, error.upgrade_url)
154
+ except tickerdb.TickerDBError as error: # any API error
155
+ print(error.status_code, error.error_type, error.message)
156
+ ```
157
+
158
+ `InvalidRequestError` (400), `AuthenticationError` (401), `InsufficientCreditsError` (402), `PlanRestrictedError` (403), `NotFoundError` (404), `RateLimitError` (429) and `ServiceUnavailableError` (503) all subclass `TickerDBError`. Network errors and 429, 502, 503 and 504 are retried twice before they are raised (`max_retries=`). Only successful responses cost credits.
159
+
160
+ ## Async
161
+
162
+ ```python
163
+ from tickerdb import AsyncTickerDB
164
+
165
+ async with AsyncTickerDB() as db:
166
+ summary = await db.summary("AAPL")
167
+ async for bar in db.iter_ohlcv("AAPL", start="2019-01-01"):
168
+ ...
169
+ ```
170
+
171
+ ## How this library stays current
172
+
173
+ The methods and the field tables are generated from TickerDB's own OpenAPI document, which the API builds from its routes: <https://api.tickerdb.com/v1/openapi.json>. A copy is in this repository as `openapi.json`.
174
+
175
+ ```bash
176
+ python scripts/generate.py --update # fetch the newest document and regenerate
177
+ python -m pytest # the tests compare the library with the document
178
+ python -m pytest -m live # a few real calls (needs a key)
179
+ ```
180
+
181
+ A push to `main` with a new version in `src/tickerdb/_version.py` is published to PyPI by `.github/workflows/publish.yml`.
182
+
183
+ ## Upgrading from 0.2
184
+
185
+ 1.0 is a rewrite for the current API, and it breaks 0.2 code.
186
+
187
+ - Methods return the response itself, not `{"data": ..., "rate_limits": ...}`. Use `result[...]` and `result.usage`.
188
+ - `base_url` no longer includes `/v1`.
189
+ - `ForbiddenError` is now `PlanRestrictedError`; `DataUnavailableError` is `ServiceUnavailableError`.
190
+ - Field names are the API's current ones (`db.schema()` lists them).
191
+
192
+ ## License
193
+
194
+ MIT
@@ -0,0 +1,159 @@
1
+ # TickerDB for Python
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/tickerdb.svg)](https://pypi.org/project/tickerdb/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/tickerdb.svg)](https://pypi.org/project/tickerdb/)
5
+
6
+ **Market data for AI agents.** Technicals, fundamentals, SEC filings, insider trades and macro, ready to search and backtest. This is the official Python client for the [TickerDB API](https://tickerdb.com/docs).
7
+
8
+ - **10,000+ tickers.** US stocks, ETFs and crypto, daily and weekly.
9
+ - **Full-market screening.** Filter every stock on any field and any date, in one call.
10
+ - **Point in time.** Each date only uses data that was public by then, without lookahead bias.
11
+ - **Direct from the SEC.** Built from SEC EDGAR filings: 10-K, 10-Q, 8-K, Form 4, 13F and N-PORT.
12
+
13
+ **Work 6.2x faster, on 55% fewer tokens.** TickerDB does the computing for you: trends, patterns and valuations for every stock, with their history, as named bands (`momentum_rsi_zone = "oversold"`) plus raw values. So there's no pipeline to build. You just ask for what you want. See the [benchmarks](https://tickerdb.com/benchmarks).
14
+
15
+ ```bash
16
+ pip install "tickerdb[pandas]"
17
+ ```
18
+
19
+ ```python
20
+ import tickerdb
21
+
22
+ tickerdb.login() # once: approve in the browser, the key is saved
23
+ db = tickerdb.TickerDB()
24
+
25
+ db.summary("AAPL")["trend"]["direction"] # 'strong_uptrend'
26
+
27
+ # Screen the whole market, as a DataFrame
28
+ db.search(
29
+ filters=[{"field": "momentum_rsi_zone", "op": "eq", "value": "oversold"},
30
+ {"field": "market_cap_usd", "op": "gt", "value": 10e9}],
31
+ fields=["ticker", "sector", "momentum_rsi_value"],
32
+ ).to_frame()
33
+
34
+ # Every daily bar since 2019, across pages
35
+ bars = tickerdb.frame(db.iter_ohlcv("AAPL", start="2019-01-01", order="asc"))
36
+ ```
37
+
38
+ ## The key
39
+
40
+ `TickerDB()` looks for a key in this order: the `api_key` argument, the `TICKERDB_API_KEY` environment variable, then the key `tickerdb.login()` saved (`~/.config/tickerdb/config.json`, on Windows `%APPDATA%\tickerdb\config.json`). You can also create a key in the [dashboard](https://tickerdb.com/dashboard/keys).
41
+
42
+ ## Methods
43
+
44
+ One method per endpoint, with the endpoint's parameters as keyword arguments. Your editor shows each one's parameters and allowed values.
45
+
46
+ | Method | Endpoint | What it returns |
47
+ | --- | --- | --- |
48
+ | `summary(ticker)` | `/v1/summary/{ticker}` | One asset's full snapshot; also a past date, a date range, or band events |
49
+ | `ohlcv(ticker)` | `/v1/ohlcv/{ticker}` | Daily or weekly price bars |
50
+ | `search()` | `/v1/search` | Assets matching filters, on the latest or any past date |
51
+ | `universe(fields)` | `/v1/universe` | Chosen fields for every asset on one date |
52
+ | `history()` | `/v1/history` | Chosen fields for many assets over a date range |
53
+ | `market()` | `/v1/market` | Market and macro fields per date |
54
+ | `diff(tickers)` | `/v1/diff` | What changed for some tickers |
55
+ | `statements(ticker)`, `statement_lines()` | `/v1/statements` | Financial statements from SEC filings, point in time |
56
+ | `insiders()`, `insider_trades(insider)`, `insider_holdings(insider)` | `/v1/insiders` | Company insiders, 13F institutions, members of Congress |
57
+ | `funds()`, `fund_holdings(fund)`, `fund_holders(ticker)` | `/v1/funds` | Fund holdings from SEC N-PORT filings |
58
+ | `indexes()`, `index_members(index)` | `/v1/indexes` | Index membership on a date |
59
+ | `models()`, `model(slug)`, `model_history(slug)`, `model_holdings(slug)`, `model_trades(slug)`, `models_holdings()` | `/v1/models` | TickerDB's open-source trading models |
60
+ | `watchlist()`, `watchlist_add(tickers)`, `watchlist_remove(tickers)`, `watchlist_diff()` | `/v1/watchlist` | Your watchlist and what changed for it |
61
+ | `schema()`, `status()`, `account()` | | The field list, release times, your plan and usage |
62
+
63
+ Lists can be Python lists (`fields=["ticker", "sector"]`), dates can be `date` objects, and filters are a list of `{"field", "op", "value"}` dicts. The endpoint pages in the [docs](https://tickerdb.com/docs) describe every parameter and response.
64
+
65
+ ## Results
66
+
67
+ Every method returns a `Result`: the response's JSON as a `dict`, with three additions.
68
+
69
+ ```python
70
+ result = db.ohlcv("AAPL", limit=5)
71
+ result["bars"] # the JSON, as documented
72
+ result.rows # the rows, whatever the endpoint calls them
73
+ result.to_frame() # the rows as a pandas DataFrame
74
+ result.usage # {'limit': 200000, 'used': 42, 'remaining': 199958, ...}
75
+ ```
76
+
77
+ ## Paging
78
+
79
+ Endpoints that page have an `iter_...` twin that returns every row, fetching pages as you go:
80
+
81
+ ```python
82
+ for trade in db.iter_insider_trades("jeffrey-p-bezos", start="2024-01-01"):
83
+ ...
84
+
85
+ panel = tickerdb.frame(db.iter_history(
86
+ tickers=["AAPL", "MSFT", "NVDA"],
87
+ fields=["trend_direction", "momentum_rsi_zone", "fundamentals_pe_ratio"],
88
+ timeframe="weekly", start="2019-01-01",
89
+ ))
90
+ ```
91
+
92
+ `max_rows=` stops early. `history()` with thousands of tickers is sent as a POST by itself.
93
+
94
+ ## Fields
95
+
96
+ ```python
97
+ from tickerdb import fields
98
+
99
+ fields.find("rsi zone") # ['momentum_rsi_zone', 'momentum_rsi_zone_prev', ...]
100
+ fields.TICKER["momentum_rsi_zone"].values # ('deep_oversold', 'oversold', 'neutral_low', ...)
101
+ ```
102
+
103
+ `fields.TICKER`, `fields.MARKET` and `fields.MODEL` list every field with its type, band values and description. `db.schema(search="bull flag")` asks the API instead, with full descriptions.
104
+
105
+ ## Search builder
106
+
107
+ ```python
108
+ db.query().eq("trend_direction", "strong_uptrend").gte("market_cap_usd", 2e9) \
109
+ .member_of("sp500").select("ticker", "sector").sort("market_cap_usd").limit(50).execute()
110
+ ```
111
+
112
+ ## Errors
113
+
114
+ ```python
115
+ try:
116
+ db.summary("AAPL", date="2015-01-02")
117
+ except tickerdb.PlanRestrictedError as error: # the date is before your plan's history
118
+ print(error.message, error.upgrade_url)
119
+ except tickerdb.TickerDBError as error: # any API error
120
+ print(error.status_code, error.error_type, error.message)
121
+ ```
122
+
123
+ `InvalidRequestError` (400), `AuthenticationError` (401), `InsufficientCreditsError` (402), `PlanRestrictedError` (403), `NotFoundError` (404), `RateLimitError` (429) and `ServiceUnavailableError` (503) all subclass `TickerDBError`. Network errors and 429, 502, 503 and 504 are retried twice before they are raised (`max_retries=`). Only successful responses cost credits.
124
+
125
+ ## Async
126
+
127
+ ```python
128
+ from tickerdb import AsyncTickerDB
129
+
130
+ async with AsyncTickerDB() as db:
131
+ summary = await db.summary("AAPL")
132
+ async for bar in db.iter_ohlcv("AAPL", start="2019-01-01"):
133
+ ...
134
+ ```
135
+
136
+ ## How this library stays current
137
+
138
+ The methods and the field tables are generated from TickerDB's own OpenAPI document, which the API builds from its routes: <https://api.tickerdb.com/v1/openapi.json>. A copy is in this repository as `openapi.json`.
139
+
140
+ ```bash
141
+ python scripts/generate.py --update # fetch the newest document and regenerate
142
+ python -m pytest # the tests compare the library with the document
143
+ python -m pytest -m live # a few real calls (needs a key)
144
+ ```
145
+
146
+ A push to `main` with a new version in `src/tickerdb/_version.py` is published to PyPI by `.github/workflows/publish.yml`.
147
+
148
+ ## Upgrading from 0.2
149
+
150
+ 1.0 is a rewrite for the current API, and it breaks 0.2 code.
151
+
152
+ - Methods return the response itself, not `{"data": ..., "rate_limits": ...}`. Use `result[...]` and `result.usage`.
153
+ - `base_url` no longer includes `/v1`.
154
+ - `ForbiddenError` is now `PlanRestrictedError`; `DataUnavailableError` is `ServiceUnavailableError`.
155
+ - Field names are the API's current ones (`db.schema()` lists them).
156
+
157
+ ## License
158
+
159
+ MIT