Vietnam stock market data library — open source data plane
Project description
OpenStockAPI
A modular, multi-source Python Data Plane for Vietnamese & International financial market data.
📋 Table of Contents
About The Project
OpenStockAPI is an open-source Python library that acts as a modular Data Plane for collecting and standardizing financial data from multiple Vietnamese and international sources.
It is designed to be the upstream data acquisition layer for financial applications — handling provider fallback, rate limiting, and tier-based access control — so your application logic never has to worry about data source reliability.
📘 A Vietnamese version of this README is available: README_VN.md
Features
- ** Multi-market Support** — Covers Vietnamese (
VN) equities and can be extended to International (US) markets with the same API. - ** Automatic Multi-source Fallback** — Integrates providers (KBS, VCI, MSN, MAS, Maybank, Fmarket) with transparent automatic failover when any source is unavailable.
- ** Freemium Tier Access Control** — Supports
Free,Pro(200 req/min), andPremium(500 req/min) tiers with a client-side Token Bucket Rate Limiter. - ** Async Support** — First-class
async/awaitsupport viaasync_ohlcv()for high-throughput data pipelines.
Quick Start
import openstockapi as osapi
# Initialize with your API key (required for all tiers)
# Register for free at: https://openstockapi.com/register
osapi.init("free_YOUR_KEY") # or "pro_YOUR_KEY" / "premium_YOUR_KEY"
# Historical OHLCV price data
df = osapi.ohlcv("VNM", resolution="1D", start="2025-01-01", end="2025-12-31")
print(df.head())
# Company financial statements
bs = osapi.balance_sheet("VNM", period="annual")
# Realtime market quote
quote = osapi.quote("HPG")
print(f"{quote.symbol}: {quote.price:,.0f} VND ({quote.pct_change:+.2f}%)")
# Corporate news & events
news = osapi.company_news("FPT", limit=5)
events = osapi.company_events("FPT", limit=5)
Installation
Minimum install:
pip install openstockapi
With Pandas DataFrame & Excel export support:
pip install openstockapi[pandas]
Requirements: Python 3.8+
Usage & Documentation
Full documentation, use case examples, and sample outputs are available in the User Guide:
Supported Providers
| Provider | Source | Tier | Data Types |
|---|---|---|---|
kbs |
KB Securities Vietnam | Free | OHLCV, Profile, News, Events |
vci |
Vietcap Securities | Free | OHLCV, Profile, Financial Statements, Insider/Foreign/Prop Trading, Events |
msn |
MSN Finance (Bing) | Free | OHLCV (VN & International) |
mas |
MAS (Mass Asset Securities) | Free | Financial Statements, Ratios |
mbk |
Maybank Securities Vietnam | Free | Macro Indicators (M2, Credit) |
fmarket |
Fmarket Vietnam | Free | Mutual Fund NAV & Holdings |
tcbs |
TCBS (Techcom Securities) | Free | Realtime Quote, Order Book |
Providers are tried in priority order per data type. If one fails, the next is used automatically.
Data Modules Overview
openstockapi
├── ohlcv() # Historical OHLCV (sync)
├── async_ohlcv() # Historical OHLCV (async)
├── profile() # Company profile
├── balance_sheet() # Balance sheet
├── income_statement() # Income statement
├── cashflow() # Cash flow statement
├── ratios() # Financial ratios (PE, PB, ROE...)
├── quote() # Realtime price quote
├── order_book() # Order book depth
├── market_index() # Market index OHLCV
├── index_constituents() # Index member list
├── macro_indicators() # Macroeconomic data
├── fund_details() # Mutual fund info
├── company_news() # Corporate news
└── company_events() # Corporate events (dividends, ESOP...)
Roadmap
- Vietnamese equity OHLCV (KBS, VCI, MSN)
- Financial statements (MAS, VCI)
- Macroeconomic indicators (World Bank, Maybank)
- Mutual fund data (Fmarket)
- Corporate news & events (KBS, VCI)
- International equity OHLCV
- Cryptocurrency data
- Derivatives / Futures data
- WebSocket streaming quotes
Contributing
Contributions are welcome! If you'd like to add a new provider, fix a bug, or improve documentation:
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-provider - Commit your changes
- Open a Pull Request
Changelog
See all version updates, new features, and bug fixes at:
License
Distributed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openstockapi-0.2.3.tar.gz.
File metadata
- Download URL: openstockapi-0.2.3.tar.gz
- Upload date:
- Size: 39.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23e7e3b27982eb53609c10aa49478903a67092f3253ce7d14b381479de3a646e
|
|
| MD5 |
7fcb692335075c8abbc05bb92d672ba3
|
|
| BLAKE2b-256 |
b05c7486d52b9a8865e174b9550d14fda41d6a3685686a0fe305db7f192ab22a
|
File details
Details for the file openstockapi-0.2.3-py3-none-any.whl.
File metadata
- Download URL: openstockapi-0.2.3-py3-none-any.whl
- Upload date:
- Size: 50.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc15b52fa455d0cb4e862c2479a2321d77db80f08b571799718568b038503753
|
|
| MD5 |
d4e1839cbe9672726b5027d190dfde45
|
|
| BLAKE2b-256 |
6a6c785000c3e785b98e417e4d22eedf2c18b9fd2296ba24963b7eb4996923b8
|