DEV Community

EmilyL
EmilyL

Posted on

US Stock Data API: Futu API vs AllTick — A Developer’s Field Report

When you’re building a monitoring dashboard or a quant research tool for US equities, the choice of market data API can make or break your project’s reliability. Last year I built a personal stock watcher and learned this the hard way. Here’s a breakdown of two approaches: the Futu API with its OpenD gateway, and a cloud WebSocket alternative I later adopted.

The Setup That Caused Silent Downtime

My tool needed real-time quotes for a handful of tickers and simple minute-level charts. I had a Futu account, so I started with their API. Futu uses a local gateway called OpenD: you install it on your machine, log in with your Futu credentials, and route all data requests through it. Your code communicates with OpenD, not with Futu’s servers directly.

This architecture has a critical weakness: if OpenD dies, or restarts due to an auto-update, or your session expires, your data feed stops without any exception. It’s a silent failure. One night OpenD auto-updated and restarted, and my script lost connectivity for over three hours. I only discovered the gap the next morning when I checked the logs.

That experience made me look for a data source with fewer moving parts.

What Futu’s API Actually Requires

Futu positions its API as a companion to its trading platform, not as a standalone market data service. That leads to some practical constraints:

  • You need a Futu securities account. Certain market data permissions require a minimum balance or trading history; otherwise you’re limited to delayed quotes.
  • OpenD must run continuously on your own infrastructure. Any server reboot, network dropout, or forced OpenD upgrade interrupts your data.
  • Level 2 data and tick-by-tick trades usually require extra permissions or fees that aren’t enabled by default.

If you’re already a Futu trader, these trade-offs may be acceptable. For a side project, they add unnecessary complexity.

A Simpler Path: Direct WebSocket Streaming

I came across ALLTICK API in a developer forum. It’s a cloud API that streams US stock quotes over WebSocket without a local gateway. You just need an API key and a WebSocket URL. No client installation, no brokerage account. I tried it and immediately noticed how much cleaner the setup was.

Here’s a side-by-side comparison:

Dimension Futu OpenD API AllTick API
Deployment Requires a local/server-resident OpenD gateway Direct cloud WebSocket/REST, no gateway needed
Account requirements Futu securities account required; some permissions need asset thresholds API key is sufficient, no brokerage account needed
Market coverage Mainly HK, US, and A-shares, tied to Futu’s tradable products US, HK, A-shares, forex, precious metals, crypto, all through one unified interface
Protocol Proprietary SDK + OpenD forwarding Standard WebSocket/RESTful interface
Operational overhead You maintain the gateway process stability No local process; server side handles stability

Code Example: Subscribing to US Stock Quotes via WebSocket

Here’s the Python script I use now. It’s lightweight and doesn’t require any local process management.

import json
import websocket

API_KEY = "your_alltick_api_key"
WS_URL = f"wss://quote.alltick.co/quote-stock-b-ws-api?token={API_KEY}"

def on_open(ws):
    subscribe_msg = {
        "cmd_id": 22004,
        "seq_id": 1,
        "trace": "sub-us-stock",
        "data": {
            "symbol_list": [
                {"code": "AAPL.US"},
                {"code": "TSLA.US"}
            ]
        }
    }
    ws.send(json.dumps(subscribe_msg))

def on_message(ws, message):
    data = json.loads(message)
    print("Received market data:", data)

def on_error(ws, error):
    print("Connection error:", error)

def on_close(ws, close_status_code, close_msg):
    print("Connection closed, preparing to reconnect")

if __name__ == "__main__":
    ws = websocket.WebSocketApp(
        WS_URL,
        on_open=on_open,
        on_message=on_message,
        on_error=on_error,
        on_close=on_close
    )
    ws.run_forever()
Enter fullscreen mode Exit fullscreen mode

Once the WebSocket connection is live, real-time quotes for AAPL and TSLA stream continuously. I’ve tested it from pre-market through regular hours, and the feed has been stable. No more silent disconnects caused by a local gateway crashing.

Choosing the Right Tool for Your Project

If you’re a Futu trader and you already have the necessary account permissions, using the Futu API keeps everything in one ecosystem. But if you want a data layer that’s independent of any broker and can run unattended on a server, a cloud-native WebSocket API is far more reliable. I migrated all my monitoring scripts to direct WebSocket connections, and since then I haven’t had to think about gateway uptime. For a side project maintained in my spare time, removing that operational burden was the key win.

Top comments (0)