Metadata-Version: 2.5
Name: cultivars-data
Version: 0.0.1
Summary: The data layer for cultivars: clients for public economic and financial data, re-exported under one import.
Project-URL: Repository, https://github.com/nikhilxsunder/cultivars-data
Project-URL: Changelog, https://github.com/nikhilxsunder/cultivars-data/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/nikhilxsunder/cultivars-data/issues
Author-email: Nikhil Sunder <nsunder724@gmail.com>
License: MIT
License-File: AUTHORS.md
License-File: LICENSE
Keywords: ALFRED,FRED,SEC EDGAR,data access,econometrics,economic data,financial data,macroeconomics,time series
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Typing :: Typed
Requires-Python: <4.0,>=3.12
Requires-Dist: edgar-sec
Requires-Dist: fedfred
Requires-Dist: toros
Description-Content-Type: text/markdown

<div align="center">
    <img src="https://raw.githubusercontent.com/nikhilxsunder/cultivars-data/main/assets/exported/cultivars_data_banner.png"  alt="cultivars-data banner">
</div>

## The data layer for cultivars: the clients that bring public economic and financial series into a workflow, under one import, published as a distribution of its own.

|                    |                                                                                                                                                                                                                                                                                                                             |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Distribution**   | [![PyPI](https://img.shields.io/pypi/v/cultivars-data.svg)](https://pypi.org/project/cultivars-data/) [![Python Versions](https://img.shields.io/pypi/pyversions/cultivars-data.svg)](https://pypi.org/project/cultivars-data/)                                                                                             |
| **Quality**        | [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)                                                                |
| **Packaging**      | [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv) [![Hatch project](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pypa/hatch/master/docs/assets/badge/v0.json)](https://github.com/pypa/hatch) |
| **License**        | [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nikhilxsunder/cultivars-data/blob/main/LICENSE)                                                                                                                                                                                     |
| **Parent project** | [![cultivars on PyPI](https://img.shields.io/pypi/v/cultivars.svg?include_prereleases&label=cultivars)](https://pypi.org/project/cultivars/) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.23028870.svg)](https://doi.org/10.5281/zenodo.23028870)                                                                    |

## What it is

The models in [cultivars](https://github.com/nikhilxsunder/cultivars) take arrays. The series behind those arrays come from a small number of public providers, each served by a client library with its own repository, documentation and release cycle. `cultivars-data` (import name `cultivars_data`) is where those clients meet. It re-exports them under names that say what kind of data they carry, starting with `economic`, and it is where a provider-neutral way to fetch an aligned panel will be built.

| Name                       | Client                                                  | Provider                                                                   | State                                                           |
| -------------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `cultivars_data.economic`  | [fedfred](https://github.com/nikhilxsunder/fedfred)     | FRED, ALFRED and the GeoFRED maps of the Federal Reserve Bank of St. Louis | Available                                                       |
| `cultivars_data.financial` | [edgar-sec](https://github.com/nikhilxsunder/edgar-sec) | SEC EDGAR                                                                  | Name planned. The client is installed; import it as `edgar_sec` |
| Not named yet              | [toros](https://github.com/edgar-sec-dev-team/toros)    | To be stated when the client has a release beyond its placeholder          | Name planned. The client is installed; import it as `toros`     |

Nothing here is estimated or transformed. A client returns observations; reducing them to the columns and the sample a question needs is the caller's step today and the connector's later.

## What a re-export is, and is not

- **`cultivars_data.economic` is the `fedfred` module.** It is the same object, not a wrapper. Every class and function on it is fedfred's, documented on fedfred's site and versioned by fedfred.
- **The name says the kind of data. It does not hide the provider.** `economic.FredAPI` is a FRED client, and code that calls it is written against fedfred's API.
- **Provider-neutral access is the connector's job.** One call that takes a mapping of names to series and returns an aligned panel is on the [roadmap](https://github.com/nikhilxsunder/cultivars-data/blob/main/ROADMAP.md), and is not part of 0.0.1.

## How it relates to cultivars

1. **cultivars requires it and does not import it.** From cultivars 1.0.0a7, `pip install cultivars` installs this package. No model imports it, and there is no `cultivars.data` module: your code imports `cultivars_data` directly.
2. **The dependency runs one way.** `cultivars-data` imports nothing from `cultivars`. What crosses the boundary is an array and a tuple of names, which is the input every cultivars model already accepts.
3. **The version numbers are independent.** A release here does not imply a cultivars release.

In cultivars 1.0.0a6 and earlier, `cultivars.data` imported `fedfred` directly. 1.0.0a7 removes that module, so `from cultivars.data import economic` becomes `from cultivars_data import economic`.

## Stability

| Surface                        | Guarantee                                                                                                                                                                                                           |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Names defined by this package  | None before 1.0.0. The package is in its `0.0.x` series and any release may rename or remove a name. Changes are listed in the [CHANGELOG](https://github.com/nikhilxsunder/cultivars-data/blob/main/CHANGELOG.md). |
| The re-exported client modules | Not this package's API. Each follows its own project's versioning. A breaking change in a client reaches you through the version of that client you have installed, whatever the version of `cultivars-data`.       |

## Installation

Requires Python 3.12 or later.

```bash
pip install cultivars-data
```

With `uv`:

```bash
uv add cultivars-data
```

Installing the package installs all three clients: `fedfred`, `edgar-sec` and `toros`. `fedfred` 3.0.0 and `toros` 0.0.1 each require `pandas` and `geopandas`, and all three require `httpx`, `tenacity`, `cachetools` and `asyncache`. An install is therefore much larger than the package's own source, which is a few lines.

## Credentials

The providers issue keys, and each client reads its own.

- **FRED.** `fedfred` takes the key from the `api_key` argument, from `economic.set_api_key(...)`, or from the `FRED_API_KEY` environment variable. `economic.FredAPI()` raises a `RuntimeError` that names all three when none is set. A free key is issued at <https://fred.stlouisfed.org/docs/api/api_key.html>.
- **This package never sees the key.** It does not read, store or log credentials. Key handling is the client's.
- **Nothing touches the network at import.** `import cultivars_data` imports the clients and makes no request. A request is made only when you call a client method.

## A quick check

Without a key and without a network connection:

```python
>>> from cultivars_data import economic
>>> economic.__name__
'fedfred'
>>> economic.FredAPI.__module__
'fedfred.clients'
```

With a key, fetch two series, keep the dates on which both are observed, and hand the array to a model. This needs a network connection, so it is not run as a test:

```python
import pandas as pd

from cultivars_data import economic

api = economic.FredAPI()  # reads FRED_API_KEY
series = {"ip": ("INDPRO", "pch"), "ffr": ("FEDFUNDS", "lin")}
columns = {
    name: pd.to_numeric(
        api.get_series_observations(code, observation_start="1990-01-01", units=units)["value"],
        errors="coerce",
    )
    for name, (code, units) in series.items()
}
panel = pd.DataFrame(columns).dropna()
y, names = panel.to_numpy(), tuple(panel.columns)
```

With cultivars installed, `y` and `names` go straight into a model:

```python
from cultivars.multivariate.reduced_form.vector_autoregression import VAR

result = VAR(y, order=4, names=names).fit()
```

The dictionary comprehension above is the step the connector will replace.

## Using what you fetch

The data belongs to its provider, and the provider's terms govern what you may do with it. For FRED, read the [FRED API Terms of Use](https://fred.stlouisfed.org/docs/api/terms_of_use.html) before building on it: among other things they restrict storing, caching and archiving FRED content, and using the API to develop or train machine-learning systems. Some series carry a copyright notice of their own. Cite a series the way its provider asks.

This package does not interpret those terms for you and adds no permission of its own.

## Documentation

This package has no documentation site yet. Until it does:

- The clients are documented at their own sites: [fedfred](https://nikhilxsunder.github.io/fedfred/) and [edgar-sec](https://nikhilxsunder.github.io/edgar-sec/).
- The models that consume the data are documented at <https://nikhilxsunder.github.io/cultivars/stable/> (stable) and <https://nikhilxsunder.github.io/cultivars/dev/> (development).

## Where to report an issue

| What you saw                                                                                 | Where it goes                                                                                                   |
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| A wrong value, a failed request or confusing behavior from a client method such as `FredAPI` | The client's tracker: [fedfred issues](https://github.com/nikhilxsunder/fedfred/issues)                         |
| An import that fails, a missing or misnamed re-export, or anything about the connector       | [cultivars-data issues](https://github.com/nikhilxsunder/cultivars-data/issues/new/choose)                      |
| A wrong number, an error or confusing behavior from a model, result or test                  | [cultivars issues](https://github.com/nikhilxsunder/cultivars/issues/new/choose)                                |
| A security vulnerability                                                                     | Privately, as described in [SECURITY.md](https://github.com/nikhilxsunder/cultivars-data/blob/main/SECURITY.md) |

If you are not sure, file it here. Issues are moved to the tracker where the fix belongs.

## Development

```bash
git clone https://github.com/nikhilxsunder/cultivars-data.git
cd cultivars-data
uv sync --all-groups
uv run pre-commit install
uv run ruff check src && uv run ruff format --check src
uv run mypy src
```

[CONTRIBUTING.md](https://github.com/nikhilxsunder/cultivars-data/blob/main/CONTRIBUTING.md) gives the design rules, the rules for tests that involve a provider, and what a change that touches cultivars or a client has to include.

## Citation

`cultivars-data` is part of cultivars and is not cited separately. If cultivars contributes to published work, cite the concept DOI, which resolves to the latest release:

```bibtex
@software{sunder_cultivars,
  author  = {Sunder, Nikhil},
  title   = {cultivars: Research-grade time series econometrics for Python},
  year    = {2026},
  doi     = {10.5281/zenodo.23028870},
  url     = {https://github.com/nikhilxsunder/cultivars}
}
```

Cite the data as well, in the form its provider asks for.

## License

MIT. See [LICENSE](https://github.com/nikhilxsunder/cultivars-data/blob/main/LICENSE). The license covers this package's code. It does not cover the data a client returns.
