Skip to main content

to_tpo_profiles

Function to_tpo_profiles 

Source
pub fn to_tpo_profiles(
    bars: &[Bar],
    config: &TPOConfig,
    clock: &BarClock,
) -> Vec<TPOProfile>
Expand description

Transform bars into TPO profiles

Sessions are the trading days of clock: the exchange sessions it carries, or calendar days in its time zone, split further at the moves between extended and regular hours with config.split_sessions and combined over config.composites. A session’s periods are whole multiples of config.period_minutes, or of the clock’s interval when longer, since its open: that of its trading day with intraday bars and trading hours, or of its stretch of extended or regular hours when split, whatever time its first bar has. Calendar days, daily and longer bars and bars split off outside the hours count from their first bar, since their open is not known. A gap leaves empty periods, and each period places one letter on every row its bars touched. The initial balance covers the bars that open within config.initial_balance_minutes of the same instant.

Rows are config.tick_size widened so the bars cover at most about 1,000 rows (see TPOProfile::tick_size). With config.instrument_tick rows are whole ticks grouped from a multiple of the row, and each row’s price is its lowest tick. Bars with a non-finite high or low or an inverted range are skipped.

§Arguments

  • bars - Source OHLCV bars
  • config - TPO configuration
  • clock - Interval and calendar of the bars, such as the chart’s Chart::bar_clock

§Returns

Vector of TPO profiles, one per session