Skip to content

Commit

Permalink
Fix PyLint
Browse files Browse the repository at this point in the history
  • Loading branch information
pratik141 committed May 1, 2024
1 parent f1d8156 commit 819be1a
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 80 deletions.
6 changes: 5 additions & 1 deletion nsedt/derivatives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from nsedt import utils
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
from nsedt.derivatives.options import (
get_option_chain,
get_option_chain_expdate,
get_historical_option_data
)
from nsedt.derivatives.futures import get_future_price, get_future_expdate

log = logging.getLogger("root")
Expand Down
2 changes: 1 addition & 1 deletion nsedt/utils/data_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def derivaties_options(
"FH_LAST_TRADED_PRICE",
"TIMESTAMP",
]

if response_type == "json":
data_json_ret = []
for record in data_json:
Expand Down
166 changes: 88 additions & 78 deletions tests/test_equity.py
Original file line number Diff line number Diff line change
@@ -1,106 +1,116 @@
"""
Test case for nsedt.equity
"""
from typing import Dict, List
import pandas as pd

from nsedt.nsedt import equity as eq
from typing import Dict, List
from nsedt import equity as eq

start_date = "01-01-2024"
end_date = "10-01-2024"
symbol = "TCS"
START_DATE = "01-01-2024"
END_DATE = "10-01-2024"
SYMBOL = "TCS"

def test_get_price():
"""
Test the get_price function from nsedt.equity module.
"""

data = eq.get_price(start_date, end_date, symbol)

# Assert expected data structure and content
assert isinstance(data, pd.DataFrame)
assert len(data) == 8
assert list(data.columns) == [
"Date",
"Open Price",
"High Price",
"Low Price",
"Close Price",
"Prev Close Price",
"Last Traded Price",
"Total Traded Quantity",
"Total Traded Value",
"52 Week High Price",
"52 Week Low Price",
"VWAP",
"Deliverable Volume",
"Deliverable Percent",
"Series",
]
assert data.loc[0, "Open Price"] == 3790.0
assert data.loc[3, "Close Price"] == 3666.8
"""
Test the get_price function from nsedt.equity module.
"""

data = eq.get_price(START_DATE, END_DATE, SYMBOL)

# Assert expected data structure and content
assert isinstance(data, pd.DataFrame)
assert len(data) == 8
assert list(data.columns) == [
"Date",
"Open Price",
"High Price",
"Low Price",
"Close Price",
"Prev Close Price",
"Last Traded Price",
"Total Traded Quantity",
"Total Traded Value",
"52 Week High Price",
"52 Week Low Price",
"VWAP",
"Deliverable Volume",
"Deliverable Percent",
"Series",
]
assert data.loc[0, "Open Price"] == 3790.0
assert data.loc[3, "Close Price"] == 3666.8


def test_get_event():
"""
Test the get_event function from nsedt.equity module.
"""
"""
Test the get_event function from nsedt.equity module.
"""

data = eq.get_event(start_date, end_date)
data = eq.get_event(START_DATE, END_DATE)

# Assert expected data structure and content
assert isinstance(data, pd.DataFrame)
assert len(data) == 39
assert list(data.columns) == ['symbol', 'company', 'purpose', 'bm_desc', 'date']
assert data.loc[0, "company"] == 'Gensol Engineering Limited'
assert data.loc[3, "date"] == '03-Jan-2024'
# Assert expected data structure and content
assert isinstance(data, pd.DataFrame)
assert len(data) == 39
assert list(data.columns) == ['SYMBOL', 'company', 'purpose', 'bm_desc', 'date']
assert data.loc[0, "company"] == 'Gensol Engineering Limited'
assert data.loc[3, "date"] == '03-Jan-2024'


def test_get_companyinfo():
"""
Test the get_companyinfo function from nsedt.equity module.
"""

data = eq.get_companyinfo(symbol=symbol,response_type="json")

# Assert expected data structure and content
assert isinstance(data, Dict)
assert len(data) == 7
assert list(data.keys()) == ['info', 'metadata', 'securityInfo', 'sddDetails', 'priceInfo', 'industryInfo', 'preOpenMarket']
assert data['info']['companyName'] == 'Tata Consultancy Services Limited'
assert data['industryInfo']['sector'] == 'Information Technology'
"""
Test the get_companyinfo function from nsedt.equity module.
"""

data = eq.get_companyinfo(SYMBOL,response_type="json")

# Assert expected data structure and content
assert isinstance(data, Dict)
assert len(data) == 7
assert list(data.keys()) == ['info',
'metadata',
'securityInfo',
'sddDetails',
'priceInfo',
'industryInfo',
'preOpenMarket',
]
assert data['info']['companyName'] == 'Tata Consultancy Services Limited'
assert data['industryInfo']['sector'] == 'Information Technology'


def test_get_symbols_list():
"""
Test the get_symbols_list function from nsedt.equity module.
"""
"""
Test the get_SYMBOLs_list function from nsedt.equity module.
"""

data = eq.get_symbols_list()
data = eq.get_symbols_list()

# Assert expected data structure and content
assert isinstance(data, List)
assert len(data) > 1000
assert symbol in data
# Assert expected data structure and content
assert isinstance(data, List)
assert len(data) > 1000
assert SYMBOL in data


def test_get_asm_list():
"""
Test the get_asm_list function from nsedt.equity module.
"""
"""
Test the get_asm_list function from nsedt.equity module.
"""

data = eq.get_asm_list(asm_type = "shortterm")
data = eq.get_asm_list(asm_type = "shortterm")

# Assert expected data structure and content
assert isinstance(data, List)
assert len(data) > 1
# Assert expected data structure and content
assert isinstance(data, List)
assert len(data) > 1


def test_get_chartdatat():
"""
Test the get_chartdata function from nsedt.equity module.
"""
"""
Test the get_chartdata function from nsedt.equity module.
"""

data = eq.get_chartdata(symbol="TCS")
data = eq.get_chartdata("TCS")

# Assert expected data structure and content
assert isinstance(data, pd.DataFrame)
assert len(data) > 1
assert list(data.columns) == ['timestamp_milliseconds', 'price', 'datetime']
# Assert expected data structure and content
assert isinstance(data, pd.DataFrame)
assert len(data) > 1
assert list(data.columns) == ['timestamp_milliseconds', 'price', 'datetime']

0 comments on commit 819be1a

Please sign in to comment.