Skip to content

ankitwasankar/mftool-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 

This repository contains the MF TOOL - JAVA source code. MF TOOL - JAVA is a Java library developed to ease the process of working with Indian Mutual Funds. It's powerful, actively maintained and easy to use.

Introduction  •  Installation  •  Usage  •  Documentation  •  Issue?

Introduction

This mf-tool java library provides simple APIs/functions/methods to work with Indian Mutual Funds. You can:

  • Fetch a list of all mutual fund schemes.
  • Fetch a list of matching mutual fund schemes based on provided keywords.
  • Fetch historic or current NAV (Net Asset Value) for a fund.
  • Fetch details for a fund and fund house.
  • Integrate this with any Java project.

Installation

Maven
<dependency>
  <groupId>com.webencyclop.core</groupId>
  <artifactId>mftool-java</artifactId>
  <version>1.0.4</version>
</dependency>
Graddle
implementation 'com.webencyclop.core:mftool-java:1.0.4'

For other dependency management tool, please visit https://search.maven.org/artifact/com.webencyclop.core/mftool-java

Usage

Sample code that shows how to use the library:

MFTool tool = new MFTool();
tool.matchingScheme("Axis");   //-- get a list of all schemes with Axis in its name
tool.getCurrentNav("120503");  //-- get current nav

The other available methods are described in the next section.

Documentation

Multiple methods provide ways to work with mutual funds and related data. Those are listed below in detail.

1. How to initialize an MFTool object

MFTool tool = new MFTool();

This will create the object for you, but it's recommended that you create this object as a singleton object. The object uses a caching mechanism, which under-the-hood caches the values of historic nav and other static information to improve the performance.
If you are using the Spring project, you can create the bean in @Configuration configuration class.

@Configuration
public class MFToolConfig{
    @Bean
    public MFTool initializeMfTool() {
        MFTool tool = new MFTool();
        return tool;
    }
}

You can use MFTool in other services using @Inject or @autowired annotation.

@Service
public class MyService {
    
    @Autowired
    private MFTool tool;

    public void getCurrentNav(String scheme) {
        BigDecimal nav = tool.getCurrentNav(scheme);
    }
}

2. How to fetch a list of all mutual fund schemes

@Service
public class MyService {
    
    @Autowired
    private MFTool tool;

    public List<SchemeNameCodePair> fetchListOfAllMutualFundSchemes() {
        List<SchemeNameCodePair> list = tool.allSchemes();
    }
}

3. How to fetch a list of all schemes matching a keyword

@Service
public class MyService {
    
    @Autowired
    private MFTool tool;

    public List<SchemeNameCodePair> getCurrentNav(String schemeCode) {
        List<SchemeNameCodePair> list = tool.matchingScheme("Axis"); 
        // This will fetch MF schemes that have "Axis" in the name.
    }
}

4. Current NAV for the mutual fund scheme

An example schemeCode is 120503 (Axis Long Term Equity Fund - Direct Plan - Growth Option).
When we fetch a list of mutual funds, we get the scheme-name, and its corresponding schemeCode.
A scheme code uniquely identifies the mutual fund scheme.

@Service
public class MyService {
    
    @Autowired
    private MFTool tool;

    public List<SchemeNameCodePair> fetchListSchemes(String schemeCode) {
        BigDecimal nav = tool.getCurrentNav(schemeCode);
    }
}

5. NAV on specific date for the scheme

LocalDate is used to define the date. For example:
LocalDate date = LocalDate.parse("2021-07-13");

@Service
public class MyService {
    
    @Autowired
    private MFTool tool;

    public List<SchemeNameCodePair> getNavOnDate(String schemeCode, LocalDate date) {
        BigDecimal nav = tool.getNavFor("120503", date);
    }
}

6. List of historic NAV for the scheme

This method provides a list of all the NAVs for the given scheme.

@Service
public class MyService {
    
    @Autowired
    private MFTool tool;

    public List<SchemeNameCodePair> getNavOnDate(String schemeCode) {
        List<Data> list = tool.historicNavForScheme(schemeCode);
    }
}

Issue

This repository is maintained actively, so if you face any issue please raise an issue.

Liked the work ?

Give the repository a star :-)