Skip to main content

FXMacroData for MongoDB

Load FXMacroData public responses into MongoDB with the official pymongo driver. Keep macro announcements as queryable documents while retaining the source payload and revision metadata.

FXMacroData documentation

Install and connect

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

python -m pip install /path/to/fxmacrodata-public-client /path/to/fxmacrodata-platform-core /path/to/mongodb-fxmacrodata

Configure FXMD_API_KEY and MONGODB_URI in your runtime secret store. Then load into a customer-owned database:

import os
from pymongo import MongoClient
from fxmacrodata_platform_core import read
from fxmacrodata_mongodb import load

client = MongoClient(os.environ["MONGODB_URI"])
try:
    batch = read("indicator_history", {"currency": "usd", "indicator": "policy_rate"})
    result = load(batch, client["analytics"], "fxmacrodata", batch_size=1000)
finally:
    client.close()

USD operations work without a key. For other currencies pass api_key_env="FXMD_API_KEY" to read or load_operation.

Pass a pymongo Database and the collection name. MongoDB creates the collection on first write. By default the loader also creates a lookup index on operation, currency, indicator, date (named fxmacrodata_lookup); set create_indexes=False when your administrator manages indexes. Collection names are one simple identifier such as fxmacrodata; dotted names, system prefixes, SQL fragments and URL-like names are rejected.

Every operation exposed by fxmacrodata_platform_core.operations() is available, including REST and MCP operations. The loader adds a document envelope without changing the original public response. record_json retains the original record; response_json retains the complete response, including pagination and metadata. An empty response produces one envelope with record_json = 'null', so absence of data and the server's metadata remain inspectable. It is not an observation.

Document fields are operation, source_url, record_id, currency, indicator, date, announcement_datetime, value, value_text, record_json, response_json, and the loader's content_hash. Only value is numeric (a double or null); everything else is a string or null. The JSON columns are stored as strings so the source bytes survive unchanged; parse them in your aggregation pipeline when you need fields from inside them. Dates and announcement times remain source strings. No publication time is inferred, and no missing value is filled. value_text and JSON preserve source numbers supplied as strings. JSON numeric tokens follow the public Python client parser, so original lexical precision is not guaranteed.

Select operations with the shared catalogue rather than constructing URLs:

from fxmacrodata_platform_core import operations, schemas

available = operations()
input_schemas = schemas()

load_operation accepts api_key_env, complete_history, max_pages, and client_factory for the public source reader. max_pages bounds history pagination; an incomplete read raises an error before a destination load starts. batch_size bounds destination blocks to 1���10,000 documents. max_batch_bytes also bounds each block using a conservative JSON byte estimate (16 MiB by default, 128 MiB maximum). An oversized individual envelope is rejected before destination changes; narrow the source date range to reduce the response size. The source response is materialized before loading; choose a source date range suitable for memory. Read the installed operation's schema for required arguments and date filters.

Supply source credentials through your runtime secret store, exposing only the environment variable name to the adapter. Destination authentication belongs to the MongoClient you construct. The adapter neither saves nor prints credentials and never constructs connection strings for you.

The package licence covers this adapter code. FXMacroData data access and onward redistribution remain subject to your subscription and applicable licence. Loading data into a database does not grant permission to publish or resell it.

Retries and querying

Each envelope is one document whose _id is operation:record_id:content_hash, written with an unordered bulk_write of UpdateOne(..., {"$setOnInsert": row}, upsert=True) operations. Retrying the same source batch is idempotent: identical envelopes are skipped, while changed record data or response metadata produces a distinct content hash and is retained alongside the earlier version. document_id(row) returns the key.

cursor = client["analytics"]["fxmacrodata"].find(
    {"record_json": {"$ne": "null"}, "indicator": "policy_rate"},
    {"currency": 1, "date": 1, "value": 1, "record_json": 1},
)

Delivery is at-least-once with an idempotent key. Blocks are not retried automatically. Because blocks are unordered, part of a failing block may be stored; retrying the same source batch is safe. LoadResult.rows counts envelopes submitted, rather than newly inserted documents.

See event_study.py for an announcement/price join. The example expects your own licensed market-price collection and uses source announcement timestamps only. Timestamp presence alone is not evidence that a release had already been published; use source publication metadata when building a point-in-time backtest.

Development

Tests are offline and fake the database:

python -m pytest tests -q

Official driver reference: pymongo bulk writes.

Metadata

Release files for mongodb-fxmacrodata 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongodb-fxmacrodata 0.1.0
File Size Uploaded Provenance Actions
mongodb_fxmacrodata-0.1.0.tar.gz 10.1 kB Without provenance Details for mongodb_fxmacrodata-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mongodb-fxmacrodata 0.1.0
File Interpreter ABI Platform Actions
mongodb_fxmacrodata-0.1.0-py3-none-any.whl Python 3 none any Details for mongodb_fxmacrodata-0.1.0-py3-none-any.whl

Total release size: 17.4 kB

Release files / mongodb_fxmacrodata-0.1.0.tar.gz

Download URL mongodb_fxmacrodata-0.1.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1aa33428c97d72d1b6a6a137fe8495b6486ff6f852e5626799e452c6906beb3c
BLAKE2b-256 checksum
How to use checksums
28916fc7c0c4177bc39663606785212af73f6e1e13bd47828d5033d81ef43ad9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via FXMacroData-PackagePublisher/1.0

Release files / mongodb_fxmacrodata-0.1.0-py3-none-any.whl

Download URL mongodb_fxmacrodata-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6b9d1b2d671fb0965490ebbe0e36ac849c838c83f7124a3d57a486dbdbed6bc
BLAKE2b-256 checksum
How to use checksums
83a1c78311ac731a7a6302a8736560c654e7e485ae60e067e12d607e1928dd0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via FXMacroData-PackagePublisher/1.0

Security for mongodb-fxmacrodata 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page