Skip to content

Add Longbridge as a Broker #129

@Jubeing

Description

@Jubeing

Motivation

Longbridge Securities (长桥证券) is a multi-market broker covering HK, US, Shanghai (Stock Connect), Shenzhen (Stock Connect), and Singapore equities — with a clean REST/WebSocket OpenAPI and an official Node.js SDK (longbridge@^4.0.5).

Currently OpenAlice supports IBKR, Alpaca, and CCXT. Adding Longbridge would significantly expand the broker coverage, especially for:

  • HK equities (not covered by any existing broker)
  • A-share Stock Connect (Shanghai + Shenzhen)
  • SG equities (Singapore Exchange)

Technical Fit

Longbridge's API is a strong match for OpenAlice's UTA architecture:

OpenAlice IBroker method Longbridge API
searchContracts No public search API → static registry needed (similar to IBKR's approach)
getPositions TradeContext.stockPositions()
getAccount TradeContext.accountBalance()
placeOrder TradeContext.submitOrder()
cancelOrder TradeContext.cancelOrder()
getOpenOrders TradeContext.todayOrders()
getMarketClock QuoteContext.tradingCalendar()
getQuote QuoteContext.staticInfo() + QuoteContext.subscribe()

Implementation Notes

A reference implementation patch is available at:
https://github.com/Jubeing/openalice-longbridge-broker

Key design decisions:

  • Symbol format: 700.HK (HK) / AAPL.US (US) / SH.600000 (Shanghai) / SZ.000001 (Shenzhen) / STI.SG (SG)
  • Chinese stock names: Fetched dynamically via QuoteContext.staticInfo().nameCn, with a static registry fallback for search
  • Option PnL: US options use ×100 contract multiplier (each contract = 100 shares)
  • Auth: AppKey + AppSecret + AccessToken (OAuth bearer, long-lived)

Request

Consider merging Longbridge as a first-class broker type (type: "longbridge" in accounts.json), or alternatively, accept contributions to the patch repo above as the canonical integration point.

Happy to provide further details on API behavior, edge cases, or testing approach.


Related links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions