Skip to content

Fix/streamlit exchange timing segment error#143

Closed
PradeepJaiswar wants to merge 3 commits intomasterfrom
fix/streamlit-exchange-timing-segment-error
Closed

Fix/streamlit exchange timing segment error#143
PradeepJaiswar wants to merge 3 commits intomasterfrom
fix/streamlit-exchange-timing-segment-error

Conversation

@PradeepJaiswar
Copy link
Copy Markdown
Contributor

Summary

live_depth_usdinr.py fails on expiry day: The expiry="current_month"
filter returns no results on or after the contract's expiry date. Removed
the filter so all available contracts are fetched, and the existing
sort-by-expiry logic picks the nearest active contract automatically.

svishi added 2 commits March 27, 2026 10:12
…ncy futures in Streamlit

Three bugs caused Streamlit examples to fail while CLI equivalents worked fine:

1. ExchangeTimingData AttributeError (Market Holidays)
   ExchangeTimingData objects were being treated as dicts. Replaced the
   combined getattr/e.get() one-liner with explicit isinstance checks
   for str, dict, and object types.

2. MCX Crude Spread returned 0 results
   get_futures_sorted() hardcoded segments="FO" (NSE equity), but MCX
   commodity futures live in the "COMM" segment. Added a `segment`
   parameter to get_futures_sorted() (default "FO" for backward
   compatibility) and passed segment="COMM" for the MCX call.

3. Currency Futures Spread returned 0 results
   Same issue — currency futures use segments="CURR", not "FO".
   Passed segment="CURR" for both NSE and BSE fallback calls.

Root cause in all cases: CLI scripts called search_instrument() directly
with the correct segment, while the Streamlit app used the shared helper
get_futures_sorted() which had the segment hardcoded to "FO".
Added current month expiry
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.

3 participants