Refactored Instrument Retrieval and Contract Master Logic for Improved Performance and Maintainability #125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a complete refactor of the contract master download and instrument lookup logic to enhance efficiency, maintainability, and performance.
Key Improvements:
Centralized Master Contract Download:
download_master_contract()downloads and consolidates data across all exchanges.Optimized In-Memory Filtering:
pandas.DataFrame, eliminating repeated file I/O operations.master_contract_df_symbolandmaster_contract_df_token).Cleaned and Standardized Data:
instrument_token,strike,lot_size) cast to correct types.Improved Instrument Retrieval:
get_instrument_by_symbol()get_instrument_by_token()get_instrument_for_fno()Backward Compatibility:
Instrumentobjects consistent with the previous implementation.Let me know if you'd like to include benchmarks, unit tests, or additional documentation updates before merging.