The runtime namespace provides error handling capabilities for PyneCore scripts. Use these functions to stop script execution and report error conditions.

Quick Example

from pynecore.lib import close, runtime, ta, script

@script.indicator(title="Runtime Error Example")
def main():
    sma: float = ta.sma(close, 20)
    
    if sma == 0:
        runtime.error("Invalid moving average calculation")
    
    if close < 0:
        runtime.error("Price data is corrupted")

Functions

error()

Terminates script execution with an error message.

ParameterTypeDescription
messagestrError message to display

Return type: void (raises RuntimeError)

Example:

if bar_index == 0:
    runtime.error("Script requires historical data")

Compatibility

All functions in the runtime namespace are fully implemented.