Skip to content

♻️ core 잔여 지표 nullable 입력 전환#19

Merged
mingi3314 merged 4 commits into
mainfrom
core-nullable-remaining-indicators
Apr 27, 2026
Merged

♻️ core 잔여 지표 nullable 입력 전환#19
mingi3314 merged 4 commits into
mainfrom
core-nullable-remaining-indicators

Conversation

@mingi3314
Copy link
Copy Markdown
Collaborator

@mingi3314 mingi3314 commented Apr 24, 2026

요약

  • 이 PR은 #18 위에 쌓인 stacked PR입니다. 리뷰는 core-remove-dense-adapters 대비로 봐주시면 됩니다.
  • core에 남아 있던 마지막 dense public indicator API를 nullable 입력 계약으로 전환해, 공개 surface 기준 nullable 마이그레이션을 마무리합니다.
  • rolling extrema helper까지 같은 규칙으로 정리해서, 이제 core의 공개 API에는 &[f64] 기반 indicator entrypoint가 남지 않도록 맞춥니다.

변경 사항

  • mom, roc, psl, cci, mfi를 nullable 입력 기준으로 전환합니다.
  • aroon, aroonosc, willr, pchan, stochf, stochs, ichimoku를 nullable extrema/window semantics에 맞게 전환합니다.
  • core/src/utils.rsrolling_max_min, rolling_argmax_argmin, rolling_midpoint를 full valid window를 요구하는 nullable helper로 정리합니다.
  • stochrsi 경로를 새 nullable extrema helper에 맞게 정리합니다.
  • 공개 surface에서 역할이 끝난 dense utility 흔적을 숨기고, 마지막 test-only dense helper는 테스트 내부 인라인으로 정리합니다.

리뷰 포인트

  • rolling extrema 계열이 gap이 포함된 window를 valid 값으로 취급하지 않는지
  • lag/pairwise 기반 indicator가 series를 압축하지 않고 aligned output을 유지하는지
  • 이번 PR 이후 core 공개 API에 &[f64] 기반 indicator가 더 이상 남지 않는지
  • stoch*, aroon*, ichimoku, cci, mfi가 대표적인 확인 포인트입니다.

범위 외

  • plugin/polars nullable adapter 마이그레이션은 여전히 후속 작업입니다.
  • 이번 PR은 core 공개 API와 helper semantics 정리에 집중하며, 별도의 성능 최적화 패스는 포함하지 않습니다.

테스트 계획

  • cargo fmt --package techr-core --check
  • cargo test -p techr-core
  • rg '^pub fn .*\\[f64\\]' core/src 결과 없음 확인

Copy link
Copy Markdown
Collaborator Author

mingi3314 commented Apr 24, 2026

@mingi3314 mingi3314 mentioned this pull request Apr 24, 2026
2 tasks
@mingi3314 mingi3314 changed the title Finish nullable migration for remaining core indicators ♻️ core 잔여 지표 nullable 입력 전환 Apr 24, 2026
@mingi3314 mingi3314 marked this pull request as ready for review April 24, 2026 06:26
@mingi3314 mingi3314 requested a review from sjquant April 24, 2026 06:26
@mingi3314 mingi3314 self-assigned this Apr 24, 2026
@alphaprime-dev-discord
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@sjquant sjquant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

[CCI]
200k all-Some release 벤치에서 CCI가 main 1.49ms에서 PR #19 8.24ms로 약 5.5배 느려졌습니다. 현재 구현은 각 출력 인덱스마다 Vec::with_capacity(period)를 만들고 window 값을 복사한 뒤 합계와 평균편차를 계산합니다. nullable strict semantics는 유지하되 window slice를 두 번 순회해서 valid 여부/sum과 mean deviation을 계산하거나, 고정 버퍼를 재사용하면 per-row heap allocation 없이 기존 구조에 가깝게 줄일 수 있습니다.

[PSL]
PSL은 main의 단일 rolling count 루프가 PR #19에서 positive_changes 전체 벡터 생성, rolling_sum_strict 전체 스캔, 결과 변환 스캔으로 바뀌면서 0.32ms에서 0.78ms로 약 2.5배 느려졌습니다. nullable gap 처리는 change valid_count와 positive count를 한 루프에서 유지하고, 빠지는 change를 closes[i - period + 1]/closes[i - period]로 제거하면 중간 벡터와 반복 스캔 없이 보존할 수 있습니다.

