行业估值分布

获取该证券所在行业的估值分布直方图。

Parameters

SDK 方法参数。

NameTypeRequiredDescription
symbolstring是证券代码,例如 AAPL.US

Request Example

from longbridge.openapi import FundamentalContext, Config, OAuthBuilder

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

resp = ctx.industry_valuation_dist("AAPL.US")
print(resp)
import asyncio
from longbridge.openapi import AsyncFundamentalContext, 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 = AsyncFundamentalContext.create(config)

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

if __name__ == "__main__":
    asyncio.run(main())
const { Config, FundamentalContext, 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 = FundamentalContext.new(config)
  const resp = await ctx.industryValuationDist('AAPL.US')
  console.log(resp)
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.fundamental.*;

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);
             FundamentalContext ctx = FundamentalContext.create(config)) {
            var resp = ctx.getIndustryValuationDist("AAPL.US").get();
            System.out.println(resp);
        }
    }
}
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, 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 = FundamentalContext::new(config);
    let resp = ctx.industry_valuation_dist("AAPL.US").await?;
    println!("{:?}", resp);
    Ok(())
}
#include &lt;iostream&gt;
#include <longbridge.hpp>

using namespace longbridge;
using namespace longbridge::fundamental;

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);
            FundamentalContext ctx = FundamentalContext::create(config);
            ctx.industry_valuation_dist("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/fundamental"
)

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 := fundamental.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()
	resp, err := c.IndustryValuationDist(context.Background(), "AAPL.US")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}

Response

Response Example

{
  "code": 0,
  "message": "success",
  "data": {
    "pe": {
      "value": "28.5",
      "high": "120.0",
      "low": "5.0",
      "median": "22.0",
      "ranking": "35",
      "rank_index": "12",
      "rank_total": "30"
    },
    "pb": {
      "value": "45.2",
      "high": "200.0",
      "low": "1.0",
      "median": "8.0",
      "ranking": "85",
      "rank_index": "25",
      "rank_total": "30"
    },
    "ps": {
      "value": "7.8",
      "high": "30.0",
      "low": "0.5",
      "median": "4.0",
      "ranking": "70",
      "rank_index": "21",
      "rank_total": "30"
    }
  }
}

Response Status

StatusDescriptionSchema
200成功IndustryValuationDist
400请求错误None

Schemas

IndustryValuationDist

NameTypeRequiredDescription
symbolstring是证券代码
metricstring否估值指标(如 pe、pb、ps)
symbol_valuedouble否该证券自身的估值指标数值
bucketsobject[]否分布直方图区间列表
buckets[].range_startdouble否区间下界
buckets[].range_enddouble否区间上界
buckets[].countint32否该区间内的公司数量