Registry / data / vnstock

vnstock

JSON →
library4.0.2pypypi✓ verified 86d ago

A beginner-friendly Python toolkit for financial analysis and automation, targeting the Vietnamese stock market. Version 4.0.2 (as of 2026-05-09) supports Python >=3.10. Released approximately every 2-4 weeks.

pip install vnstock
INSTALL
IMPORT
SIG · VNSTOCK
V
vnstock
datapythonv4.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Vnstock
from vnstock import Vnstock
from vnstock.vnstock import Vnstock
v4 changed package structure; old import fails if Vnstock is not in submodule.
Stock
from vnstock import Stock
from vnstock.core import Stock
v4 moved Stock to top-level.
Analysis
from vnstock import Analysis
from vnstock.analysis import Analysis
v4 moved Analysis to top-level.
Trading
from vnstock import Trading
from vnstock.core import Trading
v4 moved Trading to top-level.

Initialize Vnstock, login, fetch historical prices for a symbol.

from vnstock import Vnstock stock = Vnstock() stock.login(os.environ.get('VNSTOCK_USERNAME', ''), os.environ.get('VNSTOCK_PASSWORD', '')) df = stock.stock.historical_price(symbol='ACB', start='2025-01-01', end='2025-12-31') print(df.head())
Debug
Known issues
breakingv4.0.0 removed the `vnstock.vnstock` submodule; all major classes are now at package root.
fix
Change imports from `vnstock.vnstock` to `vnstock` (e.g., `from vnstock import Vnstock`).
affects: >=4.0.0
breakingLogin method changed from `login(u, p)` to `login(username, password)` and no longer accepts a broker parameter.
fix
Use `stock.login(username=..., password=...)`. Remove broker argument.
affects: >=4.0.0
breaking`Stock.historical_price()` now returns a DataFrame with columns `['time', 'open', 'high', 'low', 'close', 'volume']` instead of `['ticker', 'date', 'open', 'high', 'low', 'close', 'volume']`. Column `date` renamed to `time`.
fix
Update any code that references `df['ticker']` or `df['date']` to use `df['time']`.
affects: >=4.0.0
deprecatedThe old `vnstock.analysis` and `vnstock.core` modules are deprecated and will be removed in v5.
fix
Use top-level imports: `from vnstock import Analysis`.
affects: >=3.5.0
gotchaFree tier of vnstock has a rate limit of 10 requests/minute. Exceeding this returns HTTP 429.
fix
Use `time.sleep(6)` between requests to stay under limit.
affects: >=4.0.0
gotcha`Vnstock` class requires environment variables `VNSTOCK_USERNAME` and `VNSTOCK_PASSWORD` unless you only use public data endpoints (e.g., `Stock.historical_price` may work without login for some symbols).
fix
Set credentials via `os.environ` or call `login()` before accessing protected methods.
affects: >=4.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'vnstock.vnstock'
v4 removed the `vnstock.vnstock` submodule; all classes are now at `vnstock` top-level.
fix
Change import to `from vnstock import Vnstock`.
TypeError: Stock.historical_price() got unexpected keyword argument 'ticker'
v4 renamed parameter `ticker` to `symbol`.
fix
Use `historical_price(symbol='ACB')` instead of `ticker='ACB'`.
AttributeError: 'Vnstock' object has no attribute 'analysis'
v4 moved `analysis` from `Vnstock` to a standalone top-level import.
fix
Import `Analysis` directly: `from vnstock import Analysis`.
ConnectionError: 429 Client Error: Too Many Requests
Exceeded free tier rate limit (10 req/min).
fix
Add a delay: `time.sleep(6)` between API calls.
Upgrade
Version history
4.0.2latest on PyPI · released Apr 28, 2026
Audit
Dependencies
pandasrequiredData manipulation and DataFrame output
requestsrequiredHTTP requests to data sources
Agent activity
41 hits · last 30 days
node
38
OpenAI (training)
1
Resources
vnstock — pip install vnstock · libregistry