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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mftool
3
- Version: 2.9
3
+ Version: 3.0
4
4
  Summary: Library for getting real time Mutual funds info
5
5
  Home-page: https://github.com/NayakwadiS/mftool
6
6
  Author: SujitN
@@ -21,5 +21,5 @@
21
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  SOFTWARE.
23
23
  """
24
- __VERSION__='2.9'
24
+ __VERSION__='3.0'
25
25
  from .mftool import Mftool
@@ -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": "http://www.valueresearchonline.com/amfi/fund-performance-data/?end-type=1&primary-category=SEQ&category=CAT&amc=ALL",
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
- "Large Cap": "SEQ_LC",
12
- "Large & Mid Cap": "SEQ_LMC",
13
- "Multi Cap": "SEQ_MLC",
14
- "Mid Cap": "SEQ_MC",
15
- "Small Cap": "SEQ_SC",
16
- "Value": "SEQ_VAL",
17
- "ELSS": "SEQ_ELSS",
18
- "Contra": "SEQ_CONT",
19
- "Dividend Yield": "SEQ_DIVY",
20
- "Focused": "SEQ_FOC"
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": "SDT_LND",
24
- "Medium to Long Duration": "SDT_MLD",
25
- "Medium Duration": "SDT_MD",
26
- "Short Duration": "SDT_SD",
27
- "Low Duration": "SDT_LWD",
28
- "Ultra Short Duration": "SDT_USD",
29
- "Liquid": "SDT_LIQ",
30
- "Money Market": "SDT_MM",
31
- "Overnight": "SDT_OVNT",
32
- "Dynamic Bond": "SDT_DB",
33
- "Corporate Bond": "SDT_CB",
34
- "Credit Risk": "SDT_CR",
35
- "Banking and PSU": "SDT_BPSU",
36
- "Floater": "SDT_FL",
37
- "FMP": "SDT_FMP",
38
- "Gilt": "SDT_GL",
39
- "Gilt with 10 year constant duration": "SDT_GL10CD"
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": "SHY_AH",
43
- "Balanced Hybrid": "SHY_BH",
44
- "Conservative Hybrid": "SHY_CH",
45
- "Equity Savings": "SHY_EQS",
46
- "Arbitrage": "SHY_AR",
47
- "Multi Asset Allocation": "SHY_MAA"
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": "SSO_CHILD",
51
- "Retirement": "SSO_RETR"
52
+ "36":"Children's",
53
+ "37":"Retirement"
52
54
 
53
55
  },
54
56
  "open_ended_other_category": {
55
- "Index Funds/ETFs": "SOTH_IXETF",
56
- "FoFs(Oversease/Domestic)": "SOTH_FOFS"
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='2.8',
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
- for key in self._open_ended_equity_category.keys():
317
- scheme_performance_url = self._get_open_ended_equity_scheme_url.replace('CAT', self._open_ended_equity_category[key])
318
- scheme_performance[key] = self._get_daily_scheme_performance(scheme_performance_url)
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
- get_open_ended_debt_scheme_url = self._get_open_ended_equity_scheme_url.replace('SEQ', 'SDT')
294
+ subCategory = self._open_ended_debt_category
328
295
  scheme_performance = {}
329
- for key in self._open_ended_debt_category.keys():
330
- scheme_performance_url = get_open_ended_debt_scheme_url.replace('CAT', self._open_ended_debt_category[key])
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
- get_open_ended_debt_scheme_url = self._get_open_ended_equity_scheme_url.replace('SEQ', 'SHY')
307
+ subCategory = self._open_ended_hybrid_category
341
308
  scheme_performance = {}
342
- for key in self._open_ended_hybrid_category.keys():
343
- scheme_performance_url = get_open_ended_debt_scheme_url.replace('CAT',self._open_ended_hybrid_category[key])
344
- scheme_performance[key] = self._get_daily_scheme_performance(scheme_performance_url)
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
- get_open_ended_solution_scheme_url = self._get_open_ended_equity_scheme_url.replace('SEQ', 'SSO')
321
+ subCategory = self._open_ended_solution_category
354
322
  scheme_performance = {}
355
- for key in self._open_ended_solution_category.keys():
356
- scheme_performance_url = get_open_ended_solution_scheme_url.replace('CAT',
357
- self._open_ended_solution_category[key])
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
- get_open_ended_other_scheme_url = self._get_open_ended_equity_scheme_url.replace('SEQ', 'SOTH')
335
+ subCategory = self._open_ended_other_category
368
336
  scheme_performance = {}
369
- for key in self._open_ended_other_category.keys():
370
- scheme_performance_url = get_open_ended_other_scheme_url.replace('CAT', self._open_ended_other_category[key])
371
- scheme_performance[key] = self._get_daily_scheme_performance(scheme_performance_url)
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 is_holiday():
377
- url = performance_url + '&nav-date=' + get_friday()
378
- else:
379
- url = performance_url + '&nav-date=' + get_today()
380
- # html = requests.get(url, headers=self._user_agent)
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
- for tr in rows:
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
- cols = tr.select("td.nav.text-right")
388
- scheme_details['scheme_name'] = tr.select("td")[0].get_text()
389
- scheme_details['benchmark'] = tr.select("td")[1].get_text()
390
-
391
- scheme_details['latest NAV- Regular'] = tr.select("td")[2].get_text().strip()
392
- scheme_details['latest NAV- Direct'] = tr.select("td")[3].get_text().strip()
393
-
394
- regData = tr.find_all("td", recursive=False,class_="text-right period-return-reg", limit=1)
395
- dirData = tr.find_all("td", recursive=False, class_="text-right period-return-dir", limit=1)
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','Adj Close','Volume'])
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')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mftool
3
- Version: 2.9
3
+ Version: 3.0
4
4
  Summary: Library for getting real time Mutual funds info
5
5
  Home-page: https://github.com/NayakwadiS/mftool
6
6
  Author: SujitN
@@ -3,4 +3,4 @@ bs4
3
3
  httpx
4
4
  pandas
5
5
  yfinance
6
- Deprecated
6
+ matplotlib
@@ -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="2.9",
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','Deprecated'],
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