Skip to main content

License Actions Status Release

Fetch Vietnam stock market data from public sources.

Core features

Feature Business impact
Symbol information Research stocks and ETFs with profiles, exchanges, instrument types, indices, and industries.
Ticker quotes Fetch a ticker's quote to support market monitoring and pricing views.
Ticker history Fetch historical market data for trend analysis, investment research, and backtesting.
Index quotes Monitor supported market benchmarks with index values, OHLC, and volume.
Index history Analyze daily benchmark values, trends, and trading activity.
Index membership Build watchlists from index constituents or exchange-wide symbol lists.
Sector membership Build industry-focused watchlists for peer comparisons and sector research.
Sector snapshots Compare sector price returns, traded activity, and market capitalization.
Corporate actions Review announced dividends, share entitlements, issuance, and shareholder meetings.

Usage

Stock, index, sector, and event lookups are asynchronous. Stock ticker inputs, including event symbol filters, accept CODE, EXCHANGE:CODE, or CODE.VN. The CODE.VN form is supported for compatibility with yfinance. Case and surrounding whitespace are ignored.

Public functions return ticker symbols in CODE or EXCHANGE:CODE format.

By default, single-ticker stock lookups return None for unavailable symbols or lookup failures. Bulk profile lookups omit unavailable symbols and return {} on exceptions. Pass raise_on_error=True to re-raise lookup exceptions.

Research a company's profile

Use stocks.get_info to retrieve the company name, listing exchange, and available industry classifications.

import asyncio

from vfinance import stocks


async def main() -> None:
    info = await stocks.get_info("HOSE:BID")
    if info is None:
        print("Company profile is unavailable.")
    else:
        print(f"{info.symbol} ({info.exchange}): {info.name}")
        if info.industry is not None:
            print(f"Industry: {info.industry}")


asyncio.run(main())

Use await stocks.get_info_multi(["BID", "CTG"]) to research multiple companies at once. Results map uppercase ticker codes to profiles by default, with unavailable profiles omitted. Supply include_exchange_prefix for EXCHANGE:CODE keys, such as HOSE:BID; the keyword's value is ignored.

View the latest available quote

Use stocks.get_quote to view the latest available market price, OHLC prices, and traded volume.

import asyncio

from vfinance import stocks


async def main() -> None:
    quote = await stocks.get_quote("BID")
    if quote is None:
        print("Quote is unavailable.")
    else:
        print(f"Market price: {quote.market_price:,.0f} VND")
        print(f"As of: {quote.timestamp_str}")
        print("OHLC:", quote.open, quote.high, quote.low, quote.close)
        print(f"Volume: {quote.volume:,} traded units")


asyncio.run(main())

Prices are in VND per traded unit; volume counts traded units. A closing price can be None if it has not been finalized.

Analyze daily price history

Use stocks.get_history to retrieve daily quotes for a calendar-day window.

import asyncio

from vfinance import stocks


async def main() -> None:
    history = await stocks.get_history("BID.VN", num_days=30)
    if history is None:
        print("History is unavailable.")
    elif not history:
        print("No daily quotes in this period.")
    else:
        for day in history:
            print(day.timestamp.date(), day.close, day.volume)


asyncio.run(main())

History is ordered oldest to newest and covers calendar days, not a fixed number of trading sessions. The default window is 30 days, ending before today's midnight in Asia/Ho_Chi_Minh; requests are limited to the last five years. A successful lookup with no quotes in the selected period returns [].

Daily quotes include financial actions effective on their ex-rights date in corp_actions, together with a price_adjustment reference price. Distinct actions are retained in an immutable tuple. The reference price is None when the previous close is unavailable; quoted OHLC prices remain unchanged.

View an index quote

Use indices.get_index_quote to monitor VN30, VN100, VNINDEX, HNX, HNX30, or UPCOM. Index codes ignore case and surrounding whitespace. Values are in index points, not VND.

import asyncio

from vfinance import indices


