Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

LongPort OpenAPI provides real-time stock market data, provides AI access analysis and trading capabilities through MCP.

README.md

Longport OpenAPI SDK

![](https://crates.io/crates/longport) ![PyPI version](https://badge.fury.io/py/longport) ![npm version](https://badge.fury.io/js/longport) ![Maven Central](https://search.maven.org/artifact/io.github.longportapp/openapi-sdk)

Longport OpenAPI provides programmatic quote trading interfaces for investors with research and development capabilities and assists them to build trading or quote strategy analysis tools based on their own investment strategies. The functions fall into the following categories:

  • Trading - Create, amend, cancel orders, query today’s/past orders and transaction details, etc.
  • Quotes - Real-time quotes, acquisition of historical quotes, etc.
  • Portfolio - Real-time query of the account assets, positions, funds
  • Real-time subscription - Provides real-time quotes and push notifications for order status changes

This repo contains the following main components:

| Name | Document | Description | |-----------------------------|-----------------------------------------------------------------------|---------------------------------------------------| | Rust | Doc | Longport OpenAPI for Rust (>= 1.89.0) | | Python | Doc | Longport OpenAPI for Python 3 (>= 3.8) | | Node.js | Doc | Longport OpenAPI for Node.js (>= 10) | | Java | Doc | Longport OpenAPI for Java (>= 11) | | C | Doc | Longport OpenAPI for C (>= C99) | | C++ | Doc | Longport OpenAPI for C++(>= C++17) | | Go | | https://github.com/longportapp/openapi-go | | MCP | | An MCP server implementation for Longport OpenAPI |

Context Types

| Context | Description | |---------|-------------| | QuoteContext | Real-time quotes, candlesticks, options, warrants, watchlists, push subscriptions | | TradeContext | Orders, positions, account balance, executions, cash flow | | AssetContext | Account statement download | | ContentContext | News, community topics | | FundamentalContext | Financial reports, analyst ratings, dividends, valuation, company overview, shareholders | | MarketContext | Market status, broker holdings, A/H premium, trade statistics, anomaly alerts, index constituents | | CalendarContext | Financial calendar (earnings, dividends, splits, IPOs, macro data, market closures) | | PortfolioContext | Exchange rates, portfolio P&L analysis | | AlertContext | Price alert management (add/enable/disable/delete) | | DCAContext | Dollar-cost averaging plan management | | SharelistContext | Community sharelist management |

Quickstart

Pick a language SDK from the table above and follow its README for install and first request. Full reference docs: https://longportapp.github.io/openapi

SDK Documentation

https://longportapp.github.io/openapi

Troubleshooting

  • Environment variables not taking effect
  • macOS/Linux: export ... only affects the current shell session.
  • Windows: setx ... requires opening a new terminal/session to take effect.
  • Authentication errors (401/403)
  • Verify LONGPORT_APP_KEY, LONGPORT_APP_SECRET, LONGPORT_ACCESS_TOKEN are correct and not expired.
  • Ensure your OpenAPI app has the required permissions.
  • Network / connection errors
  • Check firewall/proxy rules for HTTPS/WSS.
  • If you use a custom endpoint, set LONGPORT_HTTP_URL, LONGPORT_QUOTE_WS_URL, LONGPORT_TRADE_WS_URL.
  • Quote subscription exits immediately
  • Keep the process running (event loop / sleep / blocking receive loop), otherwise you will not see push events.
  • Debugging
  • Enable logs via LONGPORT_LOG_PATH.
  • If quotes connect but look empty, keep LONGPORT_PRINT_QUOTE_PACKAGES=true to confirm opened quote packages.

Minimal Verification

If you're not sure whether your environment / credentials are correct, start with the built-in HTTP client examples.

  • Python:
  python examples/python/http_client.py
  • Node.js:
  node examples/nodejs/http_client.js
  • Rust:
  cargo run --manifest-path examples/rust/Cargo.toml -p http_client
  • Java (from the example module directory):
  cd examples/java/http_client
  mvn -q -DskipTests package
  mvn -q -DskipTests exec:java
  • C/C++:
  • Use the sources in examples/c/http_client/main.c and examples/cpp/http_client/main.cpp.
  • Build instructions depend on your toolchain; see the corresponding language SDK README.

Expected results:

  • If credentials are valid and network is reachable, the HTTP call returns JSON.
  • If it returns 401/403, check your LONGPORT_APP_KEY, LONGPORT_APP_SECRET, LONGPORT_ACCESS_TOKEN.
  • If it times out / cannot connect, check proxy/firewall and your endpoint env vars.

Resources

License

Licensed under either of

  • Apache License, Version 2.0,(LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Finance & Payments servers.