Quantum Signals Client
Python client library for Quantum Signals APIs.
Overview
This package provides a Python client for interacting with Quantum Signals services:
- Streaming: SSE-based signal streaming
- Inference: Model catalog and prediction endpoints
- Key Management: API key CRUD operations
- Backtest: Backtest results and metadata
Configuration
The client reads configuration from environment variables:
# Required:
export QUANTUMSIGNALS_API_KEY=foobar
# Optional, defaults to production URL:
export QUANTUMSIGNALS_BASE_URL=http://localhost:8000
The API key can also be set explicitly:
from quantumsignals.client import Client
client = Client(api_key="foobar")
client.set_api_key("foobar")
Usage
Init
from quantumsignals.client import Client
client = Client()
Fetching Available Models
models = client.get_model_catalog()
Streaming Signals
# Stream real-time signals via SSE
for signal in client.stream_signals():
print(f"{signal.time} | {signal.symbol}: {signal.signal}")
Filtering by Symbols and Models
# Stream only specific symbols
for signal in client.stream_signals(symbols=["AAPL", "MSFT"]):
print(signal)
# Stream only specific models
for signal in client.stream_signals(models=["model_v1", "model_v2"]):
print(signal)
# Combine filters (AND logic)
for signal in client.stream_signals(
symbols=["AAPL", "MSFT"],
models=["model_v1"]
):
print(signal)
Replay from Start of Trading Day
Use replay_day_from_start=True to replay all signals from the beginning of the
trading day (9:30 AM ET) as fast as possible, then continue with live streaming.
This is useful when connecting mid-day to catch up on all signals that were
generated earlier.
# Replay all signals from market open, then continue live
for signal in client.stream_signals(replay_day_from_start=True):
print(f"{signal.signal_time_utc} | {signal.symbol}: {signal.signal}")
# Combine with filters
for signal in client.stream_signals(
symbols=["AAPL"],
models=["model_v1"],
replay_day_from_start=True
):
print(signal)
The server sends a replay_status event when replay completes and transitions
to live streaming. The client handles this automatically - you'll simply see
historical signals arrive rapidly, followed by live signals at their normal pace.
Handling Null Signals
When the market is closed but data is still arriving, you'll receive "null signals"
with signal=None and a non-zero code. These provide visibility into model
activity even when not actively trading.
from quantumsignals.client.models import SignalCode
for signal in client.stream_signals():
if signal.is_null_signal():
# Market is closed, no prediction made
print(f"Null signal: {signal.code_message}")
continue
# Process normal trading signal
print(f"{signal.symbol}: {signal.signal}")
Signal codes:
0(NORMAL): Normal trading signal with valid prediction1(MARKET_CLOSED): Outside trading hours - no prediction made2(STALE_CACHE): Inference cache stale for this model's market - predictor refused to serve3(MODEL_TRADING_END): Model has finished its trading day - past the published signal's end_window.start, before market close
Older client versions that pre-date a new code value still deserialize successfully (signal.code is a plain integer). is_null_signal() returns True for any non-NORMAL code, and signal.code_message falls back to "Unknown code: N" so unrecognised codes degrade gracefully — upgrade the client at your leisure to get the human-readable description.
Automatic Reconnection
The client automatically reconnects with exponential backoff if the connection
is lost. On reconnection, it sends a Last-Event-ID header to recover any
missed events from the server's buffer (last ~100 events).
# Reconnection is enabled by default
for signal in client.stream_signals(auto_reconnect=True): # default
print(signal)
# Disable if you want to handle reconnection yourself
for signal in client.stream_signals(auto_reconnect=False):
print(signal)
Recent Signals (pull)
For agents (or anything that prefers a request/response loop over a held-open
stream), get_recent_signals() pulls the current trading day's signals as a
JSON page instead of SSE:
# Catch up: the most recent page
page = client.get_recent_signals()
for signal in page.signals:
print(signal.signal_id, signal.signal)
# Incremental polling — pass the previous next_cursor back as since_cursor,
# which costs work proportional to new signals, not the whole day.
cursor = page.next_cursor
while True:
page = client.get_recent_signals(since_cursor=cursor)
for signal in page.signals:
handle(signal)
if page.next_cursor is not None:
cursor = page.next_cursor
time.sleep(30)
# Other filters (composable):
client.get_recent_signals(last=20) # most recent 20 (a tail)
client.get_recent_signals(actionable_only=True) # drop null / non-actionable
client.get_recent_signals(
since=datetime.now(timezone.utc) - timedelta(hours=1) # must be tz-aware
)
# Restrict to specific signals by canonical slug (empty = all permitted).
# Non-empty returns only these, intersected with your permissions.
client.get_recent_signals(signals=["5min_S&P500", "5min_nasdaq100"])
Only signals from the current Eastern-Time trading day that you're permitted on
are returned. When a page is truncated, page.has_more is True — keep paging
forward with since_cursor=page.next_cursor.
Backtest Operations
# Get backtest metadata
metadata = client.get_backtest_metadata(
model_family="Pythia",
symbol="AAPL"
)
# Get historical predictions (JSON, CSV, or Parquet)
results = client.get_historical_predictions(
model_family="Pythia-aB24X",
symbol="NVDA",
format="json",
page=1,
page_size=100
)
# Get daily backtest summaries
daily = client.get_daily_backtests(
model_family="Pythia-aB24X",
symbol="NVDA",
format="json"
)
Context Manager Usage
# Properly close HTTP connections
with Client() as client:
models = client.get_model_catalog()
# Client automatically closes on exit
Development
This is a workspace package in the QS1 monorepo. See the main repository README for development setup.
Metadata
Release files for quantumsignals-client 0.9.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 |
|---|---|---|---|---|
| quantumsignals_client-0.9.0.tar.gz | 24.5 kB | Without provenance | Details for quantumsignals_client-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quantumsignals_client-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for quantumsignals_client-0.9.0-py3-none-any.whl |
Total release size: 42.2 kB
Release files / quantumsignals_client-0.9.0.tar.gz
| Download URL | quantumsignals_client-0.9.0.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a664b1aae50d1cf99e9fcc2b954a6854da3956ad5864f101082c089ae4d81bb
|
|
BLAKE2b-256 checksum How to use checksums |
0cadf12717ba6c0a20abbe01724b360bccbe82c400eaeb63f07c0d5a51726568
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.8
|
Release files / quantumsignals_client-0.9.0-py3-none-any.whl
| Download URL | quantumsignals_client-0.9.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab02d32fdb9e02ecfeab70168d065aa3ea7f43729bb75cf3c8fd4f8edbe8661e
|
|
BLAKE2b-256 checksum How to use checksums |
24519ee828fc99ea495322f246d4b322d009f8dd7e6fd1bcb0dd23c140bea1a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.8
|
Security for quantumsignals-client 0.9.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.