You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pyne run ... --profile profiles a backtest: after the run it prints a summary and writes output/<script>_profile.json. The summary splits the run's time into categories (script, libraries, engine, output, data, security, runner) and lists the slowest lines with their time, share of the script's time, execution count, average and code. --profile-top N sets the number of listed lines (default 15). A function's def line is marked as per-call setup.
Per-line and per-block data: the profile records the time and execution count of every line of the script and its libraries, and the time of every loop and conditional block. A line's share is measured against script_ns, the time spent inside the script's or its libraries' code including everything they call, so nested user calls are not counted twice.
request.security contexts are profiled too: each security child process measures its own lines and script time and sends them back to the runner. The profile lists every context with its data source, timeframe, bars and script time.
Programmatic use:ScriptRunner(profile_path=...) writes the same profile. The profile is written only for a run that completes.
The profiler is built on sys.monitoring with a compiled Cython extension that ships in the wheels. It needs Python 3.13+ and has no pure-Python fallback: without it, --profile ends with an error message instead of a traceback. --profile is refused together with --live and --broker.
Pyne Code
Methods declared in @udt class bodies can now carry state. A method in a class body is Pine's method m(Type this); a ta.* call, a Series or a Persistent inside one used to fail at run time. State belongs to the call site, a call site inside a loop keeps one instance per site and rolls back its builtins per bar, and Class.m(obj) as well as method_call by name reach the same method. A stateful method with a decorator other than @staticmethod is rejected at transform time.
Type inference types an unannotated receiver of a class-body method as its class.
The demo.py script created with a new workdir is marked @pyne edge.
Fixes
Weekly and monthly aggregation: aggregating to monthly targets was always rejected, because a month was measured as a fixed number of seconds. Weekly and monthly targets now accept an intraday source that tiles the day, 1D, or the same calendar unit with a dividing multiplier; combinations whose bars straddle a period boundary (1W -> 1M, 2D -> 1M, 7 -> 1W) are rejected. An intraday source bar is assigned to its day/week/month period by its last instant, cut short by a session end inside the bar, and an nD source counts as n trading days on a multi-day target.
time("D", timeframe_bars_back=N) no longer raises IndexError when the symbol info has no session template: every calendar day then counts as a trading day.
Import order: importing pynecore.core.script (or pynecore.core.profiler) before pynecore.lib no longer raises ImportError.
Line numbers of generated code: code emitted by the transformers now runs at the source line it serves. Inlined math.* and array.get bodies no longer carry the line numbers of the library files, request.security slice clones no longer run main()'s last line in their prologue, and Series/Persistent rewrites and security write/signal/wait blocks no longer fall back to the def line. This fixes debugger stepping, tracebacks and per-line timing.
Code prepended to a function or module goes after the docstring, so __doc__ survives and the docstring is no longer evaluated on every call.
Scripts that start with a from __future__ import now compile when they use request.security or are strategies.
Documentation
New Profiling page, profiling options in the pyne run reference and profile_path in the ScriptRunner reference.
New reference pages for global functions, footprint and volume_row, plus matrix.delete, the full plot() parameters and the missing request parameters.
Fixed examples that failed to run (Persistent SMA initializer, matrix.new / map.new / chart.point calls, missing imports, conditional plot(), na checks, enum arguments, lookahead passed positionally as gaps, and more).
Corrected descriptions: lookahead_on as the period built so far, strategy.close fill timing, numeric na as a native NaN, the closed-bar rule and source priority of currency rates, the current security process model and extra-field number parsing.
The FreqTrade signal pattern no longer derives entry signals from closed trades.
The edge profile's class and method rules are documented, with an example and the equivalent @method spelling; the function isolation page describes how state reaches a class-body method.
The contributing guide covers the call-site routing and registry steps for new lib functions.