Skip to content

Configuration

The configuration object (DirectConfig in Rust, Config elsewhere) ships sensible defaults; override individual fields when you need to.

Environments

PresetUse
production()Live market data.
dev()Streaming servers replay a past trading day in a loop at full speed — develop while markets are closed. Historical requests still hit production.
stage()Vendor staging servers; expect reboots.
python
from thetadatadx import Config

cfg = Config.production()
cfg.retry_max_attempts = 5
cfg.flush_mode = "immediate"
tdx = ThetaDataDxClient(creds, cfg)

In Rust the same fields live on DirectConfig struct sub-configs (config.retry.max_attempts, config.fpss.flush_mode); TypeScript uses Config setters (cfg.setRetryMaxAttempts(5)); C++ uses tdx::Config::set_retry_max_attempts(5).

The knobs that matter

GroupFieldsWhat they control
Request deadlinestimeout_ms per request (builder / kwarg)Hard per-call deadline; expiry raises a timeout error and frees the slot.
Retriesretry_initial_delay_ms, retry_max_delay_ms, retry_max_attempts, retry_jitter, retry_max_elapsed_secsBackoff schedule for transient historical-request faults.
Concurrencyconcurrent_requestsParallel historical requests; auto-set from your tier. See Concurrent Requests.
Streaming reconnectreconnect_policy, reconnect_max_attempts, reconnect_wait_ms, reconnect_wait_max_ms, reconnect_jitter, reconnect_stable_window_secs, …Automatic streaming reconnection. See Reconnection & Monitoring.
Streaming latencyflush_mode ("batched" default / "immediate"), fpss_ring_size, fpss_timeout_ms, keepalive fieldsWrite-path flush behavior and event-buffer capacity.
Flat filesflatfiles_max_attempts, flatfiles_initial_backoff_secs, flatfiles_max_backoff_secs, flatfiles_jitterRetry budget for bulk downloads.
Observabilitymetrics_portOptional local Prometheus exporter port (off by default).
Runtimeworker_threadsAsync worker-thread count for embedded bindings (0 = auto).

Every field above is available on all four language surfaces under the naming convention shown earlier; unknown values fail at configuration time, not at first request.

Config file (Rust)

With the config-file feature, Rust loads the same fields from TOML — useful for operating the server binary or any deployment where configuration should live outside code:

toml
[retry]
max_attempts = 5

[fpss]
flush_mode = "immediate"
hosts = ["host-a.example.com:20000", "host-b.example.com:20000"]

Streaming host lists are configurable only at this layer (or via DirectConfig in Rust); the other bindings inherit them from the loaded config.

Released under the Apache-2.0 License.