Skip to content

Commit

Permalink
added get_devsymbols_list fun in options.py (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: vardhan.negi <vardhan.negi@sunmobility.com>
  • Loading branch information
vardhannegi and vardhansunmobility authored Feb 3, 2025
1 parent f369116 commit 4821e8d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ print(de.get_option_chain(symbol="TCS", strike_price=3300, expiry_date=report_da
print(de.get_future_price(symbol="TCS", start_date=start_date, end_date=end_date))
print(de.get_future_expdate(symbol="TCS"))
print(de.get_historical_option_data(symbol="TATAMOTORS", start_date=start_date, end_date=end_date, option_type="CE", strike_price="1020", year="2024", expiry_date="30-May-2024"))
print(de.get_derivatives_symbols())

```


# Reports

### Details
Expand Down Expand Up @@ -138,4 +141,5 @@ print(rep.get_volatility_report(date=report_date, response_type="json"))
print(rep.get_fno_participant_wise_oi_data(date=report_date, response_type="json"))
print(rep.get_fno_participant_wise_volume_data(date=report_date, response_type="json"))
```

[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/pratik.anand)
2 changes: 1 addition & 1 deletion nsedt/derivatives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from nsedt.resources import constants as cns
from nsedt.utils import data_format
from nsedt.derivatives.options import (
get_option_chain, get_option_chain_expdate, get_historical_option_data)
get_option_chain, get_option_chain_expdate, get_historical_option_data,get_derivatives_symbols)
from nsedt.derivatives.futures import get_future_price, get_future_expdate

log = logging.getLogger("root")
Expand Down
18 changes: 18 additions & 0 deletions nsedt/derivatives/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@
log = logging.getLogger("root")


def get_derivatives_symbols():
"""
Args:\n
No arguments needed\n
Returns:\n
List of stock or equity symbols\n
"""
cookies = utils.get_cookies()
base_url = cns.BASE_URL
event_api = cns.UNDERLYINF_INFO

url = base_url + event_api
data = utils.fetch_url(url, cookies)
f_dict = data.to_dict()

return f_dict["data"]


def get_option_chain(
symbol: str,
strike_price: str = None,
Expand Down
2 changes: 2 additions & 0 deletions nsedt/resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
INDICES = ["NIFTY", "FINNIFTY", "BANKNIFTY"]
VIX_HISTORY = "api/historical/vixhistory?"
FNO_HISTORY = "api/historical/foCPV?"
UNDERLYINF_INFO="/api/underlying-information"


# Reports
MARKET_ACTIVITY_REPORT = "archives/equities/mkt/MA"
Expand Down
12 changes: 12 additions & 0 deletions tests/test_derivatives_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from nsedt.derivatives import options as opt

from nsedt import derivatives as de

START_DATE = "01-01-2024"
END_DATE = "10-01-2024"
SYMBOL = "TCS"
Expand Down Expand Up @@ -85,3 +87,13 @@ def test_get_historical_option_data():
expiry_date="28-03-2024",
)
assert isinstance(data, pd.DataFrame)



def test_get_derivatives_symbols():
"""
Test the get_derivatives_symbols function from nsedt.derivatives.options module.
"""
data=de.get_derivatives_symbols()
symList=[i['symbol'] for i in data['UnderlyingList']]
assert isinstance(symList, List)

0 comments on commit 4821e8d

Please sign in to comment.