[MFI]
MFI는 all-Some 200k 벤치에서 main 1.15ms에서 PR #19 1.70ms로 약 1.5배 느려졌습니다. 현재는 typical price, positive/negative money flow, 두 rolling sum 결과를 모두 materialize한 뒤 마지막에 다시 나눗셈을 합니다. strict-window nullable 처리는 money flow의 pos/neg rolling sums와 valid_count를 한 흐름에서 유지하는 방식으로도 가능해서, 전체 벡터 여러 개와 추가 패스를 줄일 수 있습니다.

@mingi3314
Copy link
Copy Markdown
Collaborator Author

mingi3314 commented Apr 27, 2026

@sjquant
체크 감사합니다! 코멘트에서 남겨주신 문제점 수정해두었습니다 (b3621a1)

  • CCI: 출력 인덱스마다 생성하던 per-window Vec allocation을 제거하고, rolling sum/valid_count로 strict window를 판단한 뒤 valid window에서만 mean deviation을 계산하도록 변경했습니다.
  • PSL: positive_changes 중간 벡터, rolling_sum_strict 전체 스캔, 결과 변환 스캔을 제거하고 change valid_count/positive count를 한 루프에서 유지하도록 변경했습니다.
  • MFI: positive/negative money flow 벡터와 두 rolling sum 결과 materialization을 제거하고, pos/neg rolling sums와 valid_count를 한 흐름에서 유지하도록 변경했습니다.

Copy link
Copy Markdown
Collaborator

@sjquant sjquant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

Copy link
Copy Markdown
Collaborator Author

mingi3314 commented Apr 27, 2026

Merge activity

  • Apr 27, 2:16 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 27, 2:23 AM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 27, 2:24 AM UTC: @mingi3314 merged this pull request with Graphite.

@mingi3314 mingi3314 changed the base branch from core-remove-dense-adapters to graphite-base/19 April 27, 2026 02:21
mingi3314 added a commit that referenced this pull request Apr 27, 2026
## 요약
- 이 PR은 `#17` 위에 쌓인 stacked PR입니다. 리뷰는 `core-nullable-composites` 대비로 봐주시면 됩니다.
- 남아 있던 dense-to-nullable bridge helper인 `ema_dense`, `rsi_dense`를 제거하고, 마지막 adapter 의존 indicator를 직접 nullable 입력 계약으로 전환합니다.
- 하위 PR들에서 이미 정리한 nullable semantics를 그대로 재사용하면서, dense adapter 층만 걷어내는 좁은 범위의 cleanup입니다.

## 변경 사항
- `erbull`, `erbear`, `cv`, `stochrsi`를 `&[Option<f64>]` 입력 기준으로 전환합니다.
- 각 indicator가 `ema`, `rsi` 같은 nullable 본체를 직접 사용하도록 정리합니다.
- `ema_dense`, `rsi_dense`를 제거합니다.
- gap 전파와 재개 동작이 기존 nullable contract를 그대로 따르는지 확인하는 테스트를 보강합니다.

## 리뷰 포인트
- touched indicator가 dense adapter 없이도 동일한 aligned nullable semantics를 유지하는지
- `EMA`/`RSI` 기반 파생 지표가 gap 이후 조기 emission 없이 기존 contract를 그대로 따르는지
- `core` 내부에 `_dense` adapter가 더 이상 남지 않는지

## 범위 외
- 남아 있던 dense public indicator API의 최종 nullable 전환은 상위 PR `#19`에서 다룹니다.
- `plugin/polars` nullable adapter 마이그레이션은 이번 stack 범위 밖입니다.

## 테스트 계획
- [x] `cargo fmt --package techr-core --check`
- [x] `cargo test -p techr-core`
@mingi3314 mingi3314 changed the base branch from graphite-base/19 to main April 27, 2026 02:22
@mingi3314 mingi3314 force-pushed the core-nullable-remaining-indicators branch from b3621a1 to 0a5645b Compare April 27, 2026 02:23
@mingi3314 mingi3314 merged commit e71b09e into main Apr 27, 2026
1 check passed
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.

2 participants