Skip to content

Latest commit

 

History

History
262 lines (221 loc) · 9.21 KB

File metadata and controls

262 lines (221 loc) · 9.21 KB

C++ API Reference

Primary headers (public API):

  • headers/pnf/types.hpp
  • headers/pnf/box.hpp
  • headers/pnf/column.hpp
  • headers/pnf/chart.hpp
  • headers/pnf/trendline.hpp
  • headers/pnf/indicators.hpp
  • headers/pnf/events.hpp
  • headers/pnf/backtest.hpp
  • headers/pnf/features.hpp
  • headers/pnf/scanner.hpp
  • headers/pnf/data_adapters.hpp
  • headers/pnf/walk_forward.hpp
  • headers/pnf/visualization.hpp
  • headers/pnf/csv_loader.hpp
  • headers/pnf/version.hpp

For exhaustive symbol-level coverage generated from source, see:

Core Model

Enums

  • BoxType
  • ColumnType
  • ConstructionMethod
  • BoxSizeMethod
  • TrendLineType
  • SignalType
  • PatternType
  • EventType
  • TradeDirection
  • PositionState
  • EntryPolicy
  • ExitPolicy

Structs

  • OHLC
  • Signal
  • Pattern
  • SupportResistanceLevel
  • PriceObjective
  • TrendLinePoint
  • ChartConfig
  • IndicatorConfig
  • ColumnData
  • ChartData
  • IndicatorData
  • EventStreamConfig
  • ChartEvent
  • EventStreamSnapshot
  • BacktestConfig
  • Trade
  • EquityPoint
  • BacktestResult
  • FeatureVector
  • FeatureMatrix
  • PatternQualityScore
  • PatternQualityConfig
  • ScanConfig
  • SymbolSeries
  • ScanRow
  • BatchScanResult
  • DataAdapterOptions
  • WalkForwardConfig
  • WalkForwardWindowResult
  • WalkForwardResult

Free Helpers

  • pattern_type_to_string(PatternType)
  • is_bullish_pattern(PatternType)
  • is_bearish_pattern(PatternType)
  • event_type_to_string(EventType)
  • trade_direction_to_string(TradeDirection)
  • position_state_to_string(PositionState)

Chart Layer

Box

  • constructor: Box(price, type, marker = "")
  • price(), type(), marker()
  • set_marker(...), set_type(...)
  • to_string()

Column

  • constructor: Column(type = ColumnType::X)
  • add_box(...) (overloads)
  • remove_box(...), has_box(...)
  • get_box(...), get_box_at(...)
  • get_box_marker(...), set_box_marker(...)
  • box_count(), highest_price(), lowest_price()
  • type(), set_type(...)
  • clear(), to_string()

Chart

  • constructor: Chart(const ChartConfig&)
  • ingestion: add_data(...) (OHLC/close overloads), add_ohlc(...)
  • structure: column_count(), column(i), last_column()
  • stats: x_column_count(), o_column_count(), mixed_column_count()
  • index helpers: x_column_indices(), o_column_indices(), mixed_column_indices()
  • market state: all_prices(), config(), current_box_size()
  • bias/support checks: has_bullish_bias(), has_bearish_bias(), should_take_bullish_signals(), should_take_bearish_signals(), is_above_bullish_support(...), is_below_bearish_resistance(...)
  • lifecycle/export: clear(), to_string(), columns()

Trendline Layer

TrendLine

  • constructor with start point + box_size
  • update_end_point(...), is_broken(...), test(...), price_at_column(...)
  • type(), start_point(), end_point(), is_active(), set_active(...), was_touched(), touch_count()
  • to_string()

TrendLineManager

  • constructor: TrendLineManager(box_size)
  • mutation: update(...), process_new_column(...), check_break(...)
  • queries: active_trend_line(), all_trend_lines(), is_above_bullish_support(...), is_below_bearish_resistance(...), has_bullish_bias(), has_bearish_bias()
  • lifecycle: clear(), set_box_size(...), to_string()

Indicator Layer

Indicator Components

  • MovingAverage
  • BollingerBands
  • RSI
  • OnBalanceVolume
  • BullishPercent
  • SignalDetector
  • PatternRecognizer
  • SupportResistance
  • PriceObjectiveCalculator
  • CongestionDetector

Each component exposes:

  • configuration setters (where applicable)
  • calculate/detect/identify
  • point queries by column
  • vector accessors for computed series
  • to_string()

Indicators Aggregator

  • constructors: default + Indicators(const IndicatorConfig&)
  • configuration: configure(...), config()
  • execution: calculate(...), calculate_with_volume(...)
  • accessors for each component pointer (const + mutable)
  • exports: export_data(), export_chart_data(...)
  • summary: summary(), to_string()

Event Streaming