async def main() -> None:
    quote = await indices.get_index_quote("VN30")
    if quote is None:
        print("Index quote is unavailable.")
    else:
        print(f"{quote.symbol}: {quote.market_price:,.2f} points")
        print(f"As of: {quote.timestamp_str}")


asyncio.run(main())

Unsupported codes and unavailable quotes return None. Input and lookup failures also return None by default; supplying raise_on_error, regardless of its value, re-raises those exceptions.

Analyze daily index history

Use indices.get_index_history to retrieve daily quotes for a supported index. Values remain in index points.

import asyncio

from vfinance import indices


async def main() -> None:
    history = await indices.get_index_history("VN30", num_days=30)
    if history is None:
        print("Index history is unavailable.")
    elif not history:
        print("No daily quotes in this period.")
    else:
        for day in history:
            print(f"{day.timestamp.date()}: {day.market_price:,.2f} points")


asyncio.run(main())

Results are ordered oldest to newest for the requested calendar-day window, excluding today and limited to the last five years. The default window is 30 days. Empty periods return []; unsupported indices and unavailable history return None. Input and lookup failures follow the same raise_on_error behavior as index quotes.

Find an index's members

Use indices.get_index_members to retrieve symbols in VN30, VN100, HNX30, or VNIndex, or explore the exchange-wide HOSE, HNX, and UPCOM lists. Index codes ignore case and surrounding whitespace. Returned members are uppercase bare ticker codes by default, such as ["BID", "CTG"]. Supply include_exchange_prefix to return EXCHANGE:CODE symbols, such as ["HOSE:BID", "HOSE:CTG"]; the keyword's value is ignored.

import asyncio

from vfinance import indices


async def main() -> None:
    members = await indices.get_index_members("VN30")
    if not members:
        print("Index membership is unavailable.")
    else:
        print("VN30 members:", ", ".join(members))
        print("BID is in VN30:", "BID" in members)


asyncio.run(main())

Unsupported codes, unavailable member lists, and unexpected failures return []. Pass raise_on_error=True to re-raise unexpected exceptions. Exchange-wide lists may include other listed instruments, not only stocks.

Find a sector's members

Use sectors.get_sector_members to build industry-focused watchlists. Pass an industry-group name or a sector slug, such as ngan-hang for banking. Case, punctuation, and repeated whitespace are normalized. Returned members use the same bare ticker-code format, such as ["BID", "CTG"].

Get supported sector slugs and their Vietnamese industry-group names with await sectors.get_sector_list().

import asyncio

from vfinance import sectors


async def main() -> None:
    members = await sectors.get_sector_members("ngan-hang")
    if not members:
        print("Sector membership is unavailable.")
    else:
        print("Banking sector:", ", ".join(members))


asyncio.run(main())

Unsupported sectors, unavailable member lists, and unexpected failures return []. Pass raise_on_error=True to re-raise unexpected exceptions.

Compare sector trading snapshots

Use sectors.get_all_sector_snapshots for a dictionary keyed by sector slug, or sectors.get_sector_snapshot for one supported industry-group name or slug.

import asyncio

from vfinance import sectors


async def main() -> None:
    snapshots = await sectors.get_all_sector_snapshots()
    for slug, snapshot in snapshots.items():
        print(slug, snapshot.volatility, snapshot.volume)

    banking = await sectors.get_sector_snapshot("ngan-hang")
    if banking is not None:
        print(banking.timestamp_str, banking.market_cap, banking.gross_trade_value)


asyncio.run(main())

Returns use percentage points, volume counts shares, and capitalization and traded value use VND. These snapshots describe sector activity and returns, not sector index levels or OHLC history. The bulk lookup returns {} when no snapshots are available; an unsupported or unavailable single sector returns None. Unexpected failures use the same defaults and can be re-raised with raise_on_error=True.

Review current and upcoming corporate actions

Use events.get_upcoming_corp_actions to review announced corporate actions across symbols, or combine symbol and action-type filters for a focused view.

