Skip to content

v6.14.0

Latest

Choose a tag to compare

@wallneradam wallneradam released this 16 Nov 08:24
· 4 commits to main since this release

v6.14.0 carries the same changes as v6.13.6, released again as a minor version because of their scope; v6.13.6 is yanked on PyPI.

Diagnostic codes

Every error a script causes now has a code. The run-time errors of a script are R codes, the rules of Pyne code are P codes, the Pyne Edge profile is E codes, and an error of PyneCore itself is I0004. The registry lives in scripts/errorcodes/registry.toml; the generated pynecore.errorcodes module has one exception class per code, all derived from PyneError (pynecore.core.errors).

  • Each class keeps the built-in it replaces as a base, so existing except ValueError / IndexError / RuntimeError handlers still catch them.
  • pyne run prints a coded error as one line: bar N (time): CODE at <site>: message, with the source location (module, file, line, column) and, for a compiled .pine, the Pine line from the <script>.py.map sourcemap written beside the code. --traceback adds the traceback.
  • Run-time checks raise codes: ta lengths, percentiles, math.sum, max_bars_back, loop steps, array/matrix/string errors, na object fields and copies, timeframe/session/date/time zone parsing, request.security (missing data, lower timeframe above the script's, loop-varying expressions, context limit), line.get_price, unavailable built-ins, unknown methods, missing syminfo details. ZeroDivisionError, UnboundLocalError and int()/round() of inf or NaN get their codes when they leave the script.
  • Inlined built-ins report their code too: an inlined array.get out of range is R0010.
  • A request.security context stopped by a coded error hands the error to the chart, which raises it marked as the context's.
  • Data, script and run option errors: R0046 (unreadable or unsupported OHLCV file), R0047 (script not runnable: no @pyne, no main, no script decorator, main not returning a dict), R0048 (file not found), R0049 (provider unavailable or failed authentication). R0037 names the file and row of importer, CSV and symbol TOML errors.
  • Pyne code rules (P0001–P0021): the transform's rejections point at their place in the source. The native steps and the wasm entry return the same code and arguments.
  • Edge profile (E0001–E0070): the Edge gate and its typed half report one code per message, in Python and natively; E0011 is new (double-underscore names). Every P and E class derives from PyneSyntaxError, so tracebacks keep their caret.
  • New codes for the remaining script errors: R0050 call_arguments, R0051 series_subscript, R0052 argument_out_of_range, R0053 export_misuse, R0054 security_not_rewritten. A failed assert of the script's own code is R0004.
  • R0034 in the strategy: the decimal kernels, the price and currency format and the volume merge raise DecimalInvalidError with the function and reason; a decimal division by zero is R0034 too.
  • I0004: pyne run and the standalone runner report an uncoded exception of PyneCore's own code as an internal error, with the traceback and a request to report it. ScriptRunner re-raises such exceptions unchanged. Errors of the standard library, of the machine, a TypeError, a misspelled name and the broker and plugin APIs are not reported as I0004.
  • runtime.error() raises ScriptRuntimeError (R0005).
  • Reference docs: docs/reference/codes/ has one page per domain (run-time errors, Pyne code rules, Edge profile) with an anchor per code.
  • The pynecore-codes Rust crate (no_std) carries the same codes for native consumers; format_arg shares its test vectors with Python.

Live trading

  • Paper orders fill on every tick with calc_on_every_tick. An order placed later in a forming bar could fill at the bar's open, at a price from before it existed. Each live update is now filled as it arrives, so an order placed on one tick fills on the next; a level the price stepped over between ticks fills at the tick price. Live paper trading also runs the process_orders_on_close pass at bar close.
  • Forming-bar results: run_iter(yield_ticks=True) yields every intra-bar live update (is_closed=False), with its plots and closed trades when the body ran on it.
  • History trades: ScriptRunner(live_history_trades=True) and pyne run --history-trades let live paper trading trade on the warmup bars and continue that position live. Off by default; rejected with a broker and in backtests. The last downloaded bar places no orders while its period was still open at download time (history_as_of).
  • The live warmup runs only the latest of consecutive same-timestamp items, so a partial downloaded last bar and its caught-up close are one bar.
  • Feed status: live_ohlcv_generator(on_feed_status=...) reports connecting, live, reconnecting (attempt, offline time, error), market closed and stopped.
  • Provider API: pynecore.core.provider_download offers download_provider_history(_resilient) without terminal output (progress through a DownloadListener, failures raised), require_live_provider() and open_live_stream().
  • Stopping from another thread: LiveStop ends a live stream or a provider download's retry backoff from any thread (DownloadStopped), so a front end without Ctrl-C can stop a live run. The startup backfill no longer holds a stop for the whole join timeout.

Fixes

  • The CLI writes stdout and stderr as UTF-8 on every platform; on Windows a redirected stream raised UnicodeEncodeError on the first box-drawing glyph (#119).
  • On Python 3.14, every hasattr() on a missing syminfo detail raised NameError.
  • matrix.concat of a matrix with itself never terminated; negative matrix.reshape dimensions erased the matrix.
  • na_bool passed positionally or inside an unpacked argument silently fell back to False.
  • The JSON, CSV and TXT importers read ask_open/ask_high/ask_low/ask_close back into the bar's ask prices instead of dropping them; a partial ask group is rejected.
  • The control-flow asserts of closedtrades and opentrades are explicit checks, so python -O keeps their answers.

Breaking changes

  • NaFieldError is removed. A field of an na object raises NaObjectFieldError (R0043) and a copy raises NaObjectCopyError (R0044); both still derive from RuntimeError.

Docs

  • The IDE setup guide recommends PyneIDE for Pyne code; the manual pyright configuration stays as a fallback.