Skip to content

Add unit tests for the four-way OI flow classifier #15

Description

@Abhay512

The classifier in backend/engine/classifier.py maps an OI change plus the simultaneous price change onto a build-up type, and flows_4way() in backend/engine/ranking.py folds those into bullish/bearish rupee totals. Both are pure functions, both are central to every board, and neither has direct test coverage today.

What to do

Add backend/tests/test_classifier.py covering every branch:

OI price expected
up up long build-up
up down short build-up
down up short covering
down down long unwinding

Then cover flows_4way(): build a StockRank with known values and assert the bullish and bearish totals. backend/tests/test_oneway.py has a _rank() helper you can copy.

Acceptance

  • Every classification branch asserted, including the zero-change edge case
  • flows_4way() asserted on at least one hand-computed example
  • Runs with python -m tests.test_classifier, no market or API key needed
  • ruff check . clean

Getting started

pip install -r requirements.txt and python -m tests.test_oneway to confirm your setup. No broker subscription required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendPython engine, feed, storage or APIgood first issueWell-scoped, self-contained, a great place to starttestingTests, fixtures and harnesses

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions