Skip to main content

Barchart Desktop SDK for Python

Live quotes, order books and cumulative volume from Openfeed, kept up to date for you. The Python port of @barchart/desktop-sdk-js, which is the reference implementation: its reference and design describe what this package does.

Early release. The API follows the TypeScript SDK.

Installing

Python 3.11 or later:

pip install barchart-desktop-sdk
# or
uv add barchart-desktop-sdk

Quick start

from barchart_desktop_sdk import Credentials, DesktopSdk, Listener, QuoteEvent, SubscriptionError


def on_quote(event: QuoteEvent) -> None:
    print(event.symbol, event.formatted.session.last)


def on_error(error: SubscriptionError) -> None:
    print(error)


with DesktopSdk() as sdk:
    sdk.login(Credentials(url="ws://localhost:9000", username="your-username", password="your-password"))
    subscription = sdk.subscribe_quote("ES*0", Listener(on_event=on_quote, on_error=on_error))
    ...

ws://localhost:9000 is the Barchart Desktop API, which takes Barchart Desktop's credentials. An Openfeed gateway works the same way, with its own URL.

Always pass on_error: nothing else tells you when the server refuses a subscription, such as one you don't have permission for.

Not every Openfeed server sends volume at price: on one that doesn't, the subscription goes active, but no events come and get_cumulative_volume stays None.

A failed lookup raises: raw.lookup_instruments gives an InstrumentLookupError when the server refuses it or finds nothing.

More in examples/. Every class, method and field has a docstring: your editor shows it on hover, help(DesktopSdk.subscribe_quote) prints it, and the installed package has them all as Markdown in barchart_desktop_sdk/docs/api/. The TypeScript SDK's reference describes the same methods and the delivery guarantees, under the names below.

Names

The same names as the TypeScript SDK, in Python's style: session.lastSize is session.last_size, sdk.subscribeQuote is sdk.subscribe_quote. Records are frozen dataclasses, levels are tuples, times are UTC datetimes (to the microsecond) and trade dates are dates. The logger is a standard logging.Logger, by default logging.getLogger("barchart_desktop_sdk").

Threads

Every method is safe to call from any thread, listeners included.

  • Listeners run one at a time, in order, on the SDK's delivery thread, and never inside the call that registered them, so you always hold the handle first.
  • State is applied as messages arrive, on another thread, so get_quote and the other getters are current even while a slow listener holds up the events behind it. Events wait in a queue with no limit: a listener that can't keep up should use coalesce_interval_ms.
  • A listener mustn't wait on a future the SDK settles, such as sdk.when_connected().result(), since settling it needs the thread the listener is running on. add_done_callback is fine.
  • After close() returns, no new callback starts. One already running on the delivery thread finishes.

The SDK's threads are daemon threads, so one you forget to dispose() doesn't keep the process alive.

In asyncio, await the futures the SDK returns (when_connected, raw.request_snapshot, raw.lookup_instruments) by wrapping them: await asyncio.wrap_future(sdk.when_connected()).

Development

uv manages the Python version, the environment and the lockfile; CONTRIBUTING.md has the rest.

uv sync                                 # the environment, with the dev tools
sh scripts/check.sh                     # everything CI runs: lint, format, types, tests, API docs, build

It depends on openfeed 1.5.0 or later, from PyPI. uv.lock pins the version the checks use; uv lock --upgrade-package openfeed moves it.

Metadata

Release files for barchart-desktop-sdk 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 barchart-desktop-sdk 0.1.0
File Size Uploaded Provenance Actions
barchart_desktop_sdk-0.1.0.tar.gz 66.7 kB With provenance Details for barchart_desktop_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for barchart-desktop-sdk 0.1.0
File Interpreter ABI Platform Actions
barchart_desktop_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for barchart_desktop_sdk-0.1.0-py3-none-any.whl

Total release size: 149.0 kB

Release files / barchart_desktop_sdk-0.1.0.tar.gz

Download URL barchart_desktop_sdk-0.1.0.tar.gz
Size 66.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3f967f08172fadf144cee50ea7a4c1c8202b123c817dfe93fa77c21e710d68ae
BLAKE2b-256 checksum
How to use checksums
015fa6caaf33d7dab5d018f06f5198356f850a8c066ec56b96b4ec6c5441609d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

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

Download URL barchart_desktop_sdk-0.1.0-py3-none-any.whl
Size 82.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0efdf8cbda48b4ff3516127667a5f6a54a9795706f006686e7f7f1793d7c69ba
BLAKE2b-256 checksum
How to use checksums
a84bff6f8352badb6500ec3ae19a7a12b0768aa3519cb23a6c15e867357a44b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for barchart-desktop-sdk 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for barchart_desktop_sdk-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

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 Full 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