Logging & Enums

log/warn/debug/print_series/print_df plus Source/DataMode/PlotType/Timeframe enums.

log

log(message)

Print a message to the Terminal panel (green, always visible).

Use for status updates, parameter values, and general output. Accepts any value, converts to string.

Parameters

  • message (Any, default required): Value to print

Returns

None

Example

from quant_charts import log

log("Starting calculation")
log(f"Period: {self.period}, Bars: {len(df)}")
log(f"Signal count: {signals.sum()}")

warn

warn(message)

Print a warning to the Terminal panel (yellow).

Use for non-fatal issues, edge cases, or unexpected conditions.

Parameters

  • message (Any, default required): Warning message

Returns

None

Example

from quant_charts import warn
warn("Insufficient data for 200-period SMA")

print_series

print_series(series, name?, head?)

Print summary of a Series/array: shape, range, NaN count, first N values.

Works with pandas Series, numpy arrays, and PriceSeries (close, high, etc.).

Parameters

  • series (array-like, default required): Data to inspect
  • name (str, default "Series"): Label
  • head (int, default 10): Values to show

Returns

None

Example

from quant_charts import print_series, close

print_series(close, "Close Prices")
print_series(sma, "SMA(20)", head=5)
print_series(rsi > 70, "Overbought")

print_df

print_df(df, name?, head?)

Print summary of a DataFrame: shape, columns, dtypes, first N rows.

Useful for understanding what data is available in the DataFrame passed to calculate().

Parameters

  • df (DataFrame, default required): DataFrame to inspect
  • name (str, default "DataFrame"): Label
  • head (int, default 5): Rows to show

Returns

None

Example

from quant_charts import print_df

print_df(df, "Price Data")
print_df(df[['close', 'volume']], "Close & Vol")

Source

Price source enum for input.source().

Each value resolves to its corresponding price series at runtime.

Parameters

  • Source.CLOSE (enum): Closing price
  • Source.OPEN (enum): Opening price
  • Source.HIGH (enum): Highest price
  • Source.LOW (enum): Lowest price
  • Source.HL2 (enum): Median: (H+L)/2
  • Source.HLC3 (enum): Typical: (H+L+C)/3
  • Source.OHLC4 (enum): Average: (O+H+L+C)/4

Example

src = input.source(Source.CLOSE, "Price Source")

PlotType

Chart visualization styles for plot().

Parameters

  • PlotType.LINE (enum, default default): Standard line chart
  • PlotType.HISTOGRAM (enum): Vertical bars from zero line. Supports per-bar colors=.
  • PlotType.COLUMNS (enum): Vertical column bars. Supports per-bar colors=.
  • PlotType.CROSS (enum): Per-point cross marker. Supports per-point colors=.
  • PlotType.CIRCLES (enum): Per-point circle marker. Supports per-point colors=.
  • PlotType.AREA (enum): Filled area under the line
  • PlotType.STEPLINE (enum): Step/staircase line

Example

plot(data, "Momentum", plot_type=PlotType.HISTOGRAM)

Notes

  • Per-bar colors= arrays are valid only for HISTOGRAM, COLUMNS, CROSS, CIRCLES.
  • LINE / AREA / STEPLINE stay single-color (per-point coloring is not meaningful for continuous series).

Timeframe

Timeframe enum for the strategy/indicator decorator.

Sets the default execution/visibility timeframe. Users can override it per-instance via the Strategy TF pill in the chart top bar.

Parameters

  • Timeframe.S1 (enum): 1-second bars
  • Timeframe.S5 (enum): 5-second bars
  • Timeframe.S10 (enum): 10-second bars
  • Timeframe.S30 (enum): 30-second bars
  • Timeframe.M1 (enum): 1-minute bars
  • Timeframe.M5 (enum): 5-minute bars
  • Timeframe.M15 (enum): 15-minute bars
  • Timeframe.M30 (enum): 30-minute bars
  • Timeframe.H1 (enum): 1-hour bars
  • Timeframe.H4 (enum): 4-hour bars
  • Timeframe.D1 (enum): Daily bars

Example

@strategy("Scalper", timeframe=Timeframe.M1, data_mode="ohlc")