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 membership | Build watchlists from index constituents or exchange-wide symbol lists. |
| Sector membership | Build industry-focused watchlists for peer comparisons and sector research. |
Usage
Stock, index, and sector lookups are asynchronous. Public functions accept stock
ticker inputs in CODE, EXCHANGE:CODE, or CODE.VN format. 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 [].
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 indices.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"].
import asyncio
from vfinance import indices
async def main() -> None:
members = await indices.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.
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 and quotes can be exported as JSON, including ISO-formatted timestamps for quotes. 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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vfinance-0.2.0.tar.gz | 109.3 kB | Without provenance | Details for vfinance-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vfinance-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for vfinance-0.2.0-py3-none-any.whl |
Total release size: 134.5 kB
Release files / vfinance-0.2.0.tar.gz
| Download URL | vfinance-0.2.0.tar.gz |
|---|---|
| Size | 109.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73041e07d443dd96941fe138aecf086c17adb6b21f27c209584a425686ef0417
|
|
BLAKE2b-256 checksum How to use checksums |
5780104ec4ae0f37c241c69cdc456c8b8d40a364fa847a18c687e81ec0bd7fea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","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.2.0-py3-none-any.whl
| Download URL | vfinance-0.2.0-py3-none-any.whl |
|---|---|
| Size | 25.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab3bfbf130c1836c1bfddc9845cdecc44b81e3192fd1a134d65b3198bd5fe589
|
|
BLAKE2b-256 checksum How to use checksums |
5cb8f130ef781d01e60886b31312065109b446efbe52a25649bda464c01b9cbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","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.2.0
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.