mftool 2.9__tar.gz → 3.0__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.
- {mftool-2.9 → mftool-3.0}/PKG-INFO +1 -1
- {mftool-2.9 → mftool-3.0}/mftool/__init__.py +1 -1
- {mftool-2.9 → mftool-3.0}/mftool/const.json +41 -39
- {mftool-2.9 → mftool-3.0}/mftool/mftool.py +51 -93
- {mftool-2.9 → mftool-3.0}/mftool.egg-info/PKG-INFO +1 -1
- {mftool-2.9 → mftool-3.0}/mftool.egg-info/requires.txt +1 -1
- {mftool-2.9 → mftool-3.0}/setup.py +2 -2
- {mftool-2.9 → mftool-3.0}/README.md +0 -0
- {mftool-2.9 → mftool-3.0}/mftool/utils.py +0 -0
- {mftool-2.9 → mftool-3.0}/mftool.egg-info/SOURCES.txt +0 -0
- {mftool-2.9 → mftool-3.0}/mftool.egg-info/dependency_links.txt +0 -0
- {mftool-2.9 → mftool-3.0}/mftool.egg-info/top_level.txt +0 -0
- {mftool-2.9 → mftool-3.0}/setup.cfg +0 -0
|
@@ -2,58 +2,60 @@
|
|
|
2
2
|
"get_quote_url": "https://www.amfiindia.com/spages/NAVAll.txt",
|
|
3
3
|
"get_scheme_url": "https://api.mfapi.in/mf/",
|
|
4
4
|
"get_amc_details_url": "https://www.amfiindia.com/modules/AMCProfileDetail",
|
|
5
|
-
"get_open_ended_equity_scheme_url": "
|
|
5
|
+
"get_open_ended_equity_scheme_url": "https://www.amfiindia.com/gateway/pollingsebi/api/amfi/fundperformance",
|
|
6
6
|
"get_avg_aum_url": "https://www.amfiindia.com/modules/AverageAUMDetails",
|
|
7
7
|
"user_agent": {
|
|
8
8
|
"User-Agent": "Chrome/95.0.4638.69"
|
|
9
9
|
},
|
|
10
10
|
"open_ended_equity_category": {
|
|
11
|
-
"
|
|
12
|
-
"Large & Mid Cap"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
11
|
+
"1": "Large Cap",
|
|
12
|
+
"2": "Large & Mid Cap",
|
|
13
|
+
"3": "Flexi Cap",
|
|
14
|
+
"4": "Multi Cap",
|
|
15
|
+
"5": "Mid Cap",
|
|
16
|
+
"6": "Small Cap",
|
|
17
|
+
"7": "Value",
|
|
18
|
+
"8": "ELSS",
|
|
19
|
+
"9": "Contra",
|
|
20
|
+
"10": "Dividend Yield",
|
|
21
|
+
"11": "Focused",
|
|
22
|
+
"12": "Sectoral / Thematic"
|
|
21
23
|
},
|
|
22
24
|
"open_ended_debt_category": {
|
|
23
|
-
"Long Duration"
|
|
24
|
-
"Medium to Long Duration"
|
|
25
|
-
"Medium Duration"
|
|
26
|
-
"Short Duration"
|
|
27
|
-
"Low Duration"
|
|
28
|
-
"Ultra Short Duration"
|
|
29
|
-
"
|
|
30
|
-
"Money Market"
|
|
31
|
-
"
|
|
32
|
-
"Dynamic Bond"
|
|
33
|
-
"Corporate Bond"
|
|
34
|
-
"Credit Risk"
|
|
35
|
-
"Banking and PSU"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"Gilt with 10 year constant duration"
|
|
25
|
+
"13":"Long Duration",
|
|
26
|
+
"14":"Medium to Long Duration",
|
|
27
|
+
"16":"Medium Duration",
|
|
28
|
+
"15":"Short Duration",
|
|
29
|
+
"18":"Low Duration",
|
|
30
|
+
"19":"Ultra Short Duration",
|
|
31
|
+
"20":"Liquid",
|
|
32
|
+
"17":"Money Market",
|
|
33
|
+
"21":"Overnight",
|
|
34
|
+
"22":"Dynamic Bond",
|
|
35
|
+
"23":"Corporate Bond",
|
|
36
|
+
"24":"Credit Risk",
|
|
37
|
+
"25":"Banking and PSU",
|
|
38
|
+
"26":"Floater",
|
|
39
|
+
"27":"FMP",
|
|
40
|
+
"28":"Gilt",
|
|
41
|
+
"29":"Gilt with 10 year constant duration"
|
|
40
42
|
},
|
|
41
43
|
"open_ended_hybrid_category": {
|
|
42
|
-
"Aggressive Hybrid"
|
|
43
|
-
"Balanced Hybrid"
|
|
44
|
-
"Conservative Hybrid"
|
|
45
|
-
"Equity Savings"
|
|
46
|
-
"
|
|
47
|
-
"Multi Asset Allocation"
|
|
44
|
+
"30":"Aggressive Hybrid",
|
|
45
|
+
"40":"Balanced Hybrid",
|
|
46
|
+
"31":"Conservative Hybrid",
|
|
47
|
+
"32":"Equity Savings",
|
|
48
|
+
"33":"Arbitrage",
|
|
49
|
+
"34":"Multi Asset Allocation"
|
|
48
50
|
},
|
|
49
51
|
"open_ended_solution_category": {
|
|
50
|
-
"Children's"
|
|
51
|
-
"
|
|
52
|
+
"36":"Children's",
|
|
53
|
+
"37":"Retirement"
|
|
52
54
|
|
|
53
55
|
},
|
|
54
56
|
"open_ended_other_category": {
|
|
55
|
-
"Index Funds/ETFs"
|
|
56
|
-
"FoFs(Oversease/Domestic)"
|
|
57
|
+
"38":"Index Funds/ETFs",
|
|
58
|
+
"39":"FoFs(Oversease/Domestic)"
|
|
57
59
|
|
|
58
60
|
},
|
|
59
61
|
"amc": [3, 53, 1, 4, 59, 46, 32, 6, 47, 54, 27, 9, 37, 20, 57, 48, 68, 62, 65, 63, 42, 70, 16, 17, 56, 18, 69, 45, 55, 21, 58, 64, 10, 13, 35,
|
|
@@ -20060,4 +20062,4 @@
|
|
|
20060
20062
|
}, {
|
|
20061
20063
|
"0P00019W5W": "Indiabulls Blue Chip Fund Direct Plan Quarterly Dividend Payout Option"
|
|
20062
20064
|
}]
|
|
20063
|
-
}
|
|
20065
|
+
}
|
|
@@ -175,7 +175,6 @@ class Mftool:
|
|
|
175
175
|
scheme_info = {}
|
|
176
176
|
url = self._get_scheme_url + code
|
|
177
177
|
response = self._session.get(url).json()
|
|
178
|
-
|
|
179
178
|
scheme_data = response['meta']
|
|
180
179
|
scheme_info['fund_house'] = scheme_data['fund_house']
|
|
181
180
|
scheme_info['scheme_type'] = scheme_data['scheme_type']
|
|
@@ -238,39 +237,7 @@ class Mftool:
|
|
|
238
237
|
else:
|
|
239
238
|
return None
|
|
240
239
|
|
|
241
|
-
@deprecated(version='
|
|
242
|
-
reason="This function will be in deprecated from next release, use mf.history() to get data")
|
|
243
|
-
def get_scheme_historical_nav_year(self, code, year, as_json=False, as_dataframe=False):
|
|
244
|
-
"""
|
|
245
|
-
gets the scheme historical data of given year for a given scheme code
|
|
246
|
-
:param code: scheme-code
|
|
247
|
-
:param year: year
|
|
248
|
-
:param as_json: default false
|
|
249
|
-
:param as_dataframe: default false
|
|
250
|
-
:return: dict or None
|
|
251
|
-
:raises: HTTPError, URLError
|
|
252
|
-
"""
|
|
253
|
-
code = str(code)
|
|
254
|
-
if self.is_valid_code(code):
|
|
255
|
-
data = []
|
|
256
|
-
# url = self._get_scheme_url + code
|
|
257
|
-
# response = self._session.get(url).json()
|
|
258
|
-
nav = self.get_scheme_historical_nav(code)
|
|
259
|
-
scheme_info = self.get_scheme_details(code)
|
|
260
|
-
for dat in nav['data']:
|
|
261
|
-
navDate = dat['date']
|
|
262
|
-
d = datetime.datetime.strptime(navDate, '%d-%m-%Y')
|
|
263
|
-
if d.year == int(year):
|
|
264
|
-
data.append(dat)
|
|
265
|
-
if len(data) == 0:
|
|
266
|
-
data.append({'Error': 'For Year '+str(year)+' Data is NOT available'})
|
|
267
|
-
|
|
268
|
-
scheme_info.update(data=data)
|
|
269
|
-
return render_response(scheme_info, as_json, as_dataframe)
|
|
270
|
-
else:
|
|
271
|
-
return None
|
|
272
|
-
|
|
273
|
-
@deprecated(version='2.7',
|
|
240
|
+
@deprecated(version='3.1',
|
|
274
241
|
reason="This function will be in deprecated from next release, use mf.history() to get data")
|
|
275
242
|
def get_scheme_historical_nav_for_dates(self, code, start_date, end_date, as_json=False, as_dataframe=False):
|
|
276
243
|
"""
|
|
@@ -289,8 +256,6 @@ class Mftool:
|
|
|
289
256
|
data = []
|
|
290
257
|
start_date = datetime.datetime.strptime(start_date, '%d-%m-%Y').date()
|
|
291
258
|
end_date = datetime.datetime.strptime(end_date, '%d-%m-%Y').date()
|
|
292
|
-
# url = self._get_scheme_url + code
|
|
293
|
-
# response = self._session.get(url).json()
|
|
294
259
|
nav = self.get_scheme_historical_nav(code)
|
|
295
260
|
scheme_info = self.get_scheme_details(code)
|
|
296
261
|
for dat in nav['data']:
|
|
@@ -306,110 +271,103 @@ class Mftool:
|
|
|
306
271
|
else:
|
|
307
272
|
return None
|
|
308
273
|
|
|
309
|
-
def get_open_ended_equity_scheme_performance(self, as_json=False):
|
|
274
|
+
def get_open_ended_equity_scheme_performance(self, report_date=None,as_json=False):
|
|
310
275
|
"""
|
|
311
276
|
gets the daily performance of open-ended equity schemes for all AMCs
|
|
277
|
+
:param report_date: date in 'DD-MMM-YYYY' format, if None then it will take last working day
|
|
312
278
|
:return: json format
|
|
313
279
|
:raises: HTTPError, URLError
|
|
314
280
|
"""
|
|
315
281
|
scheme_performance = {}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
scheme_performance[key] = self._get_daily_scheme_performance(
|
|
282
|
+
subCategory = self._open_ended_equity_category
|
|
283
|
+
for key in subCategory:
|
|
284
|
+
scheme_performance[subCategory[key]] = self._get_daily_scheme_performance(self._get_open_ended_equity_scheme_url,report_date,1, key)
|
|
319
285
|
return render_response(scheme_performance, as_json)
|
|
320
286
|
|
|
321
|
-
def get_open_ended_debt_scheme_performance(self, as_json=False):
|
|
287
|
+
def get_open_ended_debt_scheme_performance(self, report_date=None, as_json=False):
|
|
322
288
|
"""
|
|
323
289
|
gets the daily performance of open-ended debt schemes for all AMCs
|
|
290
|
+
:param report_date: date in 'DD-MMM-YYYY' format, if None then it will take last working day
|
|
324
291
|
:return: json format
|
|
325
292
|
:raises: HTTPError, URLError
|
|
326
293
|
"""
|
|
327
|
-
|
|
294
|
+
subCategory = self._open_ended_debt_category
|
|
328
295
|
scheme_performance = {}
|
|
329
|
-
for key in
|
|
330
|
-
|
|
331
|
-
scheme_performance[key] = self._get_daily_scheme_performance(scheme_performance_url)
|
|
296
|
+
for key in subCategory:
|
|
297
|
+
scheme_performance[subCategory[key]] = self._get_daily_scheme_performance(self._get_open_ended_equity_scheme_url,report_date,2,key)
|
|
332
298
|
return render_response(scheme_performance, as_json)
|
|
333
299
|
|
|
334
|
-
def get_open_ended_hybrid_scheme_performance(self, as_json=False):
|
|
300
|
+
def get_open_ended_hybrid_scheme_performance(self, report_date=None, as_json=False):
|
|
335
301
|
"""
|
|
336
302
|
gets the daily performance of open-ended hybrid schemes for all AMCs
|
|
303
|
+
:param report_date: date in 'DD-MMM-YYYY' format, if None then it will take last working day
|
|
337
304
|
:return: json format
|
|
338
305
|
:raises: HTTPError, URLError
|
|
339
306
|
"""
|
|
340
|
-
|
|
307
|
+
subCategory = self._open_ended_hybrid_category
|
|
341
308
|
scheme_performance = {}
|
|
342
|
-
for key in
|
|
343
|
-
|
|
344
|
-
|
|
309
|
+
for key in subCategory:
|
|
310
|
+
scheme_performance[subCategory[key]] = self._get_daily_scheme_performance(
|
|
311
|
+
self._get_open_ended_equity_scheme_url,report_date, 3, key)
|
|
345
312
|
return render_response(scheme_performance, as_json)
|
|
346
313
|
|
|
347
|
-
def get_open_ended_solution_scheme_performance(self, as_json=False):
|
|
314
|
+
def get_open_ended_solution_scheme_performance(self, report_date=None, as_json=False):
|
|
348
315
|
"""
|
|
349
316
|
gets the daily performance of open-ended Solution-Oriented schemes for all AMCs
|
|
317
|
+
:param report_date: date in 'DD-MMM-YYYY' format, if None then it will take last working day
|
|
350
318
|
:return: json format
|
|
351
319
|
:raises: HTTPError, URLError
|
|
352
320
|
"""
|
|
353
|
-
|
|
321
|
+
subCategory = self._open_ended_solution_category
|
|
354
322
|
scheme_performance = {}
|
|
355
|
-
for key in
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
scheme_performance[key] = self._get_daily_scheme_performance(scheme_performance_url)
|
|
323
|
+
for key in subCategory:
|
|
324
|
+
scheme_performance[subCategory[key]] = self._get_daily_scheme_performance(
|
|
325
|
+
self._get_open_ended_equity_scheme_url, report_date,4, key)
|
|
359
326
|
return render_response(scheme_performance, as_json)
|
|
360
327
|
|
|
361
|
-
def get_open_ended_other_scheme_performance(self, as_json=False):
|
|
328
|
+
def get_open_ended_other_scheme_performance(self, report_date=None, as_json=False):
|
|
362
329
|
"""
|
|
363
330
|
gets the daily performance of open-ended index and FoF schemes for all AMCs
|
|
331
|
+
:param report_date: date in 'DD-MMM-YYYY' format, if None then it will take last working day
|
|
364
332
|
:return: json format
|
|
365
333
|
:raises: HTTPError, URLError
|
|
366
334
|
"""
|
|
367
|
-
|
|
335
|
+
subCategory = self._open_ended_other_category
|
|
368
336
|
scheme_performance = {}
|
|
369
|
-
for key in
|
|
370
|
-
|
|
371
|
-
|
|
337
|
+
for key in subCategory:
|
|
338
|
+
scheme_performance[subCategory[key]] = self._get_daily_scheme_performance(
|
|
339
|
+
self._get_open_ended_equity_scheme_url, report_date,5, key)
|
|
372
340
|
return render_response(scheme_performance, as_json)
|
|
373
341
|
|
|
374
|
-
def _get_daily_scheme_performance(self, performance_url, as_json=False):
|
|
342
|
+
def _get_daily_scheme_performance(self, performance_url,report_date, category,key, as_json=False):
|
|
375
343
|
fund_performance = []
|
|
376
|
-
if
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
html = httpx.get(url, headers=self._user_agent,timeout=25)
|
|
382
|
-
soup = BeautifulSoup(html.text, 'html.parser')
|
|
383
|
-
rows = soup.select("table tbody tr")
|
|
344
|
+
if not report_date:
|
|
345
|
+
if is_holiday():
|
|
346
|
+
report_date = get_friday()
|
|
347
|
+
else:
|
|
348
|
+
report_date = get_today()
|
|
384
349
|
try:
|
|
385
|
-
|
|
350
|
+
data = {"maturityType": 1,"category": category,"subCategory": int(key),"mfid": 0,"reportDate": report_date}
|
|
351
|
+
html = httpx.post(performance_url,headers={"User-Agent":"Mozilla/5.0"},timeout=25, json=data)
|
|
352
|
+
for result in html.json()['data']:
|
|
386
353
|
scheme_details = {}
|
|
387
|
-
|
|
388
|
-
scheme_details['
|
|
389
|
-
scheme_details['
|
|
390
|
-
|
|
391
|
-
scheme_details['
|
|
392
|
-
scheme_details['
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
scheme_details['1-Year Return(%)- Regular'] = regData[0]['data-1y']
|
|
398
|
-
scheme_details['1-Year Return(%)- Direct'] = dirData[0]['data-1y']
|
|
399
|
-
|
|
400
|
-
scheme_details['3-Year Return(%)- Regular'] = regData[0]['data-3y']
|
|
401
|
-
scheme_details['3-Year Return(%)- Direct'] = dirData[0]['data-3y']
|
|
402
|
-
|
|
403
|
-
scheme_details['5-Year Return(%)- Regular'] = regData[0]['data-5y']
|
|
404
|
-
scheme_details['5-Year Return(%)- Direct'] = dirData[0]['data-5y']
|
|
405
|
-
|
|
354
|
+
scheme_details['scheme_name'] = result['schemeName']
|
|
355
|
+
scheme_details['benchmark'] = result['benchmark']
|
|
356
|
+
scheme_details['latest NAV- Regular'] = result['navRegular']
|
|
357
|
+
scheme_details['latest NAV- Direct'] = result['navDirect']
|
|
358
|
+
scheme_details['1-Year Return(%)- Regular'] = result['return1YearRegular']
|
|
359
|
+
scheme_details['1-Year Return(%)- Direct'] = result['return1YearDirect']
|
|
360
|
+
scheme_details['3-Year Return(%)- Regular'] = result['return3YearRegular']
|
|
361
|
+
scheme_details['3-Year Return(%)- Direct'] = result['return3YearDirect']
|
|
362
|
+
scheme_details['5-Year Return(%)- Regular'] = result['return5YearRegular']
|
|
363
|
+
scheme_details['5-Year Return(%)- Direct'] = result['return5YearDirect']
|
|
406
364
|
fund_performance.append(scheme_details)
|
|
407
|
-
|
|
408
365
|
except Exception:
|
|
409
366
|
return render_response(['The underlying data is unavailable for Today'], as_json)
|
|
410
|
-
|
|
411
367
|
return render_response(fund_performance, as_json)
|
|
412
368
|
|
|
369
|
+
@deprecated(version='3.1',
|
|
370
|
+
reason="This function will be in deprecated from next release")
|
|
413
371
|
def get_all_amc_profiles(self, as_json=True):
|
|
414
372
|
"""
|
|
415
373
|
gets profiles for all Fund houses
|
|
@@ -479,7 +437,7 @@ class Mftool:
|
|
|
479
437
|
code = str(code)
|
|
480
438
|
if self.is_code(code):
|
|
481
439
|
def get_Dataframe(df, as_dataframe):
|
|
482
|
-
df = df.drop(columns=['Open', 'High', 'Low','
|
|
440
|
+
df = df.drop(columns=['Open', 'High', 'Low','Volume'])
|
|
483
441
|
df = df.rename(columns={'Close': 'nav'})
|
|
484
442
|
df['dayChange'] = df['nav'].diff()
|
|
485
443
|
df = df.rename_axis('date')
|
|
@@ -7,13 +7,13 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="mftool",
|
|
10
|
-
version="
|
|
10
|
+
version="3.0",
|
|
11
11
|
author="SujitN",
|
|
12
12
|
author_email="nayakwadi_sujit@rediffmail.com",
|
|
13
13
|
description="Library for getting real time Mutual funds info",
|
|
14
14
|
license="MIT",
|
|
15
15
|
keywords="amfi, quote, mutual-funds, funds, bse, nse, market, stock, stocks",
|
|
16
|
-
install_requires=['requests', 'bs4', 'httpx','pandas','yfinance','
|
|
16
|
+
install_requires=['requests', 'bs4', 'httpx', 'pandas', 'yfinance', 'matplotlib'],
|
|
17
17
|
url="https://github.com/NayakwadiS/mftool",
|
|
18
18
|
packages=find_packages(),
|
|
19
19
|
long_description=long_description,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|