longportapp/openapi

πŸ’° Finance & Fintech
0 Views
0 Installs

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

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "longportapp-openapi": {
      "command": "npx",
      "args": [
        "-y",
        "longportapp-openapi"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

Longport OpenAPI SDK

PyPI version npm version Maven Central

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:

NameDocumentDescription
RustDocLongport OpenAPI for Rust (>= 1.89.0)
PythonDocLongport OpenAPI for Python 3 (>= 3.8)
Node.jsDocLongport OpenAPI for Node.js (>= 10)
JavaDocLongport OpenAPI for Java (>= 11)
CDocLongport OpenAPI for C (>= C99)
C++DocLongport OpenAPI for C++(>= C++17)
Gohttps://github.com/longportapp/openapi-go
MCPAn MCP server implementation for Longport OpenAPI

Context Types

ContextDescription
QuoteContextReal-time quotes, candlesticks, options, warrants, watchlists, push subscriptions
TradeContextOrders, positions, account balance, executions, cash flow
AssetContextAccount statement download
ContentContextNews, community topics
FundamentalContextFinancial reports, analyst ratings, dividends, valuation, company overview, shareholders
MarketContextMarket status, broker holdings, A/H premium, trade statistics, anomaly alerts, index constituents
CalendarContextFinancial calendar (earnings, dividends, splits, IPOs, macro data, market closures)
PortfolioContextExchange rates, portfolio P&L analysis
AlertContextPrice alert management (add/enable/disable/delete)
DCAContextDollar-cost averaging plan management
SharelistContextCommunity 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

Related MCP Servers

@agentfund/mcp

πŸ“‡ ☁️ - Fundraising infrastructure for AI agents on Solana β€” campaigns, x402 donations, and on-chain reputation. MCP tools for registering agents, creating campaigns, and donating via the x402 pay-to-call flow, backed by Anchor programs (agentregistry, escrow, reputation). npx -y @agentfund/mcp

πŸ’° Finance & Fintech1 views
@asterpay/mcp-server

πŸ“‡ ☁️ - EUR settlement for AI agents via x402 protocol. Market data, AI tools, crypto analytics β€” pay-per-call in USDC on Base. SEPA Instant EUR off-ramp.

πŸ’° Finance & Fintech1 views
@czagents/cnb

πŸ“‡ ☁️ 🏠 🍎 πŸͺŸ 🐧 - Czech National Bank (ČNB) daily FX rates: fetch official CZK exchange rates, convert between currencies, fetch historical rates. Cached 10 min to ease upstream load. npm @czagents/cnb or HTTP at cnb.cz-agents.dev/mcp.

πŸ’° Finance & Fintech1 views
@arbitova/mcp-server

πŸ“‡ ☁️ - Non-custodial on-chain escrow + AI dispute arbitration for agent-to-agent USDC payments on Base. Seven tools covering the full EscrowV1 contract surface: create escrow, mark delivered with on-chain content hash, confirm or dispute, arbiter resolves with signed verdict, cancel/escalate on timeout. npx @arbitova/mcp-server

πŸ’° Finance & Fintech0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it β†’
β˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.