Skip to content

perf: reduce stochastic signal window scans#5

Open
Godel-Smith wants to merge 1 commit into
Dragoon4002:mainfrom
Godel-Smith:perf/stochastic-signal-windowing-2
Open

perf: reduce stochastic signal window scans#5
Godel-Smith wants to merge 1 commit into
Dragoon4002:mainfrom
Godel-Smith:perf/stochastic-signal-windowing-2

Conversation

@Godel-Smith

@Godel-Smith Godel-Smith commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Reduces extra rolling-window scans in stochastic_signal. The function only uses the trailing d_period %K values to compute %D, so this PR computes those trailing windows directly instead of scanning k_period windows and discarding most of them.

If this ranks for payout, I can provide payment details privately after acceptance.

Type

  • Bug fix
  • New strategy
  • New feature
  • Refactor
  • Documentation
  • Tests
  • Chore / dependency update

Related Issue

Refs #2

Changes

  • Avoids computing unused %K windows inside stochastic_signal.
  • Preserves previous %K/%D output for the default d_period <= k_period path.
  • Preserves the existing fallback behavior when d_period > k_period.
  • Adds a focused regression test for both cases.

Benchmark

Synthetic 1000-candle input, best of 5 repeats, run with direct file import to avoid pulling app dependencies:

  • k_period=14, d_period=3: old 0.508540s, new 0.150167s for 10,000 calls: 3.39x speedup
  • k_period=120, d_period=3: old 4.531116s, new 0.154038s for 2,000 calls: 29.42x speedup
  • Output equality check passed for both benchmark cases.

Testing

  • pytest tests/ passes locally
  • New tests added for new code
  • Manually tested (describe how):
    • Focused local verification command passed
    • git diff --cached --check
    • benchmark script described above

Not run:

  • Full pytest tests/ because this repo ignores tests/ as private/internal and the local environment does not have the full app dependency stack installed.

Checklist

  • No secrets, API keys, or private keys committed
  • Type hints on all new public functions
  • docs/connections/service-map.md updated (if adding a new call path)
  • docs/architecture/data-model.md updated (if changing DB schema)
  • New strategy registered in app/strategies/signals.py (if adding a strategy)
  • New strategy added to strategy index in app/onchain_logger.py (if adding a strategy)
  • Breaking changes documented in PR description

Screenshots (if UI change)

N/A

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@Godel-Smith 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