Skip to main content

A Python package for fetching Vietnamese stock market data from multiple sources

Project description

vntickers

A unified Python package for fetching Vietnamese stock market data. This package combines vnstock, vnquant, and vietfin into a single source of truth for retrieving OHLCV (Open, High, Low, Close, Volume) and close prices for stock analysis in the Vietnamese market.

Installation

From source (development)

git clone https://github.com/gahoccode/vntickers.git
cd vntickers
uv sync

Add to your project

uv add vntickers

Usage

Using vnstock (VCI source)

from vntickers.loader import VNStockData

stocks = ["VNM", "VCB", "HPG"]
start_date = "2024-01-01"
end_date = "2024-12-31"

df = VNStockData.get_close_prices_vns(
    symbols=stocks,
    start_date=start_date,
    end_date=end_date,
    interval="1D"
)
print(df.head())

Using vnquant

from vntickers.loader import VNStockData

stocks = ["VNM", "VCB", "HPG"]
start_date = "2024-01-01"
end_date = "2024-12-31"

df = VNStockData.get_close_prices_vnq(
    symbols=stocks,
    start_date=start_date,
    end_date=end_date
)
print(df.head())

Using vietfin (Recommended - Modern API)

from vntickers import VietfinLoader
from datetime import date

# Daily data for multiple stocks (DNSE or TCBS)
df = VietfinLoader.get_close_prices(
    symbols=["VNM", "VCB", "HPG"],
    start_date=date(2024, 1, 1),
    end_date=date(2024, 12, 31),
    provider="dnse",  # or "tcbs"
    interval="1d"
)
print(df.head())

# Intraday data - hourly (DNSE only, single symbol, max 90 days)
df_hourly = VietfinLoader.get_close_prices(
    symbols="VNM",  # Single symbol for intraday
    start_date=date(2024, 10, 1),
    end_date=date(2024, 12, 30),  # Max 90 days
    provider="dnse",
    interval="1h"  # Supported: 1m, 15m, 30m, 1h
)
print(df_hourly.head())

Vietfin Provider Support:

  • DNSE: Supports 1m, 15m, 30m, 1h, 1d
    • Intraday intervals (1m, 15m, 30m, 1h): Single symbol only, max 90 days
    • Daily (1d): Multiple symbols, unlimited range
  • TCBS: Supports 1d only (multiple symbols, unlimited range)

All methods return a pandas DataFrame with:

  • Index: time/date (datetime)
  • Columns: ticker symbols
  • Values: close prices (adjusted close for vnquant)

Requirements

  • Python >=3.10
  • vnstock >=3.2.6
  • vnquant
  • vietfin
  • pandas
  • pydantic

Publishing to PyPI

Prerequisites

  1. Create a PyPI account at https://pypi.org
  2. Create an API token at https://pypi.org/manage/account/token/

Build and Publish

# Build the package
uv build

# Publish to PyPI (you'll be prompted for your API token)
uv publish

# Or use token directly
uv publish --token <your-pypi-token>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vntickers-0.2.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vntickers-0.2.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file vntickers-0.2.0.tar.gz.

File metadata

  • Download URL: vntickers-0.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for vntickers-0.2.0.tar.gz
Algorithm Hash digest
SHA256 50f2c0fbf2ce9044a53f1323bc54017c4b5554047e51edbd0d0a4b3c9d97046d
MD5 72aefeb00b64e045c7b018566f67c4e8
BLAKE2b-256 499f3f14c25e8d57123f8043aebe8c356b95891dd79d9d4ed4489be4abefa6a8

See more details on using hashes here.

File details

Details for the file vntickers-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vntickers-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for vntickers-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f54208d2e04689a50c79d5bff80936f41319be2d356706b4cfad963ddec5aecb
MD5 6efab8ad01b138761cf71f10273cf2ed
BLAKE2b-256 a7b69995b72601006875218471be9ede6fc1413d36abedcf3b1fa820420e2940

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page