Longbridge Developers
Get Started

Trading Stats

Get trade statistics showing price distribution by volume for a security.

>_ CLI
longbridge trade-stats 700.HK
longbridge trade-stats TSLA.US

Parameters

SDK method parameters.

NameTypeRequiredDescription
symbolstringYESSecurity symbol, e.g. 700.HK

Request Example

from longbridge.openapi import MarketContext, Config, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = MarketContext(config)

resp = ctx.trading_stats("AAPL.US")
print(resp)
import asyncio
from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder

async def main() -> None:
    oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
    config = Config.from_oauth(oauth)
    ctx = AsyncMarketContext.create(config)

    resp = await ctx.trading_stats("AAPL.US")
    print(resp)

if __name__ == "__main__":
    asyncio.run(main())
const { Config, MarketContext, OAuth } = require('longbridge')

async function main() {
  const oauth = await OAuth.build('your-client-id', (_, url) => {
    console.log('Open this URL to authorize: ' + url)
  })
  const config = Config.fromOAuth(oauth)
  const ctx = MarketContext.new(config)
  const resp = await ctx.trading_stats('AAPL.US')
  console.log(resp)
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.market.*;

class Main {
    public static void main(String[] args) throws Exception {
        try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
             Config config = Config.fromOAuth(oauth);
             MarketContext ctx = MarketContext.create(config)) {
            var resp = ctx.getTradingStats("AAPL.US").get();
            System.out.println(resp);
        }
    }
}
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, market::MarketContext, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("Open: {url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let ctx = MarketContext::new(config);
    let resp = ctx.trading_stats("AAPL.US").await?;
    println!("{:?}", resp);
    Ok(())
}
#include &lt;iostream&gt;
#include <longbridge.hpp>

using namespace longbridge;
using namespace longbridge::market;

int main() {
    OAuthBuilder("your-client-id").build(
        [](const std::string& url) { std::cout << "Open: " << url << std::endl; },
        [](auto res) {
            if (!res) return;
            Config config = Config::from_oauth(*res);
            MarketContext ctx = MarketContext::create(config);
            ctx.trading_stats("AAPL.US", [](auto resp) {
                if (resp) std::cout << "OK" << std::endl;
            });
        });
    std::cin.get();
}
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/longbridge/openapi-go/config"
	"github.com/longbridge/openapi-go/oauth"
	"github.com/longbridge/openapi-go/market"
)

func main() {
	o := oauth.New("your-client-id").
		OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
	if err := o.Build(context.Background()); err != nil {
		log.Fatal(err)
	}
	conf, err := config.New(config.WithOAuthClient(o))
	if err != nil {
		log.Fatal(err)
	}
	c, err := market.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()
	resp, err := c.TradingStats(context.Background(), "AAPL.US")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}

Response

Response Example

{
  "code": 0,
  "message": "success",
  "data": {
    "statistics": {
      "avgprice": "210.50",
      "buy": "45000000",
      "sell": "38000000",
      "neutral": "12000000",
      "total_amount": "95000000",
      "trades_count": "125000",
      "preclose": "208.20",
      "timestamp": "1778198400",
      "trade_date": [
        "2026-05-13"
      ]
    },
    "trades": [
      {
        "price": "210.00",
        "buy_amount": "5000000",
        "sell_amount": "4000000",
        "neutral_amount": "1000000"
      }
    ]
  }
}

Response Status

StatusDescriptionSchema
200SuccessTradeStatsResponse
400Bad requestNone

Schemas

TradeStatsResponse

NameTypeRequiredDescription
statisticsobjecttrueAggregate trade statistics
statistics.avgpricestringfalseAverage trade price
statistics.buystringfalseTotal buy volume
statistics.sellstringfalseTotal sell volume
statistics.neutralstringfalseTotal neutral volume
statistics.total_amountstringfalseTotal traded amount
statistics.trades_countstringfalseTotal trade count
statistics.preclosestringfalsePrevious close price
statistics.timestampstringfalseStatistics timestamp
statistics.trade_datestring[]falseTrading dates included
tradesobject[]falsePrice-level trade distribution
∟ pricestringtruePrice level
∟ buy_amountstringfalseBuy amount at this price
∟ sell_amountstringfalseSell amount at this price
∟ neutral_amountstringfalseNeutral amount at this price