BharatFinTrack 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bharatfintrack-0.0.1/BharatFinTrack/__init__.py +9 -0
- bharatfintrack-0.0.1/BharatFinTrack/nse_track.py +186 -0
- bharatfintrack-0.0.1/BharatFinTrack.egg-info/PKG-INFO +83 -0
- bharatfintrack-0.0.1/BharatFinTrack.egg-info/SOURCES.txt +10 -0
- bharatfintrack-0.0.1/BharatFinTrack.egg-info/dependency_links.txt +1 -0
- bharatfintrack-0.0.1/BharatFinTrack.egg-info/top_level.txt +1 -0
- bharatfintrack-0.0.1/LICENSE.txt +21 -0
- bharatfintrack-0.0.1/PKG-INFO +83 -0
- bharatfintrack-0.0.1/README.md +64 -0
- bharatfintrack-0.0.1/pyproject.toml +39 -0
- bharatfintrack-0.0.1/setup.cfg +4 -0
- bharatfintrack-0.0.1/tests/test_nse_track.py +42 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
class NSETrack:
|
|
2
|
+
|
|
3
|
+
'''
|
|
4
|
+
Represents characteristics of NSE finance products.
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@property
|
|
9
|
+
def indices_category(self):
|
|
10
|
+
|
|
11
|
+
'''
|
|
12
|
+
Returns a list categories for NSE indices.
|
|
13
|
+
'''
|
|
14
|
+
|
|
15
|
+
output = [
|
|
16
|
+
'broad',
|
|
17
|
+
'sectoral',
|
|
18
|
+
'thematic',
|
|
19
|
+
'strategy'
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
return output
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_indices_by_category(self, category):
|
|
26
|
+
|
|
27
|
+
'''
|
|
28
|
+
Returns NSE indices for a specified category.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
category : str
|
|
33
|
+
The classification type of NSE indices.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
list
|
|
38
|
+
A list containing the names of indices for the specified category.
|
|
39
|
+
'''
|
|
40
|
+
|
|
41
|
+
indices = {}
|
|
42
|
+
|
|
43
|
+
# broad index
|
|
44
|
+
indices['broad'] = [
|
|
45
|
+
'NIFTY 500',
|
|
46
|
+
'NIFTY 50'
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
# sectoral index
|
|
50
|
+
indices['sectoral'] = [
|
|
51
|
+
'NIFTY IT',
|
|
52
|
+
'NIFTY BANK'
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
# thematic index
|
|
56
|
+
indices['thematic'] = [
|
|
57
|
+
'NIFTY EV & NEW AGE AUTOMOTIVE',
|
|
58
|
+
'NIFTY INDIA DEFENCE'
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
# strategy index
|
|
62
|
+
indices['strategy'] = [
|
|
63
|
+
'NIFTY ALPHA 50',
|
|
64
|
+
'NIFTY MIDCAP150 MOMENTUM 50'
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
if category in self.indices_category:
|
|
68
|
+
pass
|
|
69
|
+
else:
|
|
70
|
+
raise Exception(f'Invadid category: {category}')
|
|
71
|
+
|
|
72
|
+
return indices[category]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def downloadable_indices(self):
|
|
77
|
+
|
|
78
|
+
'''
|
|
79
|
+
Returns a list of all indices names.
|
|
80
|
+
'''
|
|
81
|
+
|
|
82
|
+
output = [
|
|
83
|
+
index for category in self.indices_category for index in self.get_indices_by_category(category)
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
return output
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def is_valid_index(self, index):
|
|
90
|
+
|
|
91
|
+
'''
|
|
92
|
+
Checks whether a specified NSE index name is valid.
|
|
93
|
+
|
|
94
|
+
Parameters
|
|
95
|
+
----------
|
|
96
|
+
index : str
|
|
97
|
+
The name of the NSE index.
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
bool
|
|
102
|
+
True if the index name is valid, False.
|
|
103
|
+
'''
|
|
104
|
+
|
|
105
|
+
return index in self.downloadable_indices
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def indices_base_date(self):
|
|
110
|
+
|
|
111
|
+
'''
|
|
112
|
+
Returns a dictionary where keys are indices
|
|
113
|
+
and values are their corresponding base dates.
|
|
114
|
+
'''
|
|
115
|
+
|
|
116
|
+
default_date = '01-Apr-2005'
|
|
117
|
+
|
|
118
|
+
start_date = {}
|
|
119
|
+
|
|
120
|
+
start_date['01-Jan-1995'] = ['NIFTY 500']
|
|
121
|
+
start_date['03-Nov-1995'] = ['NIFTY 50']
|
|
122
|
+
start_date['01-Jan-1996'] = ['NIFTY IT']
|
|
123
|
+
start_date['01-Jan-2000'] = ['NIFTY BANK']
|
|
124
|
+
start_date['31-Dec-2003'] = ['NIFTY ALPHA']
|
|
125
|
+
start_date['02-Apr-2018'] = [
|
|
126
|
+
'NIFTY EV & NEW AGE AUTOMOTIVE'
|
|
127
|
+
'NIFTY INDIA DEFENCE'
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
date_dict = {v: key for key, value in start_date.items() for v in value}
|
|
131
|
+
|
|
132
|
+
output = dict(
|
|
133
|
+
map(lambda x: (x, date_dict.get(x, default_date)), self.downloadable_indices)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
return output
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def get_index_base_date(self, index):
|
|
140
|
+
|
|
141
|
+
'''
|
|
142
|
+
Returns the base date for a specified NSE index.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
index : str
|
|
147
|
+
The name of the NSE index.
|
|
148
|
+
|
|
149
|
+
Returns
|
|
150
|
+
-------
|
|
151
|
+
str
|
|
152
|
+
The base date of the index in 'DD-MMM-YYYY' format.
|
|
153
|
+
'''
|
|
154
|
+
|
|
155
|
+
if self.is_valid_index(index):
|
|
156
|
+
pass
|
|
157
|
+
else:
|
|
158
|
+
raise Exception(f'Invalid index: {index}')
|
|
159
|
+
|
|
160
|
+
return self.indices_base_date[index]
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def get_index_base_value(self, index):
|
|
164
|
+
|
|
165
|
+
'''
|
|
166
|
+
Returns the base value for a specified NSE index.
|
|
167
|
+
|
|
168
|
+
Parameters
|
|
169
|
+
----------
|
|
170
|
+
index : str
|
|
171
|
+
The name of the NSE index.
|
|
172
|
+
|
|
173
|
+
Returns
|
|
174
|
+
-------
|
|
175
|
+
float
|
|
176
|
+
The base value of the index.
|
|
177
|
+
'''
|
|
178
|
+
|
|
179
|
+
if self.is_valid_index(index):
|
|
180
|
+
pass
|
|
181
|
+
else:
|
|
182
|
+
raise Exception(f'Invalid index: {index}')
|
|
183
|
+
|
|
184
|
+
base_value = {'NIFTY IT': 100.0}
|
|
185
|
+
|
|
186
|
+
return base_value.get(index, 1000.0)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: BharatFinTrack
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Downloading and analyzing financial data, including indices, stocks, and mutual funds, from India, that is, Bharat.
|
|
5
|
+
Author-email: Debasish Pal <bestdebasish@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/debpal/BharatFinTrack
|
|
7
|
+
Project-URL: Documentation, https://bharatfintrack.readthedocs.io/en/latest/
|
|
8
|
+
Keywords: nse index,nse total return index,data download,data analysis
|
|
9
|
+
Classifier: Development Status :: 1 - Planning
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE.txt
|
|
19
|
+
|
|
20
|
+
# BharatFinTrack
|
|
21
|
+
|
|
22
|
+
## Analysis Toolkit
|
|
23
|
+
|
|
24
|
+
| Feature | Badge|
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| Documemt | [](https://bharatfintrack.readthedocs.io/en/latest/?badge=latest) |
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## What is BharatFinTrack?
|
|
30
|
+
BharatFinTrack is a Python package designed to simplify the process of downloading and analyzing financial data from India, that is Bharat. The current features of the package include:
|
|
31
|
+
|
|
32
|
+
- **NSE Indices**
|
|
33
|
+
- Access to characteristics of indices.
|
|
34
|
+
- Download of historical daily Total Return Index (TRI) values.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Easy Installation
|
|
38
|
+
|
|
39
|
+
To install, use pip:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install BharatFinTrack
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quickstart
|
|
46
|
+
A brief example of how to start:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
>>> import BharatFinTrack
|
|
50
|
+
>>> nse_track = BharatFinTrack.NSETrack()
|
|
51
|
+
>>> nse_track.indices_category
|
|
52
|
+
['broad', 'sectoral', 'thematic', 'strategy']
|
|
53
|
+
|
|
54
|
+
# get the list of downloadable indices
|
|
55
|
+
>>> nse_track.downloadable_indices
|
|
56
|
+
['NIFTY 500',
|
|
57
|
+
'NIFTY 50',
|
|
58
|
+
'NIFTY IT',
|
|
59
|
+
'NIFTY BANK',
|
|
60
|
+
...]
|
|
61
|
+
|
|
62
|
+
# get the dictionary of indices base date
|
|
63
|
+
>>> nse_track.indices_base_date
|
|
64
|
+
{'NIFTY 500': '01-Jan-1995',
|
|
65
|
+
'NIFTY 50': '03-Nov-1995',
|
|
66
|
+
'NIFTY IT': '01-Jan-1996',
|
|
67
|
+
'NIFTY BANK': '01-Jan-2000',
|
|
68
|
+
...}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Documentation
|
|
73
|
+
For detailed information, see the [documentation](https://bharatfintrack.readthedocs.io/en/latest/).
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Development status
|
|
77
|
+
|
|
78
|
+
The project is in the conceptualization and planning phases.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
The package is released under the MIT License.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
BharatFinTrack/__init__.py
|
|
5
|
+
BharatFinTrack/nse_track.py
|
|
6
|
+
BharatFinTrack.egg-info/PKG-INFO
|
|
7
|
+
BharatFinTrack.egg-info/SOURCES.txt
|
|
8
|
+
BharatFinTrack.egg-info/dependency_links.txt
|
|
9
|
+
BharatFinTrack.egg-info/top_level.txt
|
|
10
|
+
tests/test_nse_track.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BharatFinTrack
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Debasish Pal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: BharatFinTrack
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Downloading and analyzing financial data, including indices, stocks, and mutual funds, from India, that is, Bharat.
|
|
5
|
+
Author-email: Debasish Pal <bestdebasish@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/debpal/BharatFinTrack
|
|
7
|
+
Project-URL: Documentation, https://bharatfintrack.readthedocs.io/en/latest/
|
|
8
|
+
Keywords: nse index,nse total return index,data download,data analysis
|
|
9
|
+
Classifier: Development Status :: 1 - Planning
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE.txt
|
|
19
|
+
|
|
20
|
+
# BharatFinTrack
|
|
21
|
+
|
|
22
|
+
## Analysis Toolkit
|
|
23
|
+
|
|
24
|
+
| Feature | Badge|
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| Documemt | [](https://bharatfintrack.readthedocs.io/en/latest/?badge=latest) |
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## What is BharatFinTrack?
|
|
30
|
+
BharatFinTrack is a Python package designed to simplify the process of downloading and analyzing financial data from India, that is Bharat. The current features of the package include:
|
|
31
|
+
|
|
32
|
+
- **NSE Indices**
|
|
33
|
+
- Access to characteristics of indices.
|
|
34
|
+
- Download of historical daily Total Return Index (TRI) values.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Easy Installation
|
|
38
|
+
|
|
39
|
+
To install, use pip:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install BharatFinTrack
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quickstart
|
|
46
|
+
A brief example of how to start:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
>>> import BharatFinTrack
|
|
50
|
+
>>> nse_track = BharatFinTrack.NSETrack()
|
|
51
|
+
>>> nse_track.indices_category
|
|
52
|
+
['broad', 'sectoral', 'thematic', 'strategy']
|
|
53
|
+
|
|
54
|
+
# get the list of downloadable indices
|
|
55
|
+
>>> nse_track.downloadable_indices
|
|
56
|
+
['NIFTY 500',
|
|
57
|
+
'NIFTY 50',
|
|
58
|
+
'NIFTY IT',
|
|
59
|
+
'NIFTY BANK',
|
|
60
|
+
...]
|
|
61
|
+
|
|
62
|
+
# get the dictionary of indices base date
|
|
63
|
+
>>> nse_track.indices_base_date
|
|
64
|
+
{'NIFTY 500': '01-Jan-1995',
|
|
65
|
+
'NIFTY 50': '03-Nov-1995',
|
|
66
|
+
'NIFTY IT': '01-Jan-1996',
|
|
67
|
+
'NIFTY BANK': '01-Jan-2000',
|
|
68
|
+
...}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Documentation
|
|
73
|
+
For detailed information, see the [documentation](https://bharatfintrack.readthedocs.io/en/latest/).
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Development status
|
|
77
|
+
|
|
78
|
+
The project is in the conceptualization and planning phases.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
The package is released under the MIT License.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# BharatFinTrack
|
|
2
|
+
|
|
3
|
+
## Analysis Toolkit
|
|
4
|
+
|
|
5
|
+
| Feature | Badge|
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Documemt | [](https://bharatfintrack.readthedocs.io/en/latest/?badge=latest) |
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## What is BharatFinTrack?
|
|
11
|
+
BharatFinTrack is a Python package designed to simplify the process of downloading and analyzing financial data from India, that is Bharat. The current features of the package include:
|
|
12
|
+
|
|
13
|
+
- **NSE Indices**
|
|
14
|
+
- Access to characteristics of indices.
|
|
15
|
+
- Download of historical daily Total Return Index (TRI) values.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Easy Installation
|
|
19
|
+
|
|
20
|
+
To install, use pip:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install BharatFinTrack
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
A brief example of how to start:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
>>> import BharatFinTrack
|
|
31
|
+
>>> nse_track = BharatFinTrack.NSETrack()
|
|
32
|
+
>>> nse_track.indices_category
|
|
33
|
+
['broad', 'sectoral', 'thematic', 'strategy']
|
|
34
|
+
|
|
35
|
+
# get the list of downloadable indices
|
|
36
|
+
>>> nse_track.downloadable_indices
|
|
37
|
+
['NIFTY 500',
|
|
38
|
+
'NIFTY 50',
|
|
39
|
+
'NIFTY IT',
|
|
40
|
+
'NIFTY BANK',
|
|
41
|
+
...]
|
|
42
|
+
|
|
43
|
+
# get the dictionary of indices base date
|
|
44
|
+
>>> nse_track.indices_base_date
|
|
45
|
+
{'NIFTY 500': '01-Jan-1995',
|
|
46
|
+
'NIFTY 50': '03-Nov-1995',
|
|
47
|
+
'NIFTY IT': '01-Jan-1996',
|
|
48
|
+
'NIFTY BANK': '01-Jan-2000',
|
|
49
|
+
...}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Documentation
|
|
54
|
+
For detailed information, see the [documentation](https://bharatfintrack.readthedocs.io/en/latest/).
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Development status
|
|
58
|
+
|
|
59
|
+
The project is in the conceptualization and planning phases.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
The package is released under the MIT License.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[project]
|
|
7
|
+
name = "BharatFinTrack"
|
|
8
|
+
description = "Downloading and analyzing financial data, including indices, stocks, and mutual funds, from India, that is, Bharat."
|
|
9
|
+
authors = [
|
|
10
|
+
{ name="Debasish Pal", email="bestdebasish@gmail.com" },
|
|
11
|
+
]
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.12"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 1 - Planning",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Intended Audience :: Education",
|
|
20
|
+
"Topic :: Office/Business :: Financial",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Information Analysis"
|
|
22
|
+
]
|
|
23
|
+
dynamic = ["version"]
|
|
24
|
+
|
|
25
|
+
keywords = [
|
|
26
|
+
"nse index",
|
|
27
|
+
"nse total return index",
|
|
28
|
+
"data download",
|
|
29
|
+
"data analysis"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
"Homepage" = "https://github.com/debpal/BharatFinTrack"
|
|
35
|
+
"Documentation" = "https://bharatfintrack.readthedocs.io/en/latest/"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.dynamic]
|
|
39
|
+
version = {attr = "BharatFinTrack.__version__"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import BharatFinTrack
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.fixture(scope='module')
|
|
6
|
+
def class_instance():
|
|
7
|
+
|
|
8
|
+
return BharatFinTrack.NSETrack()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_get_indices_by_category(class_instance):
|
|
12
|
+
|
|
13
|
+
# pass test
|
|
14
|
+
assert class_instance.get_indices_by_category('broad')[0] == 'NIFTY 500'
|
|
15
|
+
assert 'NIFTY ALPHA 50' in class_instance.get_indices_by_category('strategy')
|
|
16
|
+
|
|
17
|
+
# error test
|
|
18
|
+
with pytest.raises(Exception) as exc_info:
|
|
19
|
+
class_instance.get_indices_by_category('non-existence')
|
|
20
|
+
assert exc_info.value.args[0] == 'Invadid category: non-existence'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_is_valid_index(class_instance):
|
|
24
|
+
|
|
25
|
+
assert class_instance.is_valid_index('NIFTY 50') == True
|
|
26
|
+
assert class_instance.is_valid_index('NIFTY ITI') == False
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_get_index_base_date(class_instance):
|
|
30
|
+
|
|
31
|
+
assert class_instance.get_index_base_date('NIFTY 50') == '03-Nov-1995'
|
|
32
|
+
|
|
33
|
+
# error test
|
|
34
|
+
with pytest.raises(Exception) as exc_info:
|
|
35
|
+
class_instance.get_index_base_date('non-existence')
|
|
36
|
+
assert exc_info.value.args[0] == 'Invalid index: non-existence'
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_get_index_base_value(class_instance):
|
|
40
|
+
|
|
41
|
+
assert class_instance.get_index_base_value('NIFTY 50') == 1000.0
|
|
42
|
+
assert class_instance.get_index_base_value('NIFTY IT') == 100.0
|