Metadata-Version: 2.4
Name: datasets-fxmacrodata
Version: 0.1.0
Summary: Build Hugging Face datasets from public FXMacroData responses
License-Expression: MIT
Project-URL: Documentation, https://fxmacrodata.com/documentation/reference?utm_source=pypi&utm_medium=referral&utm_campaign=datasets-fxmacrodata&utm_content=package
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fxmacrodata-platform-core==0.1.0
Requires-Dist: datasets<6,>=5.0.1
Provides-Extra: test
Requires-Dist: pytest<9,>=8; extra == "test"
Dynamic: license-file

# FXMacroData for Hugging Face Datasets

Build a `datasets.Dataset` directly from FXMacroData macroeconomic releases, FX
reference rates, commodities, positioning and calendar data. Use the result with
the Hugging Face ecosystem: `map`, `filter`, Arrow and Parquet export, pandas and
Polars conversion, or model training inputs.

[FXMacroData documentation](https://fxmacrodata.com/documentation/reference?utm_source=github&utm_medium=referral&utm_campaign=datasets-fxmacrodata&utm_content=readme)

## Install

Requires Python 3.10 or later and `datasets` 5.x. Install this package and its
public client dependencies from the distribution supplied to you:

```sh
python -m pip install /path/to/fxmacrodata-public-client /path/to/fxmacrodata-platform-core /path/to/datasets-fxmacrodata
```

## Example

USD indicators are readable without a key:

```python
from fxmacrodata_datasets_hf import load_dataset_fxmacrodata

dataset = load_dataset_fxmacrodata(
    "indicator_history", {"currency": "usd", "indicator": "policy_rate"}
)
print(dataset)
print(dataset.features)
print(dataset.filter(lambda row: row["value"] is not None).to_pandas().head())
```

With a subscription, set `FXMD_API_KEY` in your environment or secret manager
and pass its *name*:

```python
dataset = load_dataset_fxmacrodata(
    "forex", {"base": "EUR", "quote": "USD", "start_date": "2024-01-01"},
    api_key_env="FXMD_API_KEY",
)
dataset.to_parquet("eurusd.parquet")
```

`api_key_env` is an environment variable name, never an API key. Omitting it
explicitly selects anonymous access. Credentials do not belong in arguments,
notebooks, dataset cards or source control; the package never stores or prints
them.

Every operation listed by `fxmacrodata_platform_core.operations()` is supported,
including the `mcp_` tools. Historical operations follow all pages by default;
`complete_history=False` requests the supplied page only. `max_pages` (default
10,000) raises on an incomplete history instead of silently truncating it.
`to_dataset(batch)` converts a `Batch` you have already read, and `features()`
returns the schema without a request.

## Data semantics

The dataset has fixed `Features`: `value` is a nullable `float64`; `operation`,
`source_url`, `record_id`, `currency`, `indicator`, `date`,
`announcement_datetime`, `value_text`, `record_json` and `response_json` are
nullable strings. `record_json` preserves the original record and `response_json`
preserves the complete response envelope, including metadata and revisions.
Dates and announcement times remain source strings; no publication time is
inferred and no missing value is filled. `value_text` keeps numbers the source
supplied as strings.

An empty response still produces one envelope row with `record_json = "null"`,
so absence of data and the server's metadata remain inspectable. It is not an
observation. `record_id` is a stable hash of the operation and original record,
so reading the same data again yields the same identifiers and repeated reads
can be deduplicated on it (at-least-once delivery, idempotent key).

The dataset's `info.description` states that the rows are a live read made under
your own FXMacroData access and licence. It is not a redistributed snapshot.
Building a dataset does not grant permission to publish it to the Hub or to
resell it; onward distribution remains subject to your subscription terms.

## Development

Run the offline tests with `python -m pytest tests -q`. They build in-memory
datasets from fixture responses and never contact the Hugging Face Hub or the
live service.
