Skip to main content

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.

PyPI version Downloads Python Version License

Read the Docs »  ·  Report Bug  ·  Request Feature


📋 Table of Contents
  1. About The Project
  2. Features
  3. Quick Start
  4. Installation
  5. Usage & Documentation
  6. Supported Providers
  7. Data Modules
  8. Roadmap
  9. Contributing
  10. Changelog
  11. License

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

(back to top ↑)


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), and Premium (500 req/min) tiers with a client-side Token Bucket Rate Limiter.
  • ** Async Support** — First-class async/await support via async_ohlcv() for high-throughput data pipelines.

(back to top ↑)


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)

(back to top ↑)


Installation

Minimum install:

pip install openstockapi

With Pandas DataFrame & Excel export support:

pip install openstockapi[pandas]

Requirements: Python 3.8+

(back to top ↑)


Usage & Documentation

Full documentation, use case examples, and sample outputs are available in the User Guide:

User Guide — Getting Started

Module Description Guide
01 — OHLCV & Profile Historical price data, company profile
02 — Financial Statements Balance sheet, income, cash flow, ratios
03 — Realtime Quote Live price, order book depth
04 — Market Indices VNINDEX, VN30 constituents
05 — Macro Indicators CPI, M2 money supply, credit growth
06 — Mutual Funds Fund NAV, portfolio holdings
07 — News & Events Corporate news, dividends, events

(back to top ↑)


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.

(back to top ↑)


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...)

(back to top ↑)


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

(back to top ↑)


Contributing

Contributions are welcome! If you'd like to add a new provider, fix a bug, or improve documentation:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-provider
  3. Commit your changes
  4. Open a Pull Request

Please make sure your changes pass the UAT suite before submitting:

python uat/run_uat.py

(back to top ↑)


Changelog

See all version updates, new features, and bug fixes at:

CHANGELOG.md

(back to top ↑)


License

Distributed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE for more information.

(back to top ↑)

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

openstockapi-0.2.1.tar.gz (39.1 kB view details)

Uploaded Source

Built Distribution

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

openstockapi-0.2.1-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file openstockapi-0.2.1.tar.gz.

File metadata

  • Download URL: openstockapi-0.2.1.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for openstockapi-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d91bd66b9649a5824830c0889d274bba14242a727b02965f14f4762b493b72df
MD5 b59645f55708d4119954e200fca87369
BLAKE2b-256 79489a055d2dbd0409a68a3893b036bac580fd6b049790b76d0afee660e9f739

See more details on using hashes here.

File details

Details for the file openstockapi-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: openstockapi-0.2.1-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

Hashes for openstockapi-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c893f84e8c9b96e9ce0d6b4ae6b9f01649b4e15e00a0be7a13e459467ba1488
MD5 b4414df3aa265e665c92062f4058e0d3
BLAKE2b-256 8ac4bc0558fa0cfb486703e434c2484134f4e30acfecbbb87c1c5f696ed6c104

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