Indicator Calculation

Rez's Indicator Engine is built for mathematical precision. This section details the algorithms used to transform raw Binance OHLCV data into actionable technical signals.

Data Pre-processing

Before any calculation, raw data is normalized:

  1. Filtering: Only timestamp, open, high, low, close, and volume are retained.

  2. Casting: Prices are cast to float64 for high-precision arithmetic.

  3. Time-Normalization: All timestamps are converted to UTC to ensure consistency across assets.

The Warmup Algorithm

Recursive indicators like the Exponential Moving Average (EMA) and Relative Strength Index (RSI) depend on previous values. To prevent "cold start" errors where the initial value is just the first price point, Rez uses a 3x Warmup Rule.

Lfetch=max(100,Nresults×3)L_{fetch} = \max(100, N_{results} \times 3)

Where:

  • Lfetch is the number of candles fetched.

  • Nresults is the number of indicator values the agent requested.

Rationale

By fetching three times the required data, the recursive calculation has sufficient "burn-in" time. For an EMA with a period of 20, the weighting of the first (and most inaccurate) data point is reduced significantly by the time the latest candle is reached.

Specific Implementations

1. Exponential Moving Average (EMA)

Rez uses the standard exponential decay formula:

EMAt=Pt×α+EMAt1×(1α)EMA_t = P_t \times \alpha + EMA_{t-1} \times (1 - \alpha) α=2period+1\alpha = \frac{2}{period + 1}

2. Relative Strength Index (RSI)

Calculated using the Wilder's smoothing method via pandas-ta.

  1. Calculate price change: Dt=PtPt1D_t = P_t - P_{t-1}

  2. Split into gains UU and losses DD.

  3. Relative Strength RSRS = AvgGainAvgLoss\frac{AvgGain}{AvgLoss}

  4. RSI=100(1001+RS)RSI = 100 - (\frac{100}{1 + RS}).

3. Precision Management

To keep the LLM context lean, all calculated values are rounded to 4 decimal places. This maintains enough sensitivity for technical analysis while avoiding token bloat from unnecessary floating-point precision.

Vclean=round(Vraw,4)V_{clean} = \text{round}(V_{raw}, 4)

Last updated

Was this helpful?