Skip to content

Commit

Permalink
fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Witchking authored and Witchking committed May 1, 2024
2 parents 756a497 + e0fdf89 commit 076a61c
Show file tree
Hide file tree
Showing 11 changed files with 512 additions and 58 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/Push-nd-PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Python Pytest

permissions:
contents: read
issues: read
checks: write
pull-requests: write

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
Test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pylint pytest-cov
python setup.py install
- name: Lint with pylint
run: |
STAT=$(pylint $(git ls-files '*.py') |grep -o "at.*(" | cut -d ' ' -f3)
echo $STAT
OUTPUT="Last pylint run status: ${OUTPUT}"
echo "## ${OUTPUT}" >> $GITHUB_STEP_SUMMARY
echo "MESSAGE=$OUTPUT" >> $GITHUB_ENV
- name: Post pylint result to PR
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v1
with:
message: ${{ env.MESSAGE }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: false

- name: Test with pytest
id: pytest
run: |
pytest tests/ --doctest-modules \
--junitxml=junit/test-results.xml \
--cov=com --cov-report=xml --cov-report=html
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
with:
files: |
junit/test-results.xml
30 changes: 0 additions & 30 deletions .github/workflows/pylint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Thank you for using Nsedt. Please feel free to send pull requests, comments, and
`pip install -r requirements.txt`
3. Install locally
`pip install . --upgrade`

---

## Equity
Expand Down Expand Up @@ -97,7 +98,6 @@ data["Date"] = pd.to_datetime(data["Date"],format='%d-%b-%Y')

```py
from nsedt import derivatives as de

start_date = "24-04-2024"
end_date = "25-04-2024"
# date format "%d-%m-%Y"
Expand Down
12 changes: 8 additions & 4 deletions nsedt/derivatives/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
from nsedt import utils
from nsedt.resources import constants as cns
from nsedt.utils import data_format
from nsedt.utils import data_format, exceptions

log = logging.getLogger("root")

Expand Down Expand Up @@ -151,14 +151,18 @@ def get_historical_option_data(
"symbol": symbol,
"from": start_date,
"to": end_date,
"instrumentType" : "OPTSTK",
"instrumentType": "OPTSTK",
"optionType": option_type,
"expiryDate": expiry_date,
"expiryDate": datetime.strptime(expiry_date, "%d-%m-%Y").strftime("%d-%b-%Y"),
"strikePrice": strike_price,
"year": year
"year": year,
}
url = base_url + event_api + urllib.parse.urlencode(params)
data = utils.fetch_url(url, cookies, response_type="json")

if data["data"] == []:
raise exceptions.DateStrikePriceOutofRange()

return data_format.derivaties_options(
data,
response_type=response_type,
Expand Down
138 changes: 115 additions & 23 deletions nsedt/resources/index_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,31 @@
"derivatives": "FINNIFTY",
"indices": "NIFTY FINANCIAL SERVICES",
},
{"keys": ["NIFTY NEXT 50"], "derivatives": "", "indices": "NIFTY NEXT 50"},
{"keys": ["NIFTY MIDCAP 50"], "derivatives": "", "indices": "NIFTY MIDCAP 50"},
{"keys": ["NIFTY MIDCAP 100"], "derivatives": "", "indices": "NIFTY MIDCAP 100"},
{"keys": ["NIFTY MIDCAP 150"], "derivatives": "", "indices": "NIFTY MIDCAP 150"},
{"keys": ["NIFTY SMALLCAP 50"], "derivatives": "", "indices": "NIFTY SMALLCAP 50"},
{
"keys": ["NIFTY NEXT 50"],
"derivatives": "",
"indices": "NIFTY NEXT 50",
},
{
"keys": ["NIFTY MIDCAP 50"],
"derivatives": "",
"indices": "NIFTY MIDCAP 50",
},
{
"keys": ["NIFTY MIDCAP 100"],
"derivatives": "",
"indices": "NIFTY MIDCAP 100",
},
{
"keys": ["NIFTY MIDCAP 150"],
"derivatives": "",
"indices": "NIFTY MIDCAP 150",
},
{
"keys": ["NIFTY SMALLCAP 50"],
"derivatives": "",
"indices": "NIFTY SMALLCAP 50",
},
{
"keys": ["NIFTY SMALLCAP 100"],
"derivatives": "",
Expand All @@ -37,8 +57,16 @@
"derivatives": "",
"indices": "NIFTY MIDSMALLCAP 400",
},
{"keys": ["NIFTY 100"], "derivatives": "", "indices": "NIFTY 100"},
{"keys": ["NIFTY 200"], "derivatives": "", "indices": "NIFTY 200"},
{
"keys": ["NIFTY 100"],
"derivatives": "",
"indices": "NIFTY 100",
},
{
"keys": ["NIFTY 200"],
"derivatives": "",
"indices": "NIFTY 200",
},
{
"keys": ["NIFTY500 MULTICAP 50:25:25"],
"derivatives": "",
Expand All @@ -64,20 +92,56 @@
"derivatives": "",
"indices": "NIFTY MICROCAP 250",
},
{"keys": ["NIFTY AUTO"], "derivatives": "", "indices": "NIFTY AUTO"},
{"keys": ["NIFTY ENERGY"], "derivatives": "", "indices": "NIFTY ENERGY"},
{
"keys": ["NIFTY AUTO"],
"derivatives": "",
"indices": "NIFTY AUTO",
},
{
"keys": ["NIFTY ENERGY"],
"derivatives": "",
"indices": "NIFTY ENERGY",
},
{
"keys": ["NIFTY FINANCIAL SERVICES 25/50"],
"derivatives": "",
"indices": "NIFTY FINANCIAL SERVICES 25/50",
},
{"keys": ["NIFTY FMCG"], "derivatives": "", "indices": "NIFTY FMCG"},
{"keys": ["NIFTY IT"], "derivatives": "", "indices": "NIFTY IT"},
{"keys": ["NIFTY MEDIA"], "derivatives": "", "indices": "NIFTY MEDIA"},
{"keys": ["NIFTY METAL"], "derivatives": "", "indices": "NIFTY METAL"},
{"keys": ["NIFTY PHARMA"], "derivatives": "", "indices": "NIFTY PHARMA"},
{"keys": ["NIFTY PSU BANK"], "derivatives": "", "indices": "NIFTY PSU BANK"},
{"keys": ["NIFTY REALTY"], "derivatives": "", "indices": "NIFTY REALTY"},
{
"keys": ["NIFTY FMCG"],
"derivatives": "",
"indices": "NIFTY FMCG",
},
{
"keys": ["NIFTY IT"],
"derivatives": "",
"indices": "NIFTY IT",
},
{
"keys": ["NIFTY MEDIA"],
"derivatives": "",
"indices": "NIFTY MEDIA",
},
{
"keys": ["NIFTY METAL"],
"derivatives": "",
"indices": "NIFTY METAL",
},
{
"keys": ["NIFTY PHARMA"],
"derivatives": "",
"indices": "NIFTY PHARMA",
},
{
"keys": ["NIFTY PSU BANK"],
"derivatives": "",
"indices": "NIFTY PSU BANK",
},
{
"keys": ["NIFTY REALTY"],
"derivatives": "",
"indices": "NIFTY REALTY",
},
{
"keys": ["NIFTY PRIVATE BANK"],
"derivatives": "",
Expand All @@ -103,7 +167,11 @@
"derivatives": "",
"indices": "NIFTY DIVIDEND OPPORTUNITIES 50",
},
{"keys": ["NIFTY50 VALUE 20"], "derivatives": "", "indices": "NIFTY50 VALUE 20"},
{
"keys": ["NIFTY50 VALUE 20"],
"derivatives": "",
"indices": "NIFTY50 VALUE 20",
},
{
"keys": ["NIFTY100 QUALITY 30"],
"derivatives": "",
Expand All @@ -124,7 +192,11 @@
"derivatives": "",
"indices": "NIFTY100 LOW VOLATILITY 30",
},
{"keys": ["NIFTY ALPHA 50"], "derivatives": "", "indices": "NIFTY ALPHA 50"},
{
"keys": ["NIFTY ALPHA 50"],
"derivatives": "",
"indices": "NIFTY ALPHA 50",
},
{
"keys": ["NIFTY200 QUALITY 30"],
"derivatives": "",
Expand All @@ -145,25 +217,41 @@
"derivatives": "",
"indices": "NIFTY MIDCAP150 QUALITY 50",
},
{"keys": ["NIFTY COMMODITIES"], "derivatives": "", "indices": "NIFTY COMMODITIES"},
{
"keys": ["NIFTY COMMODITIES"],
"derivatives": "",
"indices": "NIFTY COMMODITIES",
},
{
"keys": ["NIFTY INDIA CONSUMPTION"],
"derivatives": "",
"indices": "NIFTY INDIA CONSUMPTION",
},
{"keys": ["NIFTY CPSE"], "derivatives": "", "indices": "NIFTY CPSE"},
{
"keys": ["NIFTY CPSE"],
"derivatives": "",
"indices": "NIFTY CPSE",
},
{
"keys": ["NIFTY INFRASTRUCTURE"],
"derivatives": "",
"indices": "NIFTY INFRASTRUCTURE",
},
{"keys": ["NIFTY MNC"], "derivatives": "", "indices": "NIFTY MNC"},
{
"keys": ["NIFTY MNC"],
"derivatives": "",
"indices": "NIFTY MNC",
},
{
"keys": ["NIFTY GROWTH SECTORS 15"],
"derivatives": "",
"indices": "NIFTY GROWTH SECTORS 15",
},
{"keys": ["NIFTY PSE"], "derivatives": "", "indices": "NIFTY PSE"},
{
"keys": ["NIFTY PSE"],
"derivatives": "",
"indices": "NIFTY PSE",
},
{
"keys": ["NIFTY SERVICES SECTOR"],
"derivatives": "",
Expand All @@ -184,7 +272,11 @@
"derivatives": "",
"indices": "NIFTY INDIA DIGITAL",
},
{"keys": ["NIFTY100 ESG"], "derivatives": "", "indices": "NIFTY100 ESG"},
{
"keys": ["NIFTY100 ESG"],
"derivatives": "",
"indices": "NIFTY100 ESG",
},
{
"keys": ["NIFTY INDIA MANUFACTURING"],
"derivatives": "",
Expand Down
38 changes: 38 additions & 0 deletions nsedt/utils/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""_summary_
Returns:
_type_: _description_
"""


class MissingEnvValue(BaseException):
"""_summary_
Args:
BaseException (_type_): _description_
"""

def __init__(self, message: str):
self.message = message

def __str__(self):
return f""" ----[ERROR]----
=================================================================================================
{self.message}
=================================================================================================
"""


class DateStrikePriceOutofRange(BaseException):
"""_summary_
Args:
BaseException (_type_): _description_
"""

def __str__(self):
return """ ----[ERROR]----
=================================================================================================
Either Date of strike Price is out of range for NSE (No data found)
=================================================================================================
"""
Empty file added tests/__init__.py
Empty file.
Loading

0 comments on commit 076a61c

Please sign in to comment.