A beginner-friendly yet powerful Python toolkit for financial analysis and automation — built to make modern investing accessible to everyone
The Fund class provides comprehensive access to Vietnamese mutual fund data including fund listings, portfolio holdings, NAV history, and asset allocation analysis through the Fmarket data source.
Comprehensive mutual fund data access with portfolio analysis capabilities.
class Fund:
"""
Mutual fund data adapter for Vietnamese fund market.
Data source: FMARKET
"""
def __init__(self, random_agent: bool = False) -> None:
"""
Initialize Fund data adapter.
Args:
random_agent (bool): Use random user agent, defaults to False
"""
# Instance attributes (populated after initialization)
fund_list: list
"""List of available fund short names."""
details: FundDetails
"""Instance of FundDetails class for symbol-based operations."""Fund listing and discovery capabilities with type-based filtering.
def listing(self, fund_type: str = "") -> pd.DataFrame:
"""
Get all available mutual funds with optional type filtering.
Args:
fund_type (str): Fund type filter ("", "BALANCED", "BOND", "STOCK")
Returns:
pd.DataFrame: Fund listing with basic information
"""
def filter(self, symbol: str = "") -> pd.DataFrame:
"""
Filter funds by short name pattern.
Args:
symbol (str): Fund short name or pattern
Returns:
pd.DataFrame: Filtered fund results
"""Detailed fund portfolio composition and holdings analysis.
def top_holding(self, fundId: int = 23) -> pd.DataFrame:
"""
Get top 10 holdings of specified fund.
Args:
fundId (int): Fund ID, defaults to 23
Returns:
pd.DataFrame: Top holdings with allocation percentages
"""
def industry_holding(self, fundId: int = 23) -> pd.DataFrame:
"""
Get industry distribution of fund portfolio.
Args:
fundId (int): Fund ID, defaults to 23
Returns:
pd.DataFrame: Industry allocation breakdown
"""
def asset_holding(self, fundId: int = 23) -> pd.DataFrame:
"""
Get asset allocation of fund portfolio.
Args:
fundId (int): Fund ID, defaults to 23
Returns:
pd.DataFrame: Asset class allocation breakdown
"""Fund performance metrics and NAV history tracking.
def nav_report(self, fundId: int = 23) -> pd.DataFrame:
"""
Get daily NAV (Net Asset Value) history.
Args:
fundId (int): Fund ID, defaults to 23
Returns:
pd.DataFrame: Historical NAV data with dates and values
"""Symbol-based fund operations for detailed analysis.
class FundDetails:
"""Fund details operations using fund symbols."""
def top_holding(self, symbol: str = "SSISCA") -> pd.DataFrame:
"""Get top holdings by fund symbol."""
def industry_holding(self, symbol: str = "SSISCA") -> pd.DataFrame:
"""Get industry distribution by fund symbol."""
def nav_report(self, symbol: str = "SSISCA") -> pd.DataFrame:
"""Get NAV report by fund symbol."""
def asset_holding(self, symbol: str = "SSISCA") -> pd.DataFrame:
"""Get asset allocation by fund symbol."""from vnstock import Fund
# Initialize fund adapter
fund = Fund()
# Get all available funds
all_funds = fund.listing()
# Get stock funds only
stock_funds = fund.listing(fund_type="STOCK")
# Get specific fund details
fund_holdings = fund.top_holding(fundId=23)
fund_industries = fund.industry_holding(fundId=23)
fund_nav = fund.nav_report(fundId=23)
# Use fund details by symbol
details = fund.details
ssisca_holdings = details.top_holding(symbol="SSISCA")
ssisca_nav = details.nav_report(symbol="SSISCA")
# Get fund list for reference
available_funds = fund.fund_list
print(f"Available funds: {len(available_funds)}")Install with Tessl CLI
npx tessl i tessl/pypi-vnstock