Skip to content

[Fix] Issue #97 - derivatives_df() API endpoint fix#117

Merged
sevakram merged 3 commits into
masterfrom
fix/issue-97-derivatives-api
Mar 16, 2026
Merged

[Fix] Issue #97 - derivatives_df() API endpoint fix#117
sevakram merged 3 commits into
masterfrom
fix/issue-97-derivatives-api

Conversation

@sevakram
Copy link
Copy Markdown
Contributor

@sevakram sevakram commented Mar 16, 2026

Problem

Issue #97: derivatives_df() and derivatives_csv() were failing with 404 errors when fetching derivatives data.

The old API endpoint was returning 'Resource not found' errors, making it impossible to retrieve derivatives historical data.

Root Cause

NSE deprecated the old /api/historical/fo/derivatives endpoint. The library was still using this defunct endpoint which now returns 404.

Solution

  1. Updated API endpoint from /api/historical/fo/derivatives to /api/historicalOR/foCPV
  2. Added required 'year' parameter to API requests (new endpoint requirement)
  3. Added comprehensive test coverage for derivatives functionality
  4. Updated documentation with note about historical data availability

Changes

  • jugaad_data/nse/history.py: Updated endpoint URL and added year parameter
  • tests/test_nse.py: Added 3 new test methods for derivatives:
    • test_derivatives_raw_futures() - tests FUTIDX data retrieval
    • test_derivatives_raw_options() - tests OPTIDX data retrieval
    • test_derivatives_df() - tests DataFrame output
  • docs/API_REFERENCE.md: Added note about historical data availability
  • CHANGELOG.md: Documented v0.33.1 release
  • pyproject.toml: Bumped version to 0.33.1

Testing

✅ All 12 NSE tests pass (including 3 new derivative tests)
✅ Verified derivatives_df() works with current market data (NIFTY March 2026 options)
✅ Backwards compatible - no API changes for users

Notes

  • Historical data availability limited to recent periods per NSE retention policies
  • Old data (2021-2022) may not be available through new endpoint
  • This is a patch release (0.33.1) - no breaking changes

abc-git added 3 commits March 16, 2026 20:06
…ivatives to /api/historicalOR/foCPV

- NSE deprecated the old derivatives endpoint which was returning 404
- New endpoint requires 'year' parameter in request
- Adds support for current market data (futures and options)
- Fixes issue #97 where derivatives_df() was not working
- Added test_derivatives_raw_futures() - tests futures data retrieval
- Added test_derivatives_raw_options() - tests options data retrieval
- Added test_derivatives_df() - tests DataFrame output for derivatives
- All tests pass with new NSE API endpoint
- Ensures derivatives_df(), derivatives_csv(), and derivatives_raw() work correctly
- Updated API_REFERENCE.md with note about historical data availability
- Updated CHANGELOG.md with v0.33.1 release notes
- Bumped version from 0.33.0 to 0.33.1 (patch release)
- Documented API endpoint change and data retention limitations
@sevakram sevakram merged commit bdbbca2 into master Mar 16, 2026
2 checks 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