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?
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.
<dependency>
<groupId>com.webencyclop.core</groupId>
<artifactId>mftool-java</artifactId>
<version>1.0.4</version>
</dependency>
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
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.
Multiple methods provide ways to work with mutual funds and related data. Those are listed below in detail.
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);
}
}
@Service
public class MyService {
@Autowired
private MFTool tool;
public List<SchemeNameCodePair> fetchListOfAllMutualFundSchemes() {
List<SchemeNameCodePair> list = tool.allSchemes();
}
}
@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.
}
}
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);
}
}
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);
}
}
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);
}
}
This repository is maintained actively, so if you face any issue please raise an issue.
Give the repository a star :-)