Announcing ``schwab-py`` v2.0 ============================= Reviving Regular Maintenance ---------------------------- After a prolonged hiatus `for good reasons, I promise `__, I am returning to actively maintaining ``schwab-py``! In the interim, we've seen good developments, like the community developing some very interesting forks and submitting some very important requests, as well as some bad developments, like deprecation warnings and bugs creeping in. I am now actively working through the outstanding issues with the library, as well as incorporating some of the interesting ideas suggested and implemented by community members. V2 Transition Timeline ---------------------- Some of the changes I am exploring are unfortunately breaking changes. For instance, the migration from the deprecated ``httpx`` to the supported ``httpx2`` results in a different exposed exception hierarchy, which will cause existing code to break. In order to preserve compatibility with existing code, these new changes will be released as a ``2.x`` version series. In order to minimize the impact on users, we will implement a transition plan: * All ``1.x`` releases will feature a deprecation warning admonishing users to either prepare to transition to 2.0 or pin their versions to ``<2.0`` in their package managers. * ``2.0`` will be made available as an extended series of ``alpha`` and ``beta`` releases prior to release, effectively turning it into an optional release for a time. During this prerelease period, the interface will be subject to change. * Once the interface stabilizes, a series of one or more ``2.0`` release candidates will be released with the finalized interface. * The final ``2.0rc(x)`` release candidate will be released as ``2.0`` no less than 90 days after the first ``1.x`` release featuring the deprecation warning, and no less than 14 days after the final ``2.0`` release candidate. This way, users who are still on ``1.x`` have an opportunity to learn about and prepare for the upcoming upgrade, and users following along with the development of ``2.0`` can adjust to the stable interface. * All development will be accompanied by frequent updates in the `support channel on the project discord server `__. Compatibility Changes --------------------- This section lists the substantive differences between ``1.x`` and ``2.0``. ``httpx`` replaced with ``httpx2`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All HTTP is now performed by `httpx2 `__, the actively maintained successor to ``httpx``. Response objects, status codes, timeouts, and client configuration are API-compatible, so most users will notice no difference. However, ``httpx`` and ``httpx2`` define *separate* class hierarchies, so code that references ``httpx`` types directly will need updating: * ``except httpx.HTTPError`` (and other ``httpx`` exception types) will **not** catch errors raised by this library. Update exception handling to use ``httpx2`` exceptions. * ``isinstance(response, httpx.Response)`` checks and ``httpx.Response`` type annotations will fail against our return values. Use ``httpx2.Response``. * The ``httpx`` logger is renamed ``httpx2``; update logging configuration accordingly. Websocket implementation updated ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Streaming now uses ``websockets.asyncio`` (the maintained implementation) instead of the deprecated ``websockets.legacy``. This is transparent for most users, but arguments passed via ``websocket_connect_args`` to :func:`schwab.auth.easy_client` are forwarded verbatim to ``websockets.asyncio.client.connect``, whose signature differs from the legacy ``connect``: * ``extra_headers`` is renamed ``additional_headers`` * ``create_protocol`` is renamed ``create_connection`` with a different signature * ``read_limit`` is removed New options are also available, including ``proxy``, ``reconnect_delays``, and ``process_exception``. See the `websockets asyncio client documentation `__ for the full signature. Prices must be strings ~~~~~~~~~~~~~~~~~~~~~~ ``OrderBuilder.set_price``, ``OrderBuilder.set_stop_price``, and the order templates that call them now require prices as strings. Passing ``float`` (or any other non-string value) raises ``ValueError``; the deprecated ``truncate_float`` conversion path is removed, along with the warning it emitted. Callers previously relying on float conversion must format prices themselves — e.g., ``f'{price:.2f}'``. All price strings pass through verbatim for Schwab to validate, with one exception: strings that parse to a negative number raise ``ValueError``, because the Schwab API silently strips the sign from ``price`` and ``stopPrice`` fields — a negative input would otherwise be submitted as its absolute value, inverting the order's intent. ``copy_price`` and ``copy_stop_price`` still bypass validation as before. AI Disclosure ------------- In keeping with the general tendency in our industry, development of ``schwab-py`` is now performed substantially using AI tools. These tools have proven incredibly useful, and I've already been able to implement tasks in days which I previously expected me to take weeks. I expect these tools will allow me to create a more correct, feature-rich, and useful library than I would have been able to deliver otherwise. On the topic of correctness: AI thrives with concrete and specific feedback, and to that end I am implementing a substantial functionality testing regime based on placing real API calls against my personal Charles Schwab accounts. You may inspect these tests in the `livetests `__ directory of the codebase. If you spot anything suspicious, incorrect, or incomplete, please let me know in the Discord server.