@@ -37,6 +37,7 @@ typedef struct TdxCredentials TdxCredentials;
3737typedef struct TdxClient TdxClient ;
3838typedef struct TdxConfig TdxConfig ;
3939typedef struct TdxFpssHandle TdxFpssHandle ;
40+ typedef struct TdxUnified TdxUnified ;
4041
4142/* ═══════════════════════════════════════════════════════════════════════ */
4243/* #[repr(C)] tick types — layout-compatible with Rust tdbe structs */
@@ -890,6 +891,69 @@ void tdx_fpss_shutdown(const TdxFpssHandle* h);
890891/** Free the FPSS handle. Must be called after tdx_fpss_shutdown. */
891892void tdx_fpss_free (TdxFpssHandle * h );
892893
894+ /* ======================================================================= */
895+ /* Unified client -- historical + streaming through one handle */
896+ /* ======================================================================= */
897+
898+ /** Connect to ThetaData (historical only -- FPSS streaming is NOT started).
899+ * Returns NULL on connection/auth failure (check tdx_last_error()). */
900+ TdxUnified * tdx_unified_connect (const TdxCredentials * creds , const TdxConfig * config );
901+
902+ /** Start FPSS streaming on the unified client. Returns 0 on success, -1 on error. */
903+ int tdx_unified_start_streaming (const TdxUnified * handle );
904+
905+ /** Subscribe to quote data for a stock symbol. Returns 0 on success, -1 on error. */
906+ int tdx_unified_subscribe_quotes (const TdxUnified * handle , const char * symbol );
907+
908+ /** Subscribe to trade data for a stock symbol. Returns 0 on success, -1 on error. */
909+ int tdx_unified_subscribe_trades (const TdxUnified * handle , const char * symbol );
910+
911+ /** Unsubscribe from quote data. Returns 0 on success, -1 on error. */
912+ int tdx_unified_unsubscribe_quotes (const TdxUnified * handle , const char * symbol );
913+
914+ /** Unsubscribe from trade data. Returns 0 on success, -1 on error. */
915+ int tdx_unified_unsubscribe_trades (const TdxUnified * handle , const char * symbol );
916+
917+ /** Subscribe to open interest data. Returns 0 on success, -1 on error. */
918+ int tdx_unified_subscribe_open_interest (const TdxUnified * handle , const char * symbol );
919+
920+ /** Unsubscribe from open interest data. Returns 0 on success, -1 on error. */
921+ int tdx_unified_unsubscribe_open_interest (const TdxUnified * handle , const char * symbol );
922+
923+ /** Subscribe to all trades for a security type ("STOCK", "OPTION", "INDEX"). Returns 0 or -1. */
924+ int tdx_unified_subscribe_full_trades (const TdxUnified * handle , const char * sec_type );
925+
926+ /** Subscribe to all open interest for a security type. Returns 0 or -1. */
927+ int tdx_unified_subscribe_full_open_interest (const TdxUnified * handle , const char * sec_type );
928+
929+ /** Unsubscribe from all trades for a security type. Returns 0 or -1. */
930+ int tdx_unified_unsubscribe_full_trades (const TdxUnified * handle , const char * sec_type );
931+
932+ /** Unsubscribe from all open interest for a security type. Returns 0 or -1. */
933+ int tdx_unified_unsubscribe_full_open_interest (const TdxUnified * handle , const char * sec_type );
934+
935+ /** Check if streaming is active. Returns 1 if streaming, 0 otherwise. */
936+ int tdx_unified_is_streaming (const TdxUnified * handle );
937+
938+ /** Look up a contract by ID. Returns string or NULL. Caller must free with tdx_string_free. */
939+ char * tdx_unified_contract_lookup (const TdxUnified * handle , int id );
940+
941+ /** Get active subscriptions as typed array. Caller must free with tdx_subscription_array_free. */
942+ TdxSubscriptionArray * tdx_unified_active_subscriptions (const TdxUnified * handle );
943+
944+ /** Poll for next streaming event. Returns TdxFpssEvent* or NULL on timeout.
945+ * Caller MUST free with tdx_fpss_event_free. */
946+ TdxFpssEvent * tdx_unified_next_event (const TdxUnified * handle , uint64_t timeout_ms );
947+
948+ /** Borrow the historical client from a unified handle. Do NOT free the returned pointer. */
949+ const TdxClient * tdx_unified_historical (const TdxUnified * handle );
950+
951+ /** Stop streaming on the unified client. Historical remains available. */
952+ void tdx_unified_stop_streaming (const TdxUnified * handle );
953+
954+ /** Free a unified client handle. */
955+ void tdx_unified_free (TdxUnified * handle );
956+
893957#ifdef __cplusplus
894958}
895959#endif
0 commit comments