Skip to content

perf: limit rsi signal to trailing window#8

Open
christianarriaga1234-coder wants to merge 1 commit into
Dragoon4002:mainfrom
christianarriaga1234-coder:perf/rsi-tail-window
Open

perf: limit rsi signal to trailing window#8
christianarriaga1234-coder wants to merge 1 commit into
Dragoon4002:mainfrom
christianarriaga1234-coder:perf/rsi-tail-window

Conversation

@christianarriaga1234-coder

Copy link
Copy Markdown

Summary

Refs #2.

This PR removes unnecessary full-history work from rsi_signal. The RSI calculation only needs the latest period price changes, so the function now scans just that trailing window instead of walking every price on each call and then slicing back to the same last period values.

Type

  • Performance improvement
  • Tests

Changes

  • Limit rsi_signal gain/loss accumulation to prices[-period-1:] semantics.
  • Preserve the previous signal/detail output for long histories.
  • Preserve the existing warmup behavior.
  • Add focused regression coverage comparing the optimized path against the legacy full-history calculation.

Benchmark

Synthetic 10,000-price input, 20,000 calls, direct Python runtime:

  • Old full-history scan: 69.610807s
  • New trailing-window scan: 0.124175s
  • Speedup: 560.59x

The output equality assertion passed before timing.

Testing

  • Direct regression assertions passed via bundled Python runtime.
  • python -m py_compile app/strategies/quant_algos/mean_reversion_algos.py shared/tests/test_mean_reversion_algos.py
  • git diff --check
  • Full pytest suite not run because this checkout does not have the full dependency stack installed.

Checklist

  • No secrets, API keys, or private keys committed
  • No schema changes
  • Existing public function signature preserved

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@christianarriaga1234-coder is attempting to deploy a commit to the dragoon4002's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant