Skip to content

chore: final FOSS Hack 2026 polish on active endpoints#1192

Open
LuckyAnsari22 wants to merge 1 commit intomarketcalls:mainfrom
LuckyAnsari22:chore/final-fosshack-polish
Open

chore: final FOSS Hack 2026 polish on active endpoints#1192
LuckyAnsari22 wants to merge 1 commit intomarketcalls:mainfrom
LuckyAnsari22:chore/final-fosshack-polish

Conversation

@LuckyAnsari22
Copy link
Copy Markdown
Contributor

@LuckyAnsari22 LuckyAnsari22 commented Mar 28, 2026

FOSS Hack 2026 Contribution 🚀

This Pull Request acts as the final maintainability polish for the OpenAlgo ecosystem, specifically targeting database ingestion vulnerabilities and documenting the outermost REST API utilities. It builds upon the global error handling refactor and standardization schemas implemented over the past month.

🛠️ Key Changes

  1. Angel Master Contract DB Fix (

broker/angel/database/master_contract_db.py
)

Found a fragile try/except block where Bulk SQL Inserts and Pandas JSON schema parsing failures were being natively swallowed by simple logger.info() and logger.error() strings without context.
Hardened this pipeline by injecting standard logger.exception() structures so failed database synchronizations actually expose their crash stack traces to the system admins.
2. OpenAlgo Endpoint Documentation (

restx_api/market_holidays.py
&

broker/angel/api/funds.py
)

Standardized the internal

get_margin_data()
fetching logic for Angel Broking with PEP-compliant Google-style docstrings, specifically documenting how OpenAlgo dynamically calculates collateral natively versus utilized payout.
Upgraded the documentation schema for the native

MarketHolidays
REST controller resolving endpoint descriptions.
✅ Checklist
Database insertion failures now log full diagnostic logger.exception data instead of failing silently.
Margin and Holiday API controllers adhere to OpenAlgo's Google-style document schemas.
Tested locally without breaking legacy REST consumers.


Summary by cubic

Hardened DB ingestion error handling and improved REST docs to make failures visible and API behavior clearer. Stack traces are now logged for bulk insert and master contract download failures, and endpoint docstrings describe collateral calculation and response shapes.

  • Bug Fixes

    • Switched to logger.exception for bulk insert and master contract download failures to log full stack traces.
  • Documentation

    • Added Google-style docstring to get_margin_data() detailing dynamic collateral calculation and return schema.
    • Expanded MarketHolidays.post docstring to describe behavior, weekend handling, and JSON response format.

Written for commit c2031b8. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="broker/angel/api/funds.py">

<violation number="1" location="broker/angel/api/funds.py:25">
P2: Docstring promises `{}` on failure/parse failure, but uncaught JSON and float parsing paths can raise exceptions instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread broker/angel/api/funds.py
auth_token (str): JWT or session string provided natively by Angel login.

Returns:
dict: Standardized payload containing available cash, collateral, m2m, and utilized debits matching OpenAlgo dictionary schemas exactly. Or returns an empty {} dict on complete failure or parse failure.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 28, 2026

Choose a reason for hiding this comment

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

P2: Docstring promises {} on failure/parse failure, but uncaught JSON and float parsing paths can raise exceptions instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At broker/angel/api/funds.py, line 25:

<comment>Docstring promises `{}` on failure/parse failure, but uncaught JSON and float parsing paths can raise exceptions instead.</comment>

<file context>
@@ -12,7 +12,18 @@
+        auth_token (str): JWT or session string provided natively by Angel login.
+
+    Returns:
+        dict: Standardized payload containing available cash, collateral, m2m, and utilized debits matching OpenAlgo dictionary schemas exactly. Or returns an empty {} dict on complete failure or parse failure.
+    """
     api_key = os.getenv("BROKER_API_KEY")
</file context>
Suggested change
dict: Standardized payload containing available cash, collateral, m2m, and utilized debits matching OpenAlgo dictionary schemas exactly. Or returns an empty {} dict on complete failure or parse failure.
dict: Standardized payload containing available cash, collateral, m2m, and utilized debits matching OpenAlgo dictionary schemas exactly. Returns {} when response data is absent; request/parse/conversion errors may raise.
Fix with Cubic

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