Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interactive_examples/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def contango_label(spread):
c1, c2, c3 = st.columns([2, 1, 1])
query = c1.text_input("Search query", value="NIFTY")
exch = c2.selectbox("Exchange", ["NSE", "BSE", "MCX"])
exact = c3.checkbox("Exact underlying match", value=True,
exact = c3.checkbox("Exact underlying match", value=False,
help="Filter strictly by underlying_symbol to avoid e.g. NIFTYNXT50 when searching NIFTY")

if st.button("🔍 Search", type="primary"):
Expand Down
10 changes: 7 additions & 3 deletions interactive_examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def get_futures_sorted(
query: str,
exchange: str = "NSE",
exact_symbol: bool = False,
segment: str = "FO",
segment: str = None,
):
"""
Search for futures contracts and return them sorted by expiry (nearest first).
Expand All @@ -170,12 +170,16 @@ def get_futures_sorted(
matches *query* (case-insensitive) are returned — useful when searching
'NIFTY' to avoid picking up NIFTYNXT50, BANKNIFTY, etc.

Use segment="COMM" for MCX commodity futures (e.g. CRUDEOIL, NATURALGAS).
Use segment="FO" (default) for NSE/BSE equity futures.
The segment is derived from *exchange* when not given explicitly:
MCX commodities (e.g. CRUDEOIL, NATURALGAS) use "COMM"; NSE/BSE equity
futures use "FO". Pass segment explicitly to override (e.g. "CURR" for
currency futures on NSE/BSE).

Returns list of instrument dicts, each with keys like:
instrument_key, trading_symbol, expiry, lot_size, underlying_symbol
"""
if segment is None:
segment = "COMM" if exchange.upper() == "MCX" else "FO"
response = search_instrument(
api_client,
query,
Expand Down
Loading