@@ -167,6 +167,62 @@ class TestDerivatives(TestCase):
167167 def setUp (self ):
168168 setup_test (self )
169169
170+ def test_derivatives_raw_futures (self ):
171+ """Test fetching futures derivatives data"""
172+ symbol = "NIFTY"
173+ from_date = date (2026 , 3 , 9 )
174+ to_date = date (2026 , 3 , 16 )
175+ expiry_date = date (2026 , 3 , 30 )
176+ instrument_type = "FUTIDX"
177+
178+ raw = nse .derivatives_raw (symbol , from_date , to_date , expiry_date , instrument_type ,
179+ strike_price = None , option_type = None )
180+ assert len (raw ) > 0
181+ # Verify required fields for futures
182+ assert 'FH_TIMESTAMP' in raw [0 ]
183+ assert 'FH_SYMBOL' in raw [0 ]
184+ assert 'FH_CLOSING_PRICE' in raw [0 ]
185+ assert raw [0 ]['FH_SYMBOL' ] == symbol
186+
187+ def test_derivatives_raw_options (self ):
188+ """Test fetching options derivatives data"""
189+ symbol = "NIFTY"
190+ from_date = date (2026 , 3 , 9 )
191+ to_date = date (2026 , 3 , 16 )
192+ expiry_date = date (2026 , 3 , 30 )
193+ instrument_type = "OPTIDX"
194+ strike_price = 23000
195+ option_type = "PE"
196+
197+ raw = nse .derivatives_raw (symbol , from_date , to_date , expiry_date , instrument_type ,
198+ strike_price = strike_price , option_type = option_type )
199+ assert len (raw ) > 0
200+ # Verify required fields for options
201+ assert 'FH_TIMESTAMP' in raw [0 ]
202+ assert 'FH_OPTION_TYPE' in raw [0 ]
203+ assert 'FH_STRIKE_PRICE' in raw [0 ]
204+ assert raw [0 ]['FH_OPTION_TYPE' ] == option_type
205+ assert raw [0 ]['FH_STRIKE_PRICE' ] == strike_price
206+
207+ def test_derivatives_df (self ):
208+ """Test fetching derivatives as dataframe"""
209+ symbol = "NIFTY"
210+ from_date = date (2026 , 3 , 9 )
211+ to_date = date (2026 , 3 , 16 )
212+ expiry_date = date (2026 , 3 , 30 )
213+ instrument_type = "OPTIDX"
214+ strike_price = 23000
215+ option_type = "PE"
216+
217+ df = nse .derivatives_df (symbol , from_date , to_date , expiry_date , instrument_type ,
218+ strike_price = strike_price , option_type = option_type )
219+ assert len (df ) > 0
220+ # Verify required columns for options
221+ assert 'DATE' in df .columns
222+ assert 'EXPIRY' in df .columns
223+ assert 'STRIKE PRICE' in df .columns
224+ assert 'OPTION TYPE' in df .columns
225+ assert 'CLOSE' in df .columns
170226
171227class TestIndexHistory (TestCase ):
172228 def setUp (self ):
0 commit comments