import asyncio

from vfinance import events, utils


async def main() -> None:
    actions = await events.get_upcoming_corp_actions(
        filter_symbol="FPT.VN",
        filter_action_type=utils.DIVIDEND,
        raise_on_error=True,
    )
    for action in actions:
        print(action.symbol, action.ex_rights_date_str, action.amount)


asyncio.run(main())

Omit either filter to include all symbols or action types. Action codes are available as string constants in utils: DIVIDEND, BONUS_SHARES, STOCK_DIVIDEND, EGM, AGM, ISSUE_SHARES, and OTHER. These seven codes form the utils.CorpActionType type used by models.CorpAction.

Plain string filters also remain supported; matching ignores case and surrounding whitespace. Unsupported filter codes and filters with no matching actions return [].

Results are immutable models.CorpAction entries with announcement details, entitlement dates, scheduled action dates, and applicable cash amounts in VND per share or new/offered shares per existing share. A scheduled action date may be None, and an unavailable announcement URL is empty. New or revised announcements may not appear immediately.

Failures also return [] by default. Supply raise_on_error to re-raise the original exception instead; the keyword's value is ignored.

Keep ticker identifiers consistent across datasets

Use utils.normalize_ticker to turn supported ticker formats into a consistent bare symbol.

from vfinance.utils import normalize_ticker

print(normalize_ticker("BID"))
print(normalize_ticker("HOSE:BID"))
print(normalize_ticker("BID.VN"))

Each call returns BID.

Export results as JSON

Profiles, quotes, and corporate actions can be exported as JSON, including ISO-formatted dates and timestamps. For example, export BID's latest available quote:

import asyncio

from vfinance import stocks


async def main() -> None:
    quote = await stocks.get_quote("BID")
    if quote is not None:
        print(quote.model_dump_json(indent=2))


asyncio.run(main())

Data Coverage, Limitations and Disclaimer

Data coverage

vfinance covers stocks traded on Vietnam's HOSE, HNX, and UPCOM markets.

Limitations

  • Data is fetched from public sources/APIs, and availability depends on those providers.
  • Results are cached for a limited period to reduce repeated requests and help avoid overloading public sources/APIs.
  • Quotes are not guaranteed to be real-time and may be delayed. Their freshness depends on the underlying sources and their update frequency.

Disclaimer

Data is provided "as is". vfinance and its maintainers make no guarantees about its quality, accuracy, completeness, or timeliness, and accept no responsibility for the quality or correctness of the data. Verify data independently before relying on it.

License

This package is licensed under the MIT License - see the LICENSE.md file for details.

Contributing & Support

Feel free to create pull requests or issues to report bugs or suggest new features.

Metadata

Release files for vfinance 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vfinance 0.3.2
File Size Uploaded Provenance Actions
vfinance-0.3.2.tar.gz 165.7 kB Without provenance Details for vfinance-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vfinance 0.3.2
File Interpreter ABI Platform Actions
vfinance-0.3.2-py3-none-any.whl Python 3 none any Details for vfinance-0.3.2-py3-none-any.whl

Total release size: 207.9 kB

Release files / vfinance-0.3.2.tar.gz

Download URL vfinance-0.3.2.tar.gz
Size 165.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b7b87b205d7f4cb6cd267ae51d6d2d699020c22664ca35878373342ffbf38dfe
BLAKE2b-256 checksum
How to use checksums
60ee8c956db6837a77c7781d599064b21e94375cf8a75e203938c6f85cf4dea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / vfinance-0.3.2-py3-none-any.whl

Download URL vfinance-0.3.2-py3-none-any.whl
Size 42.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77959c1790d77d204869b4bd0122d46960f4f6dfbacb501f30e65462fe8e0c09
BLAKE2b-256 checksum
How to use checksums
b94fc85180fb3895bbe3341a2849738c799b0fdd49bce4e21e49391ec3bca056
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for vfinance 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page