Vnstock
raw JSON → 4.0.2 verified Sat May 09 auth: no python
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 Common errors
error ModuleNotFoundError: No module named 'vnstock.vnstock' ↓
cause v4 removed the `vnstock.vnstock` submodule; all classes are now at `vnstock` top-level.
fix
Change import to
from vnstock import Vnstock. error TypeError: Stock.historical_price() got unexpected keyword argument 'ticker' ↓
cause v4 renamed parameter `ticker` to `symbol`.
fix
Use
historical_price(symbol='ACB') instead of ticker='ACB'. error AttributeError: 'Vnstock' object has no attribute 'analysis' ↓
cause v4 moved `analysis` from `Vnstock` to a standalone top-level import.
fix
Import
Analysis directly: from vnstock import Analysis. error ConnectionError: 429 Client Error: Too Many Requests ↓
cause Exceeded free tier rate limit (10 req/min).
fix
Add a delay:
time.sleep(6) between API calls. Warnings
breaking v4.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`).
breaking Login 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.
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']`.
deprecated The old `vnstock.analysis` and `vnstock.core` modules are deprecated and will be removed in v5. ↓
fix Use top-level imports: `from vnstock import Analysis`.
gotcha Free 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.
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.
Imports
- Vnstock wrong
from vnstock.vnstock import Vnstockcorrectfrom vnstock import Vnstock - Stock wrong
from vnstock.core import Stockcorrectfrom vnstock import Stock - Analysis wrong
from vnstock.analysis import Analysiscorrectfrom vnstock import Analysis - Trading wrong
from vnstock.core import Tradingcorrectfrom vnstock import Trading
Quickstart
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())