FXMacroData for ClickHouse
Load FXMacroData public responses into ClickHouse with the official
clickhouse-connect Python client. Join macro announcements with your market
prices while retaining the source payload and revision metadata.
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/clickhouse-fxmacrodata
Configure FXMD_API_KEY, CLICKHOUSE_HOST, CLICKHOUSE_USER, and
CLICKHOUSE_PASSWORD in your runtime secret store. Then use a customer-owned
ClickHouse database:
import os
import clickhouse_connect
from fxmacrodata_platform_core import read
from fxmacrodata_clickhouse import load
client = clickhouse_connect.get_client(
host=os.environ["CLICKHOUSE_HOST"],
username=os.environ["CLICKHOUSE_USER"],
password=os.environ["CLICKHOUSE_PASSWORD"],
secure=True,
)
try:
batch = read("release_calendar", {"currency": "usd"}, api_key_env="FXMD_API_KEY")
result = load(batch, client, "analytics.fxmacrodata", batch_size=1000)
finally:
client.close()
The database must already exist. By default the loader creates the envelope
table if absent. Set create_table=False to use a table provisioned by your
administrator; create_table_sql(table) returns the required DDL.
Identifiers accept one or two simple names, such as fxmacrodata or
analytics.fxmacrodata. Quoted names, 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 tabular 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.
Columns 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.
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 rows. 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 official SDK connection you pass to the loader. The adapter neither saves nor prints credentials and never constructs destination credentials 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 warehouse does not grant permission to publish or resell it.
Retries and querying
The table uses ReplacingMergeTree ordered by operation, record ID and content
hash. Repeated identical envelopes are collapsed by background merges. Query
with FINAL when you require duplicate-free results immediately:
SELECT currency, indicator, date, value, record_json
FROM analytics.fxmacrodata FINAL
WHERE record_json != 'null';
This is eventual storage deduplication, not an exactly-once insert guarantee.
Changed record data or response metadata produces a distinct content hash and is
retained. Inserts are not retried automatically. On a failure, earlier blocks may
already exist; retrying the same source batch is safe for queries using FINAL.
Existing tables must use the documented engine and key for these semantics.
LoadResult.rows counts envelopes submitted, rather than newly created logical rows.
See event_study.sql for an announcement/price join. The example expects your own licensed market-price table 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.
Test
python -m pytest tests -q
Official SDK reference: ClickHouse Connect inserts.
Metadata
Release files for clickhouse-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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clickhouse_fxmacrodata-0.1.0.tar.gz | 9.2 kB | Without provenance | Details for clickhouse_fxmacrodata-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clickhouse_fxmacrodata-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for clickhouse_fxmacrodata-0.1.0-py3-none-any.whl |
Total release size: 16.4 kB
Release files / clickhouse_fxmacrodata-0.1.0.tar.gz
| Download URL | clickhouse_fxmacrodata-0.1.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d68bc59e212261514498457a8dbe96d0755d07c25296baf96e2845552321152c
|
|
BLAKE2b-256 checksum How to use checksums |
38f1e6777bc02420cd1911faf2ff8689e20444eeb9b95ad56b961467addd6211
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
FXMacroData-PackagePublisher/1.0
|
Release files / clickhouse_fxmacrodata-0.1.0-py3-none-any.whl
| Download URL | clickhouse_fxmacrodata-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
459559d2baf32d7898815e47b6d3ef694148f92519430c7fb2842429be1787be
|
|
BLAKE2b-256 checksum How to use checksums |
d436543f82233987a7df7a72b94e156ed067bd97f3e449388a489060d33f5574
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
FXMacroData-PackagePublisher/1.0
|
Security for clickhouse-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.