Skip to main content
Glama
ariesanhthu

VNStock MCP Server

by ariesanhthu

get_all_symbols_by_industry

Retrieve stock symbols from Vietnam's market filtered by industry sector, with options for JSON or DataFrame output formats.

Instructions

Get all symbols from stock market
Args:
    industry: str = None (if None, return all symbols)
    output_format: Literal['json', 'dataframe'] = 'json'
Returns:
    pd.DataFrame or json

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
industryNo
output_formatNojson

Implementation Reference

  • The handler function for the 'get_all_symbols_by_industry' tool. It retrieves all symbols grouped by industries using VCIListing.symbols_by_industries(), optionally filters by a specific industry code across ICB code columns, and returns the result in JSON or DataFrame format. The @server.tool() decorator registers this function as an MCP tool.
    @server.tool()
    def get_all_symbols_by_industry(
        industry: str = None, output_format: Literal["json", "dataframe"] = "json"
    ):
        """
        Get all symbols from stock market
        Args:
            industry: str = None (if None, return all symbols)
            output_format: Literal['json', 'dataframe'] = 'json'
        Returns:
            pd.DataFrame or json
        """
        listing = VCIListing()
        df = listing.symbols_by_industries()
        if industry:
            codes = ["icb_code1", "icb_code2", "icb_code3", "icb_code4"]
            masks = []
            for col in codes:
                if col in df.columns:
                    masks.append(df[col].astype(str) == industry)
            if masks:
                mask = masks[0]
                for m in masks[1:]:
                    mask = mask | m
                df = df[mask]
        if output_format == "json":
            return df.to_json(orient="records", force_ascii=False)
        else:
            return df

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ariesanhthu/mcp-server-vietnam-stock-trading'

If you have feedback or need assistance with the MCP directory API, please join our Discord server