Skip to main content

openbb_akshare

Python Version License

How to Use AKShare as a Data Source for OpenBB

OpenBB, as an open-source financial data platform, is dedicated to providing free and transparent financial data interfaces for investors, analysts, and developers. For a detailed introduction to OpenBB and its usage, please refer to Introduction to OpenBB and How to Use It to Aid Financial Data Analysis of China A-share and Hong Kong Stocks.

Although OpenBB supports multi-source data interfaces, the acquisition of financial data in China (including Hong Kong) mainly relies on Yahoo Finance. As a free basic data source, it can meet basic needs, but its coverage depth for the Chinese and Hong Kong markets is still insufficient. More importantly, mainland Chinese users need to use a VPN to access this service, creating significant usage barriers.

To enhance service capabilities in Greater China, OpenBB urgently needs to improve the implementation of localized financial data sources. The mainstream paid solutions include Wind, Eastmoney Choice, and 同花顺 iFind (mainly for institutional clients), while the free solutions focus on the open-source tool AKShare as the core solution. By integrating data interfaces from platforms such as Eastmoney, 同花顺, Tencent, Sina, and 雪球, AKShare has become one of the most comprehensive, up-to-date, and developer-friendly financial data aggregation libraries in the domestic Python ecosystem.

The openbb_akshare project, as a data source extension for OpenBB, enables seamless integration of AKShare data into the OpenBB platform. Below is a detailed usage guide:

Table of Contents

💻 Environment Setup and Installation Process

As developers, we primarily interact with the platform through the OpenBB Platform CLI. To integrate the AKShare data source, follow these steps to configure the development environment:

  1. Create a Python Virtual Environment

    You can use venv, uv, or poetry to create a virtual environment. Here, we use venv (built into Python):

    # Create a virtual environment
    python3 -m venv .venv
    
    # Activate the virtual environment (Linux/Mac)
    source .venv/bin/activate
    
    # For Windows
    .venv\Scripts\activate  
    
  2. Install OpenBB Platform CLI

    Install the core OpenBB CLI via pip. Users in mainland China can configure a mirror for faster installation:

    # (Optional) Set a domestic mirror for pip
    # For Linux/Mac
    export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple
    
    # Install OpenBB CLI
    pip install openbb-cli
    
  3. Install openbb_akshare

    Next, install the openbb_akshare extenstion to use the AKShare data source:

    # Install the AKShare data source extension
       pip install openbb_akshare
    
       # Rebuild OpenBB resources to activate the plugin
       python -c "import openbb; openbb.build()"   ```
    

🚀 Using the AKShare Data Source

Case 1: Query A-Share Company News (Vanke as an Example)

Jupyter Notebook:

from openbb import obb
messages = obb.news.company("000002", provider="akshare")
for result in messages.results:
    print(f"{result.title}")

Output:

开源证券发布万科A研报,公司信息更新报告:销售均价有所提升,股东持续借款提供支持
万科A出售2086万股库存股,金额1.36亿元
万科A:已完成所有A股库存股出售 所得资金4.79亿元
...

Using OpenBB CLI:

openbb
2025 Jun 26, 03:11 (🦋) /news/ $ company --symbol 000002 --provider akshare

After entering the command, the results will be displayed in a WebView, as shown below:

openbb04

Case 2: Obtain Historical Stock Prices of Hong Kong Stocks (Hong Kong Telecom as an Example)

Using OpenBB CLI:

2025 Jun 26, 03:28 (🦋) /equity/price/ $ historical --symbol 06823 --provider akshare

Results in WebView:openbb05

Jupyter Notebook:

from openbb import obb
prices = obb.equity.price.historical(symbol='06823', start_date="2025-06-01", end_date="2025-06-10", provider="akshare")
prices.results[0].date, prices.results[0].open, prices.results[0].close, prices.results[0].high, prices.results[0].low, prices.results[0].volume

Output:

(datetime.date(2025, 6, 2), 11.28, 11.3, 11.3, 11.14, 10308375)

🌟 openbb_akshare Project Ecosystem

The openbb_akshare project is currently in an active development phase, and contributions from the open-source community are welcome:

Code Repositories

Ways to Contribute

  1. Submit Issues to report data needs or bugs.

  2. Contribute PRs to optimize data source interfaces.

  3. Improve documentation to help more users.

Through the integration of AKShare and OpenBB, users in China can more conveniently access real-time and historical data for markets such as A-Shares and Hong Kong Stocks, providing strong data support for quantitative analysis and investment research.

Run openbb-akshare as a web service

You can also run openbb-akshare as a FastAPI web service:

uvicorn openbb_platform_api.main:app --port 8001

To start the instance in VSCode, update your launch.json configuration as below:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "OpenBB Debugger: FastAPI",
            "type": "debugpy",
            "request": "launch",
            "module": "uvicorn",
            "args": [
                "openbb_platform_api.main:app",
                "--port",
                "8001"
            ],
            "jinja": true
        },
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

Requirements

  • Python 3.11 or higher
  • OpenBB Platform 4.6.0 or higher
  • AKShare 1.18.19 or higher

Troubleshooting

If you encounter issues during installation or usage:

  1. Build issues: Make sure to run python -c "import openbb; openbb.build()" after installing the extension
  2. Data not loading: Verify your internet connection and that AKShare APIs are accessible
  3. Import errors: Ensure all dependencies are installed correctly in your virtual environment
  4. For more help: Visit the project issues page

Metadata

Release files for openbb-akshare 1.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openbb-akshare 1.2.5
File Size Uploaded Provenance
openbb_akshare-1.2.5.tar.gz 57.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openbb-akshare 1.2.5
File Interpreter ABI Platform
openbb_akshare-1.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 142.1 kB

Release files / openbb_akshare-1.2.5.tar.gz

Download URL openbb_akshare-1.2.5.tar.gz
Size 57.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dfcfd6c124d991e6b8a369e51426c609400d55cb3b94161e123541000f2aa378
BLAKE2b-256 checksum
How to use checksums
592b19ca961fa593f47e23e0dc1935e1397c0a571ee08ed427a0bfcf54631b30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.0 CPython/3.13.13 Windows/10

Release files / openbb_akshare-1.2.5-py3-none-any.whl

Download URL openbb_akshare-1.2.5-py3-none-any.whl
Size 84.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d246b78c5a113b40595f53f4b26a19150300271dd74fa847373f5e6a9dafdf2
BLAKE2b-256 checksum
How to use checksums
79e0563c03756cbd5afbfc6265a3c41c5928ebff60b733fbab778b2fef5cdd72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.0 CPython/3.13.13 Windows/10

Security for openbb-akshare 1.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page