EventStream

  • constructor: EventStream(chart_config, indicator_config, stream_config)
  • ingestion: add_data(...) (OHLC/close overloads), add_ohlc(...)
  • event access: events(), events_copy(), consume_events()
  • state access: snapshot(), chart(), indicators()
  • lifecycle: reset()

EventStream is an additive wrapper over Chart and Indicators. It does not change chart construction behavior; it observes each incremental update and emits structured ChartEvent records for column creation, column extension, reversals, signals, patterns, objectives, support/resistance changes, and congestion detection.

Backtesting

Backtester

  • constructor: Backtester(const BacktestConfig&)
  • execution: run(data, chart_config, indicator_config)
  • configuration: config()

BacktestResult

  • trade list: trades
  • equity samples: equity_curve
  • headline metrics: final_equity, total_return, max_drawdown, win_rate, profit_factor, average_trade_pnl, exposure, sharpe_ratio
  • counts: trade_count, winning_trades, losing_trades
  • summary: to_string()

The built-in backtester consumes EventStream output, so strategy decisions are made only from events emitted after each historical bar is processed. This keeps the path close to live event processing and avoids vectorized lookahead assumptions.

Quant Scanner, ML Features, and Optimization

Feature Extraction

  • FeatureVector is the stable numeric ML row: column count, last column type, box size, reversal, trend bias, bullish percent, support/resistance distance, latest pattern type, objective distance, congestion width, SMA distance, and RSI.
  • FeatureMatrix stores column names and feature rows; use values() for row-major numeric export and to_csv() for text export.
  • extract_features(chart, indicators) reuses already-calculated indicators.
  • extract_features(chart, indicator_config) calculates indicators internally.
  • extract_feature_matrix(charts, config) exports one row per chart.
  • objective_distance(price, objective) returns signed relative distance to a target.

Pattern Quality

  • PatternQualityConfig tunes quality scoring inputs.
  • score_pattern_quality(chart, indicators, pattern, config) scores one pattern.
  • score_patterns(chart, indicators, config) scores every detected pattern.
  • Score dimensions are freshness, breakout strength, column symmetry, congestion context, support/resistance distance, trend alignment, and objective room.

Batch Scanner

  • ScanConfig combines chart config, indicator config, freshness lookback, and support/resistance tolerance.
  • SymbolSeries carries aligned OHLCV vectors for one symbol.
  • scan(symbols, config) returns a BatchScanResult with one ScanRow per symbol.
  • BatchScanResult::feature_matrix() exports scanner rows as a FeatureMatrix.
  • rank_by_bullish_percent, latest_patterns, fresh_breakouts, near_support, near_resistance, and objective_distance are post-scan filters/helpers.

Data Adapters

  • DataAdapters::is_supported(format) reports local format support.
  • DataAdapters::load, load_csv, load_metatrader_export, and load_tradingview_export return std::vector<OHLC>.
  • DataAdapters::save_csv writes OHLC data in the configured delimiter/header layout.
  • DataAdapterOptions maps timestamp, open, high, low, close, volume, delimiter, and header behavior.

Walk-Forward Optimization

  • WalkForwardConfig controls rolling train/test lengths, step size, candidate chart configs, and candidate indicator configs.
  • walk_forward_optimize(data, config) returns window-level best parameters, train/test performance, stability score, overfit warnings, and split-performance text.

Rendering and Export

AsciiRenderer

  • constructor with RenderConfig
  • render(chart), render_with_indicators(chart, indicators)
  • set_config(...), config()

SvgRenderer

  • constructor with SvgConfig
  • render(chart), render_with_indicators(chart, indicators)
  • set_config(...), config()

JsonExporter

  • constructor with JsonConfig
  • export_chart(...), export_chart_with_indicators(...), export_indicators(...)
  • set_config(...), config()

CsvExporter

  • export_columns(...)
  • export_boxes(...)
  • export_signals(...)
  • export_patterns(...)
  • export_indicator_values(...)

PlotExporter

  • to_svg(chart, indicators, config)
  • to_png(chart, indicators, config)
  • to_html(chart, indicators, config)
  • to_plotly_json(chart, indicators, config)

PlotExportConfig controls title, annotation toggles for signals/patterns/objectives/month markers/support-resistance, and PNG scale. Use these exports for reproducible reports where dashboard state is not enough.

Visualization Static Helpers

  • to_ascii(...)
  • to_svg(...)
  • to_json(...)
  • to_csv_columns(...)
  • to_csv_boxes(...)
  • to_ascii_with_indicators(...)
  • to_svg_with_indicators(...)
  • to_json_with_indicators(...)

IO and Version

CSVLoader

  • load(filename)
  • parse_datetime(date_str, format)

Version

  • Version::major
  • Version::minor
  • Version::patch
  • Version::string