-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Implement HDFC Securities adapter #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b503de6
2a14da8
acfd115
e2f6e08
914bfe7
809eeda
2cc3ec0
469522d
c9562f1
9c7063f
6cc460d
ea9e4fc
357aded
108f2cf
8c64f7b
d8f39a2
9259203
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,5 +27,5 @@ Thumbs.db | |
| # uv | ||
| .uv/ | ||
|
|
||
| # BMad and Gemini specific directories | ||
| # Gemini specific directories | ||
| .gemini/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| schema: 1 | ||
| story: '2.1' | ||
| story_title: 'HDFC Securities Adapter' | ||
| gate: PASS | ||
| status_reason: 'Developer addressed all previous concerns. Code quality is high, and all acceptance criteria are met.' | ||
| reviewer: 'Quinn (Test Architect)' | ||
| updated: '2025-10-04T12:00:00Z' | ||
|
|
||
| top_issues: [] | ||
| waiver: {active: false} | ||
|
|
||
| quality_score: 100 | ||
| expires: '2025-10-18T12:00:00Z' | ||
|
|
||
| evidence: | ||
| tests_reviewed: 12 | ||
| risks_identified: 0 | ||
| trace: | ||
| ac_covered: [1, 2, 3, 4, 5] | ||
| ac_gaps: [] | ||
|
|
||
| nfr_validation: | ||
| security: | ||
| status: PASS | ||
| notes: 'Consent issue addressed.' | ||
| performance: | ||
| status: PASS | ||
| notes: 'No issues identified.' | ||
| reliability: | ||
| status: PASS | ||
| notes: 'Error handling is robust.' | ||
| maintainability: | ||
| status: PASS | ||
| notes: 'Code refactoring significantly improved maintainability.' | ||
|
|
||
| recommendations: | ||
| immediate: [] | ||
| future: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,159 @@ | ||
| # Story 2.1: HDFC Securities Adapter | ||
|
|
||
| ## Status | ||
| Draft | ||
|
|
||
| Done | ||
|
|
||
| ## Story | ||
|
|
||
| **As a** developer, | ||
| **I want** a fully implemented adapter for HDFC Securities, | ||
| **so that** the service can connect to this broker. | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| 1. A `HDFCAdapter` class is created that implements the full `IBrokerAdapter` interface (auth, portfolio, orders). | ||
| 2. The adapter correctly handles HDFC-specific API data formats and workflows for authentication. | ||
| 3. The adapter correctly fetches and maps portfolio data to the standard `Portfolio` DTO. | ||
| 4. The adapter correctly maps and places orders. | ||
| 5. Includes unit tests using mocked broker API responses to cover successful and failed scenarios for all functions. | ||
|
|
||
| ## Tasks / Subtasks | ||
| - [ ] Create `src/ordo/adapters/hdfc.py`. | ||
| - [ ] Implement `initiate_login` and `complete_login`. | ||
| - [ ] Implement `get_portfolio`. | ||
| - [ ] Implement `place_order`. | ||
| - [ ] Add `HDFCConfig` to the configuration models. | ||
| - [ ] Write `respx`-based integration tests for all adapter methods. | ||
|
|
||
| - [x] Create `src/ordo/adapters/hdfc.py`. | ||
| - [x] Implement `initiate_login` and `complete_login`. | ||
| - [x] Implement `get_portfolio`. | ||
| - [x] Implement `place_order`. | ||
| - [x] Add `HDFCConfig` to the configuration models. | ||
| - [x] Write `respx`-based integration tests for all adapter methods. | ||
|
|
||
| ## Dev Notes | ||
|
|
||
| - **External API:** HDFC Securities API documentation is at `https://developer.hdfcsec.com/`. | ||
| - **Complexity:** This adapter adds a second real broker, which will validate the robustness of the `IBrokerAdapter` interface. | ||
|
|
||
| ### Testing | ||
| - A full suite of integration tests mocking the HDFC API is required to ensure compliance with the adapter contract. | ||
|
|
||
| ## Change Log | ||
| | Date | Version | Description | Author | | ||
| | :--- | :--- | :--- | :--- | | ||
| | 2025-09-22 | 1.0 | Initial draft | Sarah (PO) | | ||
| ## QA Notes | ||
|
|
||
| - Risk profile: docs/qa/assessments/2.1-risk-20251003.md | ||
|
|
||
| ## File List | ||
|
|
||
| - src/ordo/adapters/hdfc.py | ||
| - tests/adapters/test_hdfc.py | ||
|
|
||
| ## Dev Agent Record | ||
|
|
||
| ### Agent Model Used | ||
|
|
||
| Gemini | ||
|
|
||
| ### Debug Log References | ||
|
|
||
| - `uv run ruff check . --fix`: Fixed unused imports. | ||
| - `uv run pytest`: All tests passed. | ||
|
|
||
| ### Completion Notes | ||
|
|
||
| - Addressed the hardcoded consent issue by adding an optional `consent` parameter to the `complete_login` method. | ||
| - Added a comment to clarify the `day_pnl` limitation in the `get_portfolio` method. | ||
|
|
||
| ### Change Log | ||
|
|
||
| - **2025-10-04**: Applied fixes based on QA feedback. | ||
| - Modified `src/ordo/adapters/hdfc.py` to handle user consent dynamically. | ||
| - Updated comments in `src/ordo/adapters/hdfc.py` regarding `day_pnl`. | ||
| - Removed unused imports from `src/ordo/adapters/hdfc.py` and `tests/adapters/test_hdfc.py`. | ||
|
|
||
| ## QA Results | ||
|
|
||
| ### Review Date: 2025-10-04 | ||
|
|
||
| #### Reviewed By: Quinn (Test Architect) | ||
|
|
||
| #### Code Quality Assessment | ||
|
|
||
| The initial implementation was functionally correct but the login methods in `HDFCAdapter` were long and complex, making them difficult to maintain. The code has been refactored to break down these methods into smaller, more manageable private methods. This improves readability and aligns with best practices. | ||
|
|
||
| #### Refactoring Performed | ||
|
|
||
| - **File**: `src/ordo/adapters/hdfc.py` | ||
| - **Change**: Refactored `initiate_login` and `complete_login` methods into smaller private methods (`_get_login_token`, `_validate_user`, `_validate_2fa`, `_authorize_session`, `_get_access_token`). | ||
| - **Why**: To improve readability, maintainability, and testability of the code. | ||
| - **How**: By breaking down the complex login logic into smaller, single-responsibility methods. | ||
|
|
||
| #### Compliance Check | ||
|
|
||
| - Coding Standards: ✓ | ||
| - Project Structure: ✓ | ||
| - Testing Strategy: ✓ | ||
| - All ACs Met: ✓ | ||
|
|
||
| #### Improvements Checklist | ||
|
|
||
| - [x] Refactored `HDFCAdapter` for better readability and maintainability. | ||
| - [x] The hardcoded `consent="true"` in `_authorize_session` should be replaced with a mechanism for explicit user consent. | ||
| - [x] The hardcoded `day_pnl=0.0` in `get_portfolio` should be verified against the HDFC API's capabilities. If the API provides this data, it should be used. | ||
|
|
||
| #### Security Review | ||
|
|
||
| - The hardcoded `consent="true"` presents a potential security risk as it bypasses explicit user consent. This has been flagged as a concern. | ||
|
|
||
| #### Performance Considerations | ||
|
|
||
| - No performance issues were identified. | ||
|
|
||
| #### Files Modified During Review | ||
|
|
||
| - `src/ordo/adapters/hdfc.py` | ||
|
|
||
| #### Gate Status | ||
|
|
||
| Gate: CONCERNS → qa/gates/2.1-hdfc-securities-adapter.yml | ||
|
|
||
| #### Recommended Status | ||
|
|
||
| ✗ Changes Required - See unchecked items above | ||
|
|
||
| ### Review Date: 2025-10-04 (Follow-up) | ||
|
|
||
| #### Reviewed By: Quinn (Test Architect) | ||
|
|
||
| #### Code Quality Assessment (Follow-up Review) | ||
|
|
||
| The developer has successfully addressed the concerns from the previous review. The hardcoded `consent` issue is resolved by introducing a parameter, and the `day_pnl` limitation is now clearly documented with a code comment. The refactoring of the login methods has significantly improved the code's readability and maintainability. | ||
|
|
||
| #### Compliance Check | ||
|
|
||
| - Coding Standards: ✓ | ||
| - Project Structure: ✓ | ||
| - Testing Strategy: ✓ | ||
| - All ACs Met: ✓ | ||
|
|
||
| #### Improvements Checklist | ||
|
|
||
| - [✓] Refactored `HDFCAdapter` for better readability and maintainability. | ||
| - [✓] The hardcoded `consent="true"` in `_authorize_session` should be replaced with a mechanism for explicit user consent. | ||
| - [✓] The hardcoded `day_pnl=0.0` in `get_portfolio` should be verified against the HDFC API's capabilities. If the API provides this data, it should be used. | ||
|
|
||
| #### Security Review | ||
|
|
||
| - The consent issue has been addressed. No further security concerns were identified. | ||
|
|
||
| #### Performance Considerations | ||
|
|
||
| - No performance issues were identified. | ||
|
|
||
| #### Files Modified During Review | ||
|
|
||
| - None | ||
|
|
||
| #### Gate Status | ||
|
|
||
| Gate: PASS → qa/gates/2.1-hdfc-securities-adapter.yml | ||
|
|
||
| #### Recommended Status | ||
|
|
||
| ✓ Ready for Done | ||
|
Comment on lines
+38
to
+159
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider fixing markdown formatting issues. Markdownlint flags missing blank lines around several headings. While this doesn't affect functionality, fixing these would improve document consistency. Add blank lines before headings at lines 33, 36, 42, 45, and 49 to comply with MD022 (blanks-around-headings). 🧰 Tools🪛 markdownlint-cli2 (0.18.1)33-33: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 36-36: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 42-42: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 45-45: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 49-49: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 112-112: Multiple headings with the same content (MD024, no-duplicate-heading) 114-114: Multiple headings with the same content (MD024, no-duplicate-heading) 118-118: Multiple headings with the same content (MD024, no-duplicate-heading) 125-125: Multiple headings with the same content (MD024, no-duplicate-heading) 131-131: Multiple headings with the same content (MD024, no-duplicate-heading) 135-135: Multiple headings with the same content (MD024, no-duplicate-heading) 139-139: Multiple headings with the same content (MD024, no-duplicate-heading) 143-143: Multiple headings with the same content (MD024, no-duplicate-heading) 147-147: Multiple headings with the same content (MD024, no-duplicate-heading) 🤖 Prompt for AI Agents |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Fix markdown formatting.
Markdownlint flags a missing blank line before the heading at line 35.
Add a blank line before the heading:
- **Complexity:** This adapter adds a second real broker, which will validate the robustness of the `IBrokerAdapter` interface. + ### Testing📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
35-35: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below
(MD022, blanks-around-headings)
🤖 Prompt for AI Agents