Skip to content

Commit

Permalink
Merge pull request #67 from jugaad-py/stock-currency-option-chains
Browse files Browse the repository at this point in the history
Added functions for equity and currency option chain
  • Loading branch information
sevakram authored Dec 23, 2023
2 parents 5484639 + 9951d6f commit 8bc622f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jugaad_data/nse/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class NSELive:
"all_indices": "/allIndices",
"live_index": "/equity-stockIndices",
"index_option_chain": "/option-chain-indices",
"equity_option_chain": "/option-chain-equities",
"currency_option_chain": "/option-chain-currency",
"pre_open_market": "/market-data-pre-open",
"holiday_list": "/holiday-master?type=trading"
}
Expand Down Expand Up @@ -101,6 +103,16 @@ def index_option_chain(self, symbol="NIFTY"):
data = {"symbol": symbol}
return self.get("index_option_chain", data)

@live_cache
def equities_option_chain(self, symbol):
data = {"symbol": symbol}
return self.get("equity_option_chain", data)

@live_cache
def currency_option_chain(self, symbol="USDINR"):
data = {"symbol": symbol}
return self.get("currency_option_chain", data)

@live_cache
def live_fno(self):
return self.live_index("SECURITIES IN F&O")
Expand Down
12 changes: 12 additions & 0 deletions tests/test_nse_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def test_index_option_chain():
assert "filtered" in d
assert "records" in d

def test_equities_option_chain():
d = n.equities_option_chain("RELIANCE")
assert "filtered" in d
assert "records" in d
assert "data" in d["records"]

def test_currency_option_chain():
d = n.currency_option_chain("USDINR")
assert "filtered" in d
assert "records" in d
assert "data" in d["records"]

def test_live_fno():
d = n.live_fno()
assert "SECURITIES IN F&O" == d['name']
Expand Down

0 comments on commit 8bc622f

Please sign in to comment.