How to get real-time Mutual Funds Information using Python?

In this article, we are going to write Python scripts to real-time Mutual Funds Information. Today Mutual Funds is a very popular term among investors, so let’s do some help for them. Mftool Modules will help to collect real-time data from AFM(Association of Mutual Funds).

Features of Mftool:

  • Get last update quotes from Mutual Fund using scheme codes.
  • Get all the register Schemes available in AMF
  • Get Net Asset Value (NAV) track record
  • Get all the list of Schemes with there Scheme codes.

Note: This module is able to collect data from The Association of Mutual Funds in India.

Before starting we need to install this module:

Run this module into your terminal.



pip install mftool

Let’s Understand these modules Step-by-step:

Step 1: import module and create an object for Mftool.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# import module
from mftool import Mftool
  
  
obj = Mftool()

chevron_right


Step 2: Getting a Scheme Quote with get_scheme_quote() methods.

Note: All scheme codes are presented here : Click 

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# pass the scheme code into 
# methods
data = obj.get_scheme_quote('119551')
print(data)

chevron_right


Output:



Step 3: Get Scheme Details with specific Scheme code using get_scheme_details() methods.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

obj.get_scheme_details("119551")

chevron_right


Output:

Step 4: Get Scheme Historical NAV’s data using get_scheme_historical_nav() methods.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

data = mf.get_scheme_historical_nav("119551")
print(data)

chevron_right


Output:

Note: This data is in the Dictionary form.

Now we can manipulate this data with our own needs.



Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# dict demonstration
data['fund_house']

chevron_right


Output:

'Aditya Birla Sun Life Mutual Fund'

List of the Historical NAV data.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

data['data']

chevron_right


Output:

[{'date': '25-09-2020', 'nav': '156.32930'},
 {'date': '24-09-2020', 'nav': '156.37000'},
 {'date': '23-09-2020', 'nav': '156.40260'},
 {'date': '22-09-2020', 'nav': '156.34590'},
 {'date': '21-09-2020', 'nav': '156.29950'},
 {'date': '18-09-2020', 'nav': '156.20390'},
 {'date': '17-09-2020', 'nav': '156.16490'},
 {'date': '16-09-2020', 'nav': '156.11460'},
 {'date': '15-09-2020', 'nav': '156.00040'},
 {'date': '14-09-2020', 'nav': '156.12840'},
 {'date': '11-09-2020', 'nav': '156.11520'},
 ....

Step 5: List of Mutual Funds Scheme Codes & Names with get_scheme_codes() method.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

data = obj.get_scheme_codes() 
print(data)

chevron_right


Output:

Step 6: Get daily performance of equity schemes with get_open_ended_equity_scheme_performance() module. 



Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

data = obj.get_open_ended_equity_scheme_performance(True)
print(data)

chevron_right


Output:

{"Large Cap": [{"scheme_name": "Aditya Birla Sun Life Frontline Equity", 
"benchmark": "NIFTY 50 Total Return Index", 
"latest NAV- Regular": "210.1600", 
"latest NAV- Direct": "224.8700", 
"1-Year Return(%)- Regular": "-4.65", 
"1-Year Return(%)- Direct": "-4.02",
 "3-Year Return(%)- Regular": "0.21", 
 "3-Year Return(%)- Direct": "1.03", 
 "5-Year Return(%)- Regular": "5.97", 
 "5-Year Return(%)- Direct": "6.93"},
 .........

Step 7: Get daily performance of debt schemes with get_open_ended_debt_scheme_performance() module.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

value = obj.get_open_ended_debt_scheme_performance(True)
print(value)

chevron_right


Output:

{"Long Duration": [{"scheme_name": "ICICI Prudential Long Term Bond Fund", 
"benchmark": "NIFTY Long Duration Debt Total Return Index", 
"latest NAV- Regular": "70.0523",
"latest NAV- Direct": "74.6568",
"1-Year Return(%)- Regular": "11.13",
"1-Year Return(%)- Direct": "11.68",
"3-Year Return(%)- Regular": "8.52",
............

Step 7: All AMC profiles with get_all_amc_profiles() module.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

data = obj.get_all_amc_profiles(True)
print(data)

chevron_right


Output:

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.