diff --git a/docs/en/docs/cli/fundamentals/business-segments.md b/docs/en/docs/cli/fundamentals/business-segments.md new file mode 100644 index 00000000..9fd15354 --- /dev/null +++ b/docs/en/docs/cli/fundamentals/business-segments.md @@ -0,0 +1,61 @@ +--- +title: 'business-segments' +sidebar_label: 'business-segments' +sidebar_position: 15 +--- + +# longbridge business-segments + +Show revenue breakdown by business segment for a company — current period totals or historical trends across reporting periods. + +## Basic Usage + +```bash +longbridge business-segments AAPL.US +``` + +``` +Period: Q1 FY2026 Total: 124,300,000,000 Currency: USD + +| segment | amount | share | +|-------------------|-----------------|--------| +| iPhone | 69,140,000,000 | 55.62% | +| Services | 26,340,000,000 | 21.19% | +| Mac | 7,940,000,000 | 6.39% | +| iPad | 8,090,000,000 | 6.51% | +| Wearables & Other | 12,790,000,000 | 10.29% | +``` + +## Examples + +### Current period breakdown + +```bash +longbridge business-segments AAPL.US +``` + +Shows each business segment's revenue and its share of total revenue for the most recent reporting period. + +### Historical segment trends + +```bash +longbridge business-segments AAPL.US --history +``` + +Returns segment revenue across multiple reporting periods so you can track how the revenue mix has shifted over time. + +### Filter by report type + +```bash +longbridge business-segments AAPL.US --history --report af +``` + +Use `--report` to scope the history to a specific period type: `af` (annual), `saf` (semi-annual), `qf` (quarterly). + +## Options + +| Flag | Description | +|------|-------------| +| `--history` | Show historical segment data across multiple periods | +| `--report ` | Period type filter: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | +| `--format json` | Output raw JSON | diff --git a/docs/en/docs/cli/fundamentals/financial-report.md b/docs/en/docs/cli/fundamentals/financial-report.md index 34011d34..84dc6b86 100644 --- a/docs/en/docs/cli/fundamentals/financial-report.md +++ b/docs/en/docs/cli/fundamentals/financial-report.md @@ -59,3 +59,40 @@ longbridge financial-report 700.HK --kind BS --report af ``` Retrieves the annual balance sheet for Tencent. Use `--report` to choose the reporting period: `af` (annual), `saf` (semi-annual), `q1`, `3q`, or `qf` (quarterly). + +### AI earnings snapshot + +```bash +longbridge financial-report snapshot AAPL.US +``` + +``` +Apple Inc. (AAPL) Q1 FY2026 Jan 2026 – Mar 2026 USD + +Apple delivered a solid quarter with revenue and EPS beating consensus +estimates. Services continued to outperform, offsetting softer iPhone +sales outside of China. + +── Forecast vs Actual ────────────────────────────────────────────── +| metric | consensus | actual | beat/miss | +|---------------|-----------|---------|-----------| +| Revenue | 123.15B | 124.30B | +0.93% | +| EBIT | 34.21B | 35.43B | +3.57% | +| Net Income | 29.48B | 30.52B | +3.53% | + +── Upcoming peer earnings ────────────────────────────────────────── +| company | ticker | date | +|-------------|----------|------------| +| Microsoft | MSFT.US | 2026-04-29 | +| Alphabet | GOOG.US | 2026-04-29 | +| Meta | META.US | 2026-04-30 | +``` + +The `snapshot` subcommand provides an AI-generated earnings summary, beat/miss analysis against consensus estimates, and upcoming earnings dates for peer companies. + +```bash +# Specify a historical quarter +longbridge financial-report snapshot TSLA.US --report qf --year 2025 --period 4 +``` + +Use `--report qf --year --period <1-4>` to retrieve a specific quarter. diff --git a/docs/en/docs/cli/fundamentals/industry-peers.md b/docs/en/docs/cli/fundamentals/industry-peers.md new file mode 100644 index 00000000..3d81fc9a --- /dev/null +++ b/docs/en/docs/cli/fundamentals/industry-peers.md @@ -0,0 +1,59 @@ +--- +title: 'industry-peers' +sidebar_label: 'industry-peers' +sidebar_position: 17 +--- + +# longbridge industry-peers + +Explore the hierarchical sub-sector tree for an industry group. Takes a BK counter ID from [`industry-rank`](./industry-rank) and expands it into a full competitive landscape — sub-sectors, their sub-sectors, and the stocks in each. + +## Basic Usage + +```bash +longbridge industry-peers BK/US/IN00258 +``` + +``` +Root: Semiconductors (US) + +├── Design & Fabless 23 stocks +3.12% YTD +18.4% +│ ├── GPU & AI Chips 8 stocks +4.91% YTD +24.1% +│ ├── Mobile SoC 6 stocks +2.33% YTD +12.8% +│ └── Analog IC 9 stocks +1.54% YTD +9.3% +├── Foundry & Manufacturing 7 stocks +2.87% YTD +15.6% +│ ├── Logic Foundry 3 stocks +3.11% YTD +19.2% +│ └── Memory 4 stocks +2.61% YTD +11.9% +└── Equipment & Materials 12 stocks +1.43% YTD +7.2% +``` + +## Examples + +### Explore a sector from industry-rank + +```bash +# Step 1: find a sector +longbridge industry-rank --market US + +# Step 2: drill into it using the counter_id column +longbridge industry-peers BK/US/IN00258 +``` + +### HK sector tree + +```bash +longbridge industry-peers BK/HK/IN00012 +``` + +Works the same way across markets — use counter IDs from `industry-rank --market HK`, `--market CN`, or `--market SG`. + +## Options + +| Flag | Description | +|------|-------------| +| `--format json` | Output raw JSON | + +## Notes + +- Counter IDs follow the format `BK//IN` — copy them directly from `industry-rank` output +- Each node shows stock count, daily change, and YTD change diff --git a/docs/en/docs/cli/fundamentals/industry-rank.md b/docs/en/docs/cli/fundamentals/industry-rank.md new file mode 100644 index 00000000..fafcec6f --- /dev/null +++ b/docs/en/docs/cli/fundamentals/industry-rank.md @@ -0,0 +1,77 @@ +--- +title: 'industry-rank' +sidebar_label: 'industry-rank' +sidebar_position: 16 +--- + +# longbridge industry-rank + +Rank all industries in a market by a chosen indicator — see which sectors are leading today, which have the strongest revenue growth, or which are attracting the most capital. + +## Basic Usage + +```bash +longbridge industry-rank --market US +``` + +``` +| rank | name | counter_id | chg | indicator | +|------|-----------------------------------------|-----------------|--------|-----------| +| 1 | Semiconductors | BK/US/IN00258 | +3.82% | ... | +| 2 | Software - Infrastructure | BK/US/IN00305 | +2.91% | ... | +| 3 | Biotechnology | BK/US/IN00043 | +2.54% | ... | +| 4 | Electronic Components | BK/US/IN00099 | +1.98% | ... | +| 5 | Asset Management | BK/US/IN00033 | +1.73% | ... | +``` + +The `counter_id` column (e.g. `BK/US/IN00258`) can be passed directly to [`industry-peers`](./industry-peers) to explore the competitive tree within that sector. + +## Examples + +### Leading industries today + +```bash +longbridge industry-rank --market US +``` + +Ranks industries by daily price performance. Replace `US` with `HK`, `CN`, or `SG` to switch markets. + +### Top industries by market cap + +```bash +longbridge industry-rank --market HK --indicator market-cap +``` + +### Top industries by revenue growth + +```bash +longbridge industry-rank --market CN --indicator revenue-growth +``` + +### Then drill into a sector + +```bash +# Get the counter_id from industry-rank, then explore its sub-sectors +longbridge industry-peers BK/US/IN00258 +``` + +## Options + +| Flag | Description | +|------|-------------| +| `--market ` | Market to rank: `US`, `HK`, `CN`, `SG` | +| `--indicator ` | Ranking indicator (see below) | +| `--format json` | Output raw JSON | + +### Indicators + +| Value | Description | +|-------|-------------| +| `leading-gainer` | Daily price performance (default) | +| `today-trend` | Intraday trend strength | +| `popularity` | Search and watchlist activity | +| `market-cap` | Total market capitalisation | +| `revenue` | Latest revenue | +| `revenue-growth` | YoY revenue growth rate | +| `net-profit` | Latest net profit | +| `net-profit-growth` | YoY net profit growth rate | diff --git a/docs/en/docs/cli/fundamentals/institution-rating.md b/docs/en/docs/cli/fundamentals/institution-rating.md index a2052fe6..32b66d19 100644 --- a/docs/en/docs/cli/fundamentals/institution-rating.md +++ b/docs/en/docs/cli/fundamentals/institution-rating.md @@ -112,3 +112,20 @@ longbridge institution-rating TSLA.US --format json ``` The `evaluate` object contains the per-rating counts across all 52 covering analysts. The `target` object shows the highest and lowest price targets alongside the previous close for context. + +### Monthly analyst sentiment trend + +```bash +longbridge institution-rating TSLA.US --views +``` + +``` +| month | strong_buy | buy | hold | sell | under | no_opinion | total | +|---------|------------|-----|------|------|-------|------------|-------| +| 2026-04 | 18 | 5 | 17 | 6 | 2 | 4 | 52 | +| 2026-03 | 17 | 6 | 18 | 5 | 3 | 3 | 52 | +| 2026-02 | 16 | 7 | 19 | 5 | 3 | 2 | 52 | +| 2026-01 | 15 | 8 | 19 | 6 | 2 | 2 | 52 | +``` + +Shows how the buy/hold/sell distribution has shifted month by month, newest first. Use alongside `--history` (individual analyst target price changes) to get both perspectives on momentum. diff --git a/docs/en/docs/cli/release-notes.md b/docs/en/docs/cli/release-notes.md index 06187bfd..e6e16189 100644 --- a/docs/en/docs/cli/release-notes.md +++ b/docs/en/docs/cli/release-notes.md @@ -7,6 +7,14 @@ sidebar_icon: newspaper # Release Notes +### [v0.21.0](https://github.com/longbridge/longbridge-terminal/releases/tag/v0.21.0) + +- **New: `business-segments`** — revenue breakdown by business segment, current period or historical trend +- **New: `industry-rank`** — industry ranking by market (US/HK/CN/SG) and indicator; counter_id output feeds directly into `industry-peers` +- **New: `industry-peers`** — hierarchical sub-sector tree with stock count, daily change, and YTD change per node +- **New: `financial-report snapshot`** — AI earnings summary with beat/miss analysis vs consensus estimates and upcoming peer earnings dates +- **New: `institution-rating --views`** — month-by-month buy/hold/sell distribution timeline + ### [v0.20.3](https://github.com/longbridge/longbridge-terminal/releases/tag/v0.20.3) - **Breaking: `analyst-estimates` removed** — command has been removed; the same data is available via `consensus` (EPS and revenue estimates) diff --git a/docs/en/docs/fundamental/fundamental/business_segments.md b/docs/en/docs/fundamental/fundamental/business_segments.md new file mode 100644 index 00000000..35dc24d1 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/business_segments.md @@ -0,0 +1,232 @@ +--- +slug: business-segments +title: Business Segments +sidebar_position: 21 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the current-period revenue segment breakdown for a listed company. + + +longbridge business-segments AAPL.US +longbridge business-segments 700.HK + + + + + +## Parameters + +> **SDK method parameters.** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +## Request Example + + + + +```python +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.business_segments("AAPL.US") +print(resp) +``` + + + + +```python +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.business_segments("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.businessSegments('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getBusinessSegments("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.business_segments("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.business_segments("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.BusinessSegments(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "date": "2024Q4", + "total": "124300000000", + "currency": "USD", + "business": [ + {"name": "iPhone", "percent": "0.5619"}, + {"name": "Services", "percent": "0.2196"}, + {"name": "Mac", "percent": "0.0804"}, + {"name": "iPad", "percent": "0.0700"}, + {"name": "Wearables", "percent": "0.0681"} + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [BusinessSegmentsResponse](#BusinessSegmentsResponse) | +| 400 | Bad request | None | + +## Schemas + +### BusinessSegmentsResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| date | string | false | Reporting period label, e.g. `2024Q4` | +| total | string | false | Total revenue for the period (string value) | +| currency | string | false | Currency code, e.g. `USD` | +| business | array | false | Business segment list | +| business[].name | string | false | Segment name | +| business[].percent | string | false | Revenue share (0–1 decimal) | diff --git a/docs/en/docs/fundamental/fundamental/business_segments_history.md b/docs/en/docs/fundamental/fundamental/business_segments_history.md new file mode 100644 index 00000000..d41a89db --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/business_segments_history.md @@ -0,0 +1,245 @@ +--- +slug: business-segments-history +title: Business Segments History +sidebar_position: 22 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get historical business segment revenue trends across reporting periods. + + +longbridge business-segments AAPL.US --history +longbridge business-segments AAPL.US --history --report qf + + + + + +## Parameters + +> **SDK method parameters.** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| report | string | NO | Report type: `qf` (quarterly) / `saf` (semi-annual) / `af` (annual) | +| cate | string | NO | Segment category filter | + +## Request Example + + + + +```python +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.business_segments_history("AAPL.US", report="qf") +print(resp) +``` + + + + +```python +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.business_segments_history("AAPL.US", report="qf") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.businessSegmentsHistory('AAPL.US', { report: 'qf' }) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getBusinessSegmentsHistory("AAPL.US", "qf", null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.business_segments_history("AAPL.US", Some("qf"), None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.business_segments_history("AAPL.US", "qf", "", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.BusinessSegmentsHistory(context.Background(), "AAPL.US", "qf", "") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "historical": [ + { + "date": "2024Q4", + "total": "124300000000", + "currency": "USD", + "business": [ + {"name": "iPhone", "percent": "0.5619", "value": "69900000000"}, + {"name": "Services", "percent": "0.2196", "value": "26300000000"} + ], + "regionals": [ + {"name": "Americas", "percent": "0.4280", "value": "53200000000"}, + {"name": "Europe", "percent": "0.2520", "value": "30100000000"} + ] + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [BusinessSegmentsHistoryResponse](#BusinessSegmentsHistoryResponse) | +| 400 | Bad request | None | + +## Schemas + +### BusinessSegmentsHistoryResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| historical | array | false | List of historical reporting periods | +| historical[].date | string | false | Reporting period label, e.g. `2024Q4` | +| historical[].total | string | false | Total revenue for the period (string value) | +| historical[].currency | string | false | Currency code | +| historical[].business | array | false | Business segment list | +| historical[].business[].name | string | false | Segment name | +| historical[].business[].percent | string | false | Revenue share (0–1 decimal) | +| historical[].business[].value | string | false | Absolute revenue value | +| historical[].regionals | array | false | Regional segment list | +| historical[].regionals[].name | string | false | Region name | +| historical[].regionals[].percent | string | false | Revenue share (0–1 decimal) | +| historical[].regionals[].value | string | false | Absolute revenue value | diff --git a/docs/en/docs/fundamental/fundamental/financial_report_snapshot.md b/docs/en/docs/fundamental/fundamental/financial_report_snapshot.md new file mode 100644 index 00000000..55532e88 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/financial_report_snapshot.md @@ -0,0 +1,261 @@ +--- +slug: financial-report-snapshot +title: Financial Report Snapshot +sidebar_position: 26 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get an AI-generated earnings summary, revenue/EBIT/EPS forecast vs actual (beat/miss analysis), and key financial ratios. + + +longbridge financial-report snapshot AAPL.US +longbridge financial-report snapshot AAPL.US --report qf --year 2024 --period 4 + + + + + +## Parameters + +> **SDK method parameters.** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| report | string | NO | Report type: `qf` (quarterly) / `saf` (semi-annual) / `af` (annual) | +| fiscal_year | uint32 | NO | Fiscal year, e.g. `2024` | +| fiscal_period | string | NO | Fiscal period, e.g. `1` / `2` / `3` / `4` | + +## Request Example + + + + +```python +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.financial_report_snapshot("AAPL.US", report="qf", fiscal_year=2024, fiscal_period="4") +print(resp) +``` + + + + +```python +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.financial_report_snapshot("AAPL.US", report="qf", fiscal_year=2024, fiscal_period="4") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.financialReportSnapshot('AAPL.US', { report: 'qf', fiscalYear: 2024, fiscalPeriod: '4' }) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getFinancialReportSnapshot("AAPL.US", "qf", 2024, "4").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.financial_report_snapshot("AAPL.US", Some("qf"), Some(2024), Some("4")).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.financial_report_snapshot("AAPL.US", "qf", 2024, "4", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.FinancialReportSnapshot(context.Background(), "AAPL.US", "qf", 2024, "4") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "name": "Apple Inc.", + "ticker": "AAPL.US", + "fp_start": "2024-10-01", + "fp_end": "2024-12-31", + "currency": "USD", + "report_desc": "Apple delivered record revenue of $124.3B in Q1 FY2025...", + "fo_revenue": {"value": "124300000000", "yoy": "0.0407", "cmp_desc": "beat by 1.2%", "est_value": "123800000000"}, + "fo_ebit": {"value": "42800000000", "yoy": "0.0520", "cmp_desc": "beat by 0.8%", "est_value": "42500000000"}, + "fo_eps": {"value": "2.40", "yoy": "0.0870", "cmp_desc": "beat by 2.1%", "est_value": "2.35"}, + "fr_revenue": {"value": "124300000000", "yoy": "0.0407"}, + "fr_profit": {"value": "36330000000", "yoy": "0.0710"}, + "fr_roe_ttm": "0.1570", + "fr_profit_margin": "0.2923", + "fr_debt_assets_ratio": "0.8120" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [FinancialReportSnapshotResponse](#FinancialReportSnapshotResponse) | +| 400 | Bad request | None | + +## Schemas + +### FinancialReportSnapshotResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | false | Company name | +| ticker | string | false | Security ticker | +| fp_start | string | false | Fiscal period start date | +| fp_end | string | false | Fiscal period end date | +| currency | string | false | Currency code | +| report_desc | string | false | AI-generated earnings summary text | +| fo_revenue | object | false | Revenue forecast comparison | +| fo_revenue.value | string | false | Actual revenue | +| fo_revenue.yoy | string | false | Year-over-year growth rate (decimal) | +| fo_revenue.cmp_desc | string | false | Beat/miss description | +| fo_revenue.est_value | string | false | Consensus estimate value | +| fo_ebit | object | false | EBIT forecast comparison (same fields as fo_revenue) | +| fo_eps | object | false | EPS forecast comparison (same fields as fo_revenue) | +| fr_revenue | object | false | Revenue financial data | +| fr_revenue.value | string | false | Revenue value | +| fr_revenue.yoy | string | false | Year-over-year growth rate | +| fr_profit | object | false | Net profit financial data (same fields as fr_revenue) | +| fr_operate_cash | object | false | Operating cash flow (same fields as fr_revenue) | +| fr_invest_cash | object | false | Investing cash flow (same fields as fr_revenue) | +| fr_finance_cash | object | false | Financing cash flow (same fields as fr_revenue) | +| fr_total_assets | object | false | Total assets (same fields as fr_revenue) | +| fr_total_liability | object | false | Total liabilities (same fields as fr_revenue) | +| fr_roe_ttm | string | false | Return on equity TTM (decimal) | +| fr_profit_margin | string | false | Net profit margin (decimal) | +| fr_profit_margin_ttm | string | false | Net profit margin TTM (decimal) | +| fr_asset_turn_ttm | string | false | Asset turnover rate TTM (decimal) | +| fr_leverage_ttm | string | false | Leverage ratio TTM (decimal) | +| fr_debt_assets_ratio | string | false | Debt-to-assets ratio (decimal) | diff --git a/docs/en/docs/fundamental/fundamental/industry_peers.md b/docs/en/docs/fundamental/fundamental/industry_peers.md new file mode 100644 index 00000000..14c8ff3d --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/industry_peers.md @@ -0,0 +1,245 @@ +--- +slug: industry-peers +title: Industry Peer Hierarchy +sidebar_position: 25 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the hierarchical sub-sector tree for an industry group, including stock count, daily change, and YTD change at each node. Counter IDs come from `industry_rank`. + + +longbridge industry-peers BK/US/IN00258 +longbridge industry-peers BK/HK/IN20337 + + + + + +## Parameters + +> **SDK method parameters.** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| counter_id | string | YES | Industry unique identifier (BK/MARKET/ID format) from `industry_rank` | +| market | string | YES | Market code: `US` / `HK` / `CN` / `SG` | + +## Request Example + + + + +```python +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_peers("BK/US/IN00258", "US") +print(resp) +``` + + + + +```python +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_peers("BK/US/IN00258", "US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.industryPeers('BK/US/IN00258', 'US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getIndustryPeers("BK/US/IN00258", "US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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_peers("BK/US/IN00258", "US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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_peers("BK/US/IN00258", "US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.IndustryPeers(context.Background(), "BK/US/IN00258", "US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "top": {"name": "All Industries", "market": "US"}, + "chain": { + "name": "Technology", + "counter_id": "BK/US/IN00258", + "stock_num": 542, + "chg": "0.0231", + "ytd_chg": "0.0875", + "next": [ + { + "name": "Semiconductors", + "counter_id": "BK/US/IN00297", + "stock_num": 87, + "chg": "0.0512", + "ytd_chg": "0.1243", + "next": [] + } + ] + } + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [IndustryPeersResponse](#IndustryPeersResponse) | +| 400 | Bad request | None | + +## Schemas + +### IndustryPeersResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| top | object | false | Top-level industry info | +| top.name | string | false | Top-level industry name | +| top.market | string | false | Market code | +| chain | object | false | Industry hierarchy tree root node | +| chain.name | string | false | Sector name | +| chain.counter_id | string | false | Sector unique identifier | +| chain.stock_num | integer | false | Number of stocks in the sector | +| chain.chg | string | false | Daily change (decimal) | +| chain.ytd_chg | string | false | Year-to-date change (decimal) | +| chain.next | array | false | Sub-sector list (same structure as chain, recursive) | diff --git a/docs/en/docs/fundamental/fundamental/industry_rank.md b/docs/en/docs/fundamental/fundamental/industry_rank.md new file mode 100644 index 00000000..c4380796 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/industry_rank.md @@ -0,0 +1,245 @@ +--- +slug: industry-rank +title: Industry Ranking +sidebar_position: 24 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the industry ranking list by market and indicator. The returned Counter ID can be passed directly to `industry_peers` to explore the sub-sector hierarchy. + + +longbridge industry-rank --market US +longbridge industry-rank --market HK --indicator market-cap + + + + + +## Parameters + +> **SDK method parameters.** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | YES | Market code: `US` / `HK` / `CN` / `SG` | +| indicator | string | YES | Ranking indicator: `leading-gainer` / `today-trend` / `popularity` / `market-cap` / `revenue` / `revenue-growth` / `net-profit` / `net-profit-growth` | +| sort_type | string | YES | Sort mode: `single` / `multi` | +| limit | uint32 | YES | Number of results to return, default 20 | + +## Request Example + + + + +```python +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_rank("US", "leading-gainer", "single", 20) +print(resp) +``` + + + + +```python +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_rank("US", "leading-gainer", "single", 20) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.industryRank('US', 'leading-gainer', 'single', 20) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getIndustryRank("US", "leading-gainer", "single", 20).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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_rank("US", "leading-gainer", "single", 20).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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_rank("US", "leading-gainer", "single", 20, [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.IndustryRank(context.Background(), "US", "leading-gainer", "single", 20) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "items": [ + { + "lists": [ + { + "name": "Technology", + "counter_id": "BK/US/IN00258", + "chg": "0.0231", + "leading_name": "NVIDIA", + "leading_ticker": "NVDA.US", + "leading_chg": "0.0512", + "value_name": "", + "value_data": "" + } + ] + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [IndustryRankResponse](#IndustryRankResponse) | +| 400 | Bad request | None | + +## Schemas + +### IndustryRankResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| items | array | false | Ranking group list | +| items[].lists | array | false | Industry entry list | +| items[].lists[].name | string | false | Industry name | +| items[].lists[].counter_id | string | false | Industry unique identifier (BK/MARKET/ID format), usable in `industry_peers` | +| items[].lists[].chg | string | false | Daily change (decimal) | +| items[].lists[].leading_name | string | false | Top-gaining stock name | +| items[].lists[].leading_ticker | string | false | Top-gaining stock ticker | +| items[].lists[].leading_chg | string | false | Top-gaining stock change | +| items[].lists[].value_name | string | false | Indicator name (populated by indicator type) | +| items[].lists[].value_data | string | false | Indicator value | diff --git a/docs/en/docs/fundamental/fundamental/institution_rating_views.md b/docs/en/docs/fundamental/fundamental/institution_rating_views.md new file mode 100644 index 00000000..93ef2871 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/institution_rating_views.md @@ -0,0 +1,244 @@ +--- +slug: institution-rating-views +title: Institutional Rating Views Timeline +sidebar_position: 23 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the monthly institutional rating (buy/hold/sell) distribution timeline, newest first. + + +longbridge institution-rating AAPL.US --views +longbridge institution-rating TSLA.US --views + + + + + +## Parameters + +> **SDK method parameters.** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +## Request Example + + + + +```python +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.institution_rating_views("AAPL.US") +print(resp) +``` + + + + +```python +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.institution_rating_views("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.institutionRatingViews('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getInstitutionRatingViews("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.institution_rating_views("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.institution_rating_views("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.InstitutionRatingViews(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "elist": [ + { + "date": 1746057600, + "buy": 18, + "over": 5, + "hold": 17, + "under": 3, + "sell": 4, + "total": 51 + }, + { + "date": 1743379200, + "buy": 17, + "over": 6, + "hold": 18, + "under": 3, + "sell": 5, + "total": 53 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [InstitutionRatingViewsResponse](#InstitutionRatingViewsResponse) | +| 400 | Bad request | None | + +## Schemas + +### InstitutionRatingViewsResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| elist | array | false | Monthly rating distribution list, newest first | +| elist[].date | int64 | false | Unix timestamp (seconds) | +| elist[].buy | integer | false | Buy rating count | +| elist[].over | integer | false | Outperform rating count | +| elist[].hold | integer | false | Hold rating count | +| elist[].under | integer | false | Underperform rating count | +| elist[].sell | integer | false | Sell rating count | +| elist[].total | integer | false | Total analyst count | diff --git a/docs/zh-CN/docs/cli/fundamentals/business-segments.md b/docs/zh-CN/docs/cli/fundamentals/business-segments.md new file mode 100644 index 00000000..9fd15354 --- /dev/null +++ b/docs/zh-CN/docs/cli/fundamentals/business-segments.md @@ -0,0 +1,61 @@ +--- +title: 'business-segments' +sidebar_label: 'business-segments' +sidebar_position: 15 +--- + +# longbridge business-segments + +Show revenue breakdown by business segment for a company — current period totals or historical trends across reporting periods. + +## Basic Usage + +```bash +longbridge business-segments AAPL.US +``` + +``` +Period: Q1 FY2026 Total: 124,300,000,000 Currency: USD + +| segment | amount | share | +|-------------------|-----------------|--------| +| iPhone | 69,140,000,000 | 55.62% | +| Services | 26,340,000,000 | 21.19% | +| Mac | 7,940,000,000 | 6.39% | +| iPad | 8,090,000,000 | 6.51% | +| Wearables & Other | 12,790,000,000 | 10.29% | +``` + +## Examples + +### Current period breakdown + +```bash +longbridge business-segments AAPL.US +``` + +Shows each business segment's revenue and its share of total revenue for the most recent reporting period. + +### Historical segment trends + +```bash +longbridge business-segments AAPL.US --history +``` + +Returns segment revenue across multiple reporting periods so you can track how the revenue mix has shifted over time. + +### Filter by report type + +```bash +longbridge business-segments AAPL.US --history --report af +``` + +Use `--report` to scope the history to a specific period type: `af` (annual), `saf` (semi-annual), `qf` (quarterly). + +## Options + +| Flag | Description | +|------|-------------| +| `--history` | Show historical segment data across multiple periods | +| `--report ` | Period type filter: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | +| `--format json` | Output raw JSON | diff --git a/docs/zh-CN/docs/cli/fundamentals/financial-report.md b/docs/zh-CN/docs/cli/fundamentals/financial-report.md index c5971f2c..d1082ecb 100644 --- a/docs/zh-CN/docs/cli/fundamentals/financial-report.md +++ b/docs/zh-CN/docs/cli/fundamentals/financial-report.md @@ -59,3 +59,37 @@ longbridge financial-report 700.HK --kind BS --report af ``` 获取腾讯的年度资产负债表。使用 `--report` 选择报告周期:`af`(年报)、`saf`(半年报)、`q1`、`3q` 或 `qf`(季报)。 + +### AI 财报速览 + +```bash +longbridge financial-report snapshot AAPL.US +``` + +``` +Apple Inc. (AAPL) Q1 FY2026 Jan 2026 – Mar 2026 USD + +本季度苹果整体表现稳健,营收和每股收益均超过分析师预期。服务业务继续 +表现亮眼,部分抵消了中国区以外 iPhone 销量的下滑。 + +── 预期 vs 实际 ───────────────────────────────────────────────────── +| 指标 | 一致预期 | 实际 | 超预期幅度 | +|------------|-----------|-----------|------------| +| 营收 | 123.15B | 124.30B | +0.93% | +| EBIT | 34.21B | 35.43B | +3.57% | +| 净利润 | 29.48B | 30.52B | +3.53% | + +── 同行即将发布财报 ────────────────────────────────────────────────── +| 公司 | 代码 | 日期 | +|-----------|----------|------------| +| Microsoft | MSFT.US | 2026-04-29 | +| Alphabet | GOOG.US | 2026-04-29 | +| Meta | META.US | 2026-04-30 | +``` + +`snapshot` 子命令提供 AI 生成的财报摘要、相对一致性预期的超/低预期分析,以及同行公司的即将发布财报日期。 + +```bash +# 查询历史特定季度 +longbridge financial-report snapshot TSLA.US --report qf --year 2025 --period 4 +``` diff --git a/docs/zh-CN/docs/cli/fundamentals/industry-peers.md b/docs/zh-CN/docs/cli/fundamentals/industry-peers.md new file mode 100644 index 00000000..3d81fc9a --- /dev/null +++ b/docs/zh-CN/docs/cli/fundamentals/industry-peers.md @@ -0,0 +1,59 @@ +--- +title: 'industry-peers' +sidebar_label: 'industry-peers' +sidebar_position: 17 +--- + +# longbridge industry-peers + +Explore the hierarchical sub-sector tree for an industry group. Takes a BK counter ID from [`industry-rank`](./industry-rank) and expands it into a full competitive landscape — sub-sectors, their sub-sectors, and the stocks in each. + +## Basic Usage + +```bash +longbridge industry-peers BK/US/IN00258 +``` + +``` +Root: Semiconductors (US) + +├── Design & Fabless 23 stocks +3.12% YTD +18.4% +│ ├── GPU & AI Chips 8 stocks +4.91% YTD +24.1% +│ ├── Mobile SoC 6 stocks +2.33% YTD +12.8% +│ └── Analog IC 9 stocks +1.54% YTD +9.3% +├── Foundry & Manufacturing 7 stocks +2.87% YTD +15.6% +│ ├── Logic Foundry 3 stocks +3.11% YTD +19.2% +│ └── Memory 4 stocks +2.61% YTD +11.9% +└── Equipment & Materials 12 stocks +1.43% YTD +7.2% +``` + +## Examples + +### Explore a sector from industry-rank + +```bash +# Step 1: find a sector +longbridge industry-rank --market US + +# Step 2: drill into it using the counter_id column +longbridge industry-peers BK/US/IN00258 +``` + +### HK sector tree + +```bash +longbridge industry-peers BK/HK/IN00012 +``` + +Works the same way across markets — use counter IDs from `industry-rank --market HK`, `--market CN`, or `--market SG`. + +## Options + +| Flag | Description | +|------|-------------| +| `--format json` | Output raw JSON | + +## Notes + +- Counter IDs follow the format `BK//IN` — copy them directly from `industry-rank` output +- Each node shows stock count, daily change, and YTD change diff --git a/docs/zh-CN/docs/cli/fundamentals/industry-rank.md b/docs/zh-CN/docs/cli/fundamentals/industry-rank.md new file mode 100644 index 00000000..fafcec6f --- /dev/null +++ b/docs/zh-CN/docs/cli/fundamentals/industry-rank.md @@ -0,0 +1,77 @@ +--- +title: 'industry-rank' +sidebar_label: 'industry-rank' +sidebar_position: 16 +--- + +# longbridge industry-rank + +Rank all industries in a market by a chosen indicator — see which sectors are leading today, which have the strongest revenue growth, or which are attracting the most capital. + +## Basic Usage + +```bash +longbridge industry-rank --market US +``` + +``` +| rank | name | counter_id | chg | indicator | +|------|-----------------------------------------|-----------------|--------|-----------| +| 1 | Semiconductors | BK/US/IN00258 | +3.82% | ... | +| 2 | Software - Infrastructure | BK/US/IN00305 | +2.91% | ... | +| 3 | Biotechnology | BK/US/IN00043 | +2.54% | ... | +| 4 | Electronic Components | BK/US/IN00099 | +1.98% | ... | +| 5 | Asset Management | BK/US/IN00033 | +1.73% | ... | +``` + +The `counter_id` column (e.g. `BK/US/IN00258`) can be passed directly to [`industry-peers`](./industry-peers) to explore the competitive tree within that sector. + +## Examples + +### Leading industries today + +```bash +longbridge industry-rank --market US +``` + +Ranks industries by daily price performance. Replace `US` with `HK`, `CN`, or `SG` to switch markets. + +### Top industries by market cap + +```bash +longbridge industry-rank --market HK --indicator market-cap +``` + +### Top industries by revenue growth + +```bash +longbridge industry-rank --market CN --indicator revenue-growth +``` + +### Then drill into a sector + +```bash +# Get the counter_id from industry-rank, then explore its sub-sectors +longbridge industry-peers BK/US/IN00258 +``` + +## Options + +| Flag | Description | +|------|-------------| +| `--market ` | Market to rank: `US`, `HK`, `CN`, `SG` | +| `--indicator ` | Ranking indicator (see below) | +| `--format json` | Output raw JSON | + +### Indicators + +| Value | Description | +|-------|-------------| +| `leading-gainer` | Daily price performance (default) | +| `today-trend` | Intraday trend strength | +| `popularity` | Search and watchlist activity | +| `market-cap` | Total market capitalisation | +| `revenue` | Latest revenue | +| `revenue-growth` | YoY revenue growth rate | +| `net-profit` | Latest net profit | +| `net-profit-growth` | YoY net profit growth rate | diff --git a/docs/zh-CN/docs/cli/fundamentals/institution-rating.md b/docs/zh-CN/docs/cli/fundamentals/institution-rating.md index 20bf316e..a55055fb 100644 --- a/docs/zh-CN/docs/cli/fundamentals/institution-rating.md +++ b/docs/zh-CN/docs/cli/fundamentals/institution-rating.md @@ -112,3 +112,20 @@ longbridge institution-rating TSLA.US --format json ``` `evaluate` 对象包含 52 位覆盖分析师的各评级数量;`target` 对象显示最高和最低目标价,以及上一收盘价供参考。 + +### 月度分析师情绪趋势 + +```bash +longbridge institution-rating TSLA.US --views +``` + +``` +| month | strong_buy | buy | hold | sell | under | no_opinion | total | +|---------|------------|-----|------|------|-------|------------|-------| +| 2026-04 | 18 | 5 | 17 | 6 | 2 | 4 | 52 | +| 2026-03 | 17 | 6 | 18 | 5 | 3 | 3 | 52 | +| 2026-02 | 16 | 7 | 19 | 5 | 3 | 2 | 52 | +| 2026-01 | 15 | 8 | 19 | 6 | 2 | 2 | 52 | +``` + +按月展示买入/持有/卖出评级分布的变化,最新月份在前。与 `--history`(个别分析师目标价变化)配合使用,可从两个维度了解机构情绪趋势。 diff --git a/docs/zh-CN/docs/cli/release-notes.md b/docs/zh-CN/docs/cli/release-notes.md index cc5df0dc..06cd814f 100644 --- a/docs/zh-CN/docs/cli/release-notes.md +++ b/docs/zh-CN/docs/cli/release-notes.md @@ -7,6 +7,14 @@ sidebar_icon: newspaper # Release Notes +### [v0.21.0](https://github.com/longbridge/longbridge-terminal/releases/tag/v0.21.0) + +- **新增 `business-segments`** — 按业务分部拆解营收,支持当期数据或历史趋势对比 +- **新增 `industry-rank`** — 按市场(US/HK/CN/SG)和指标对行业排名;Counter ID 可直接传给 `industry-peers` +- **新增 `industry-peers`** — 行业子板块树形结构,展示各节点的股票数、当日涨跌和年初至今涨跌 +- **新增 `financial-report snapshot`** — AI 财报摘要,含超/低预期分析和同行即将发布财报日期 +- **新增 `institution-rating --views`** — 逐月展示机构评级分布变化趋势 + ### [v0.20.3](https://github.com/longbridge/longbridge-terminal/releases/tag/v0.20.3) - **Breaking:移除 `analyst-estimates` 命令** — 该命令已下线;EPS 和营收预测数据请改用 `consensus` diff --git a/docs/zh-CN/docs/fundamental/fundamental/business_segments.md b/docs/zh-CN/docs/fundamental/fundamental/business_segments.md new file mode 100644 index 00000000..fb1cd9fa --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/business_segments.md @@ -0,0 +1,232 @@ +--- +slug: business-segments +title: 业务分部(当前期) +sidebar_position: 21 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取上市公司当前报告期的业务分部收入占比。 + + +longbridge business-segments AAPL.US +longbridge business-segments 700.HK + + + + + +## Parameters + +> **SDK 方法参数。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | + +## Request Example + + + + +```python +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.business_segments("AAPL.US") +print(resp) +``` + + + + +```python +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.business_segments("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.businessSegments('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getBusinessSegments("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.business_segments("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.business_segments("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.BusinessSegments(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "date": "2024Q4", + "total": "124300000000", + "currency": "USD", + "business": [ + {"name": "iPhone", "percent": "0.5619"}, + {"name": "Services", "percent": "0.2196"}, + {"name": "Mac", "percent": "0.0804"}, + {"name": "iPad", "percent": "0.0700"}, + {"name": "Wearables", "percent": "0.0681"} + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [BusinessSegmentsResponse](#BusinessSegmentsResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### BusinessSegmentsResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| date | string | 否 | 报告期标签,例如 `2024Q4` | +| total | string | 否 | 当期总收入(字符串数值) | +| currency | string | 否 | 货币代码,例如 `USD` | +| business | array | 否 | 业务分部列表 | +| business[].name | string | 否 | 业务分部名称 | +| business[].percent | string | 否 | 收入占比(0–1 小数) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/business_segments_history.md b/docs/zh-CN/docs/fundamental/fundamental/business_segments_history.md new file mode 100644 index 00000000..71fa9c00 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/business_segments_history.md @@ -0,0 +1,245 @@ +--- +slug: business-segments-history +title: 业务分部(历史趋势) +sidebar_position: 22 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取上市公司按报告期的历史业务分部收入趋势。 + + +longbridge business-segments AAPL.US --history +longbridge business-segments AAPL.US --history --report qf + + + + + +## Parameters + +> **SDK 方法参数。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| report | string | 否 | 报告类型:`qf`(季报)/ `saf`(半年报)/ `af`(年报) | +| cate | string | 否 | 分部类别过滤 | + +## Request Example + + + + +```python +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.business_segments_history("AAPL.US", report="qf") +print(resp) +``` + + + + +```python +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.business_segments_history("AAPL.US", report="qf") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.businessSegmentsHistory('AAPL.US', { report: 'qf' }) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getBusinessSegmentsHistory("AAPL.US", "qf", null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.business_segments_history("AAPL.US", Some("qf"), None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.business_segments_history("AAPL.US", "qf", "", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.BusinessSegmentsHistory(context.Background(), "AAPL.US", "qf", "") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "historical": [ + { + "date": "2024Q4", + "total": "124300000000", + "currency": "USD", + "business": [ + {"name": "iPhone", "percent": "0.5619", "value": "69900000000"}, + {"name": "Services", "percent": "0.2196", "value": "26300000000"} + ], + "regionals": [ + {"name": "Americas", "percent": "0.4280", "value": "53200000000"}, + {"name": "Europe", "percent": "0.2520", "value": "30100000000"} + ] + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [BusinessSegmentsHistoryResponse](#BusinessSegmentsHistoryResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### BusinessSegmentsHistoryResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| historical | array | 否 | 历史报告期列表 | +| historical[].date | string | 否 | 报告期标签,例如 `2024Q4` | +| historical[].total | string | 否 | 当期总收入(字符串数值) | +| historical[].currency | string | 否 | 货币代码 | +| historical[].business | array | 否 | 业务分部列表 | +| historical[].business[].name | string | 否 | 业务分部名称 | +| historical[].business[].percent | string | 否 | 收入占比(0–1 小数) | +| historical[].business[].value | string | 否 | 绝对收入数值 | +| historical[].regionals | array | 否 | 地区分部列表 | +| historical[].regionals[].name | string | 否 | 地区名称 | +| historical[].regionals[].percent | string | 否 | 收入占比(0–1 小数) | +| historical[].regionals[].value | string | 否 | 绝对收入数值 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/financial_report_snapshot.md b/docs/zh-CN/docs/fundamental/fundamental/financial_report_snapshot.md new file mode 100644 index 00000000..1656f717 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/financial_report_snapshot.md @@ -0,0 +1,261 @@ +--- +slug: financial-report-snapshot +title: 财报快照(AI 摘要 + 预测对比) +sidebar_position: 26 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取 AI 生成的财报摘要、营收/EBIT/EPS 预测对比(超预期/低于预期),以及关键财务指标。 + + +longbridge financial-report snapshot AAPL.US +longbridge financial-report snapshot AAPL.US --report qf --year 2024 --period 4 + + + + + +## Parameters + +> **SDK 方法参数。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| report | string | 否 | 报告类型:`qf`(季报)/ `saf`(半年报)/ `af`(年报) | +| fiscal_year | uint32 | 否 | 财政年度,例如 `2024` | +| fiscal_period | string | 否 | 财政季度,例如 `1` / `2` / `3` / `4` | + +## Request Example + + + + +```python +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.financial_report_snapshot("AAPL.US", report="qf", fiscal_year=2024, fiscal_period="4") +print(resp) +``` + + + + +```python +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.financial_report_snapshot("AAPL.US", report="qf", fiscal_year=2024, fiscal_period="4") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.financialReportSnapshot('AAPL.US', { report: 'qf', fiscalYear: 2024, fiscalPeriod: '4' }) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getFinancialReportSnapshot("AAPL.US", "qf", 2024, "4").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.financial_report_snapshot("AAPL.US", Some("qf"), Some(2024), Some("4")).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.financial_report_snapshot("AAPL.US", "qf", 2024, "4", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.FinancialReportSnapshot(context.Background(), "AAPL.US", "qf", 2024, "4") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "name": "Apple Inc.", + "ticker": "AAPL.US", + "fp_start": "2024-10-01", + "fp_end": "2024-12-31", + "currency": "USD", + "report_desc": "Apple delivered record revenue of $124.3B in Q1 FY2025...", + "fo_revenue": {"value": "124300000000", "yoy": "0.0407", "cmp_desc": "beat by 1.2%", "est_value": "123800000000"}, + "fo_ebit": {"value": "42800000000", "yoy": "0.0520", "cmp_desc": "beat by 0.8%", "est_value": "42500000000"}, + "fo_eps": {"value": "2.40", "yoy": "0.0870", "cmp_desc": "beat by 2.1%", "est_value": "2.35"}, + "fr_revenue": {"value": "124300000000", "yoy": "0.0407"}, + "fr_profit": {"value": "36330000000", "yoy": "0.0710"}, + "fr_roe_ttm": "0.1570", + "fr_profit_margin": "0.2923", + "fr_debt_assets_ratio": "0.8120" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [FinancialReportSnapshotResponse](#FinancialReportSnapshotResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### FinancialReportSnapshotResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | 否 | 公司名称 | +| ticker | string | 否 | 证券代码 | +| fp_start | string | 否 | 财政期开始日期 | +| fp_end | string | 否 | 财政期结束日期 | +| currency | string | 否 | 货币代码 | +| report_desc | string | 否 | AI 生成的财报摘要文字 | +| fo_revenue | object | 否 | 营收预测对比 | +| fo_revenue.value | string | 否 | 实际营收 | +| fo_revenue.yoy | string | 否 | 同比增速(小数) | +| fo_revenue.cmp_desc | string | 否 | 超预期/低于预期描述 | +| fo_revenue.est_value | string | 否 | 一致预期值 | +| fo_ebit | object | 否 | EBIT 预测对比(字段同 fo_revenue) | +| fo_eps | object | 否 | EPS 预测对比(字段同 fo_revenue) | +| fr_revenue | object | 否 | 营收财务数据 | +| fr_revenue.value | string | 否 | 营收数值 | +| fr_revenue.yoy | string | 否 | 同比增速 | +| fr_profit | object | 否 | 净利润财务数据(字段同 fr_revenue) | +| fr_operate_cash | object | 否 | 经营现金流(字段同 fr_revenue) | +| fr_invest_cash | object | 否 | 投资现金流(字段同 fr_revenue) | +| fr_finance_cash | object | 否 | 融资现金流(字段同 fr_revenue) | +| fr_total_assets | object | 否 | 总资产(字段同 fr_revenue) | +| fr_total_liability | object | 否 | 总负债(字段同 fr_revenue) | +| fr_roe_ttm | string | 否 | 净资产收益率 TTM(小数) | +| fr_profit_margin | string | 否 | 净利率(小数) | +| fr_profit_margin_ttm | string | 否 | 净利率 TTM(小数) | +| fr_asset_turn_ttm | string | 否 | 资产周转率 TTM(小数) | +| fr_leverage_ttm | string | 否 | 杠杆率 TTM(小数) | +| fr_debt_assets_ratio | string | 否 | 资产负债率(小数) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/industry_peers.md b/docs/zh-CN/docs/fundamental/fundamental/industry_peers.md new file mode 100644 index 00000000..4813f495 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/industry_peers.md @@ -0,0 +1,245 @@ +--- +slug: industry-peers +title: 行业子板块层级树 +sidebar_position: 25 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取行业分组的层级子板块树,含各节点股票数量、日涨跌幅和年初至今涨跌幅。Counter ID 可从 `industry_rank` 返回结果中获取。 + + +longbridge industry-peers BK/US/IN00258 +longbridge industry-peers BK/HK/IN20337 + + + + + +## Parameters + +> **SDK 方法参数。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| counter_id | string | 是 | 行业唯一标识(BK/市场/ID 格式),来源于 `industry_rank` | +| market | string | 是 | 市场代码:`US` / `HK` / `CN` / `SG` | + +## Request Example + + + + +```python +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_peers("BK/US/IN00258", "US") +print(resp) +``` + + + + +```python +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_peers("BK/US/IN00258", "US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.industryPeers('BK/US/IN00258', 'US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getIndustryPeers("BK/US/IN00258", "US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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_peers("BK/US/IN00258", "US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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_peers("BK/US/IN00258", "US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.IndustryPeers(context.Background(), "BK/US/IN00258", "US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "top": {"name": "All Industries", "market": "US"}, + "chain": { + "name": "Technology", + "counter_id": "BK/US/IN00258", + "stock_num": 542, + "chg": "0.0231", + "ytd_chg": "0.0875", + "next": [ + { + "name": "Semiconductors", + "counter_id": "BK/US/IN00297", + "stock_num": 87, + "chg": "0.0512", + "ytd_chg": "0.1243", + "next": [] + } + ] + } + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryPeersResponse](#IndustryPeersResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### IndustryPeersResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| top | object | 否 | 顶层行业信息 | +| top.name | string | 否 | 顶层行业名称 | +| top.market | string | 否 | 市场代码 | +| chain | object | 否 | 行业层级树根节点 | +| chain.name | string | 否 | 板块名称 | +| chain.counter_id | string | 否 | 板块唯一标识 | +| chain.stock_num | integer | 否 | 板块内股票数量 | +| chain.chg | string | 否 | 当日涨跌幅(小数) | +| chain.ytd_chg | string | 否 | 年初至今涨跌幅(小数) | +| chain.next | array | 否 | 子板块列表(结构与 chain 相同,递归) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/industry_rank.md b/docs/zh-CN/docs/fundamental/fundamental/industry_rank.md new file mode 100644 index 00000000..3c68e8cb --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/industry_rank.md @@ -0,0 +1,245 @@ +--- +slug: industry-rank +title: 行业排行榜 +sidebar_position: 24 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +按市场和指标获取行业排行榜。返回的 Counter ID 可直接传入 `industry_peers` 查询子行业树。 + + +longbridge industry-rank --market US +longbridge industry-rank --market HK --indicator market-cap + + + + + +## Parameters + +> **SDK 方法参数。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | 是 | 市场代码:`US` / `HK` / `CN` / `SG` | +| indicator | string | 是 | 排行指标:`leading-gainer` / `today-trend` / `popularity` / `market-cap` / `revenue` / `revenue-growth` / `net-profit` / `net-profit-growth` | +| sort_type | string | 是 | 排序方式:`single`(单一排序)/ `multi`(多维排序) | +| limit | uint32 | 是 | 返回条数,默认 20 | + +## Request Example + + + + +```python +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_rank("US", "leading-gainer", "single", 20) +print(resp) +``` + + + + +```python +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_rank("US", "leading-gainer", "single", 20) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.industryRank('US', 'leading-gainer', 'single', 20) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getIndustryRank("US", "leading-gainer", "single", 20).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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_rank("US", "leading-gainer", "single", 20).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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_rank("US", "leading-gainer", "single", 20, [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.IndustryRank(context.Background(), "US", "leading-gainer", "single", 20) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "items": [ + { + "lists": [ + { + "name": "Technology", + "counter_id": "BK/US/IN00258", + "chg": "0.0231", + "leading_name": "NVIDIA", + "leading_ticker": "NVDA.US", + "leading_chg": "0.0512", + "value_name": "", + "value_data": "" + } + ] + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryRankResponse](#IndustryRankResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### IndustryRankResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| items | array | 否 | 排行分组列表 | +| items[].lists | array | 否 | 行业条目列表 | +| items[].lists[].name | string | 否 | 行业名称 | +| items[].lists[].counter_id | string | 否 | 行业唯一标识(BK/市场/ID 格式),可传入 `industry_peers` | +| items[].lists[].chg | string | 否 | 当日涨跌幅(小数) | +| items[].lists[].leading_name | string | 否 | 涨幅领先个股名称 | +| items[].lists[].leading_ticker | string | 否 | 涨幅领先个股代码 | +| items[].lists[].leading_chg | string | 否 | 涨幅领先个股涨跌幅 | +| items[].lists[].value_name | string | 否 | 指标名称(按指标类型填充) | +| items[].lists[].value_data | string | 否 | 指标数值 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/institution_rating_views.md b/docs/zh-CN/docs/fundamental/fundamental/institution_rating_views.md new file mode 100644 index 00000000..c27a0644 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/institution_rating_views.md @@ -0,0 +1,244 @@ +--- +slug: institution-rating-views +title: 机构评级分布时间线 +sidebar_position: 23 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取按月统计的机构评级(买入/持有/卖出)分布时间线,最新月份在前。 + + +longbridge institution-rating AAPL.US --views +longbridge institution-rating TSLA.US --views + + + + + +## Parameters + +> **SDK 方法参数。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | + +## Request Example + + + + +```python +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.institution_rating_views("AAPL.US") +print(resp) +``` + + + + +```python +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.institution_rating_views("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.institutionRatingViews('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getInstitutionRatingViews("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.institution_rating_views("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.institution_rating_views("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.InstitutionRatingViews(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "elist": [ + { + "date": 1746057600, + "buy": 18, + "over": 5, + "hold": 17, + "under": 3, + "sell": 4, + "total": 51 + }, + { + "date": 1743379200, + "buy": 17, + "over": 6, + "hold": 18, + "under": 3, + "sell": 5, + "total": 53 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InstitutionRatingViewsResponse](#InstitutionRatingViewsResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### InstitutionRatingViewsResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| elist | array | 否 | 月度评级分布列表,最新月份在前 | +| elist[].date | int64 | 否 | Unix 时间戳(秒) | +| elist[].buy | integer | 否 | 买入评级数量 | +| elist[].over | integer | 否 | 跑赢市场评级数量 | +| elist[].hold | integer | 否 | 持有评级数量 | +| elist[].under | integer | 否 | 跑输市场评级数量 | +| elist[].sell | integer | 否 | 卖出评级数量 | +| elist[].total | integer | 否 | 机构总数 | diff --git a/docs/zh-HK/docs/cli/fundamentals/business-segments.md b/docs/zh-HK/docs/cli/fundamentals/business-segments.md new file mode 100644 index 00000000..9fd15354 --- /dev/null +++ b/docs/zh-HK/docs/cli/fundamentals/business-segments.md @@ -0,0 +1,61 @@ +--- +title: 'business-segments' +sidebar_label: 'business-segments' +sidebar_position: 15 +--- + +# longbridge business-segments + +Show revenue breakdown by business segment for a company — current period totals or historical trends across reporting periods. + +## Basic Usage + +```bash +longbridge business-segments AAPL.US +``` + +``` +Period: Q1 FY2026 Total: 124,300,000,000 Currency: USD + +| segment | amount | share | +|-------------------|-----------------|--------| +| iPhone | 69,140,000,000 | 55.62% | +| Services | 26,340,000,000 | 21.19% | +| Mac | 7,940,000,000 | 6.39% | +| iPad | 8,090,000,000 | 6.51% | +| Wearables & Other | 12,790,000,000 | 10.29% | +``` + +## Examples + +### Current period breakdown + +```bash +longbridge business-segments AAPL.US +``` + +Shows each business segment's revenue and its share of total revenue for the most recent reporting period. + +### Historical segment trends + +```bash +longbridge business-segments AAPL.US --history +``` + +Returns segment revenue across multiple reporting periods so you can track how the revenue mix has shifted over time. + +### Filter by report type + +```bash +longbridge business-segments AAPL.US --history --report af +``` + +Use `--report` to scope the history to a specific period type: `af` (annual), `saf` (semi-annual), `qf` (quarterly). + +## Options + +| Flag | Description | +|------|-------------| +| `--history` | Show historical segment data across multiple periods | +| `--report ` | Period type filter: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | +| `--format json` | Output raw JSON | diff --git a/docs/zh-HK/docs/cli/fundamentals/financial-report.md b/docs/zh-HK/docs/cli/fundamentals/financial-report.md index 0a9391f3..b57b289b 100644 --- a/docs/zh-HK/docs/cli/fundamentals/financial-report.md +++ b/docs/zh-HK/docs/cli/fundamentals/financial-report.md @@ -59,3 +59,37 @@ longbridge financial-report 700.HK --kind BS --report af ``` 取得騰訊的年度資產負債表。使用 `--report` 選擇報告周期:`af`(年報)、`saf`(半年報)、`q1`、`3q` 或 `qf`(季報)。 + +### AI 财报速览 + +```bash +longbridge financial-report snapshot AAPL.US +``` + +``` +Apple Inc. (AAPL) Q1 FY2026 Jan 2026 – Mar 2026 USD + +本季度苹果整体表现稳健,营收和每股收益均超过分析师预期。服务业务继续 +表现亮眼,部分抵消了中国区以外 iPhone 销量的下滑。 + +── 预期 vs 实际 ───────────────────────────────────────────────────── +| 指标 | 一致预期 | 实际 | 超预期幅度 | +|------------|-----------|-----------|------------| +| 营收 | 123.15B | 124.30B | +0.93% | +| EBIT | 34.21B | 35.43B | +3.57% | +| 净利润 | 29.48B | 30.52B | +3.53% | + +── 同行即将发布财报 ────────────────────────────────────────────────── +| 公司 | 代码 | 日期 | +|-----------|----------|------------| +| Microsoft | MSFT.US | 2026-04-29 | +| Alphabet | GOOG.US | 2026-04-29 | +| Meta | META.US | 2026-04-30 | +``` + +`snapshot` 子命令提供 AI 生成的财报摘要、相对一致性预期的超/低预期分析,以及同行公司的即将发布财报日期。 + +```bash +# 查询历史特定季度 +longbridge financial-report snapshot TSLA.US --report qf --year 2025 --period 4 +``` diff --git a/docs/zh-HK/docs/cli/fundamentals/industry-peers.md b/docs/zh-HK/docs/cli/fundamentals/industry-peers.md new file mode 100644 index 00000000..3d81fc9a --- /dev/null +++ b/docs/zh-HK/docs/cli/fundamentals/industry-peers.md @@ -0,0 +1,59 @@ +--- +title: 'industry-peers' +sidebar_label: 'industry-peers' +sidebar_position: 17 +--- + +# longbridge industry-peers + +Explore the hierarchical sub-sector tree for an industry group. Takes a BK counter ID from [`industry-rank`](./industry-rank) and expands it into a full competitive landscape — sub-sectors, their sub-sectors, and the stocks in each. + +## Basic Usage + +```bash +longbridge industry-peers BK/US/IN00258 +``` + +``` +Root: Semiconductors (US) + +├── Design & Fabless 23 stocks +3.12% YTD +18.4% +│ ├── GPU & AI Chips 8 stocks +4.91% YTD +24.1% +│ ├── Mobile SoC 6 stocks +2.33% YTD +12.8% +│ └── Analog IC 9 stocks +1.54% YTD +9.3% +├── Foundry & Manufacturing 7 stocks +2.87% YTD +15.6% +│ ├── Logic Foundry 3 stocks +3.11% YTD +19.2% +│ └── Memory 4 stocks +2.61% YTD +11.9% +└── Equipment & Materials 12 stocks +1.43% YTD +7.2% +``` + +## Examples + +### Explore a sector from industry-rank + +```bash +# Step 1: find a sector +longbridge industry-rank --market US + +# Step 2: drill into it using the counter_id column +longbridge industry-peers BK/US/IN00258 +``` + +### HK sector tree + +```bash +longbridge industry-peers BK/HK/IN00012 +``` + +Works the same way across markets — use counter IDs from `industry-rank --market HK`, `--market CN`, or `--market SG`. + +## Options + +| Flag | Description | +|------|-------------| +| `--format json` | Output raw JSON | + +## Notes + +- Counter IDs follow the format `BK//IN` — copy them directly from `industry-rank` output +- Each node shows stock count, daily change, and YTD change diff --git a/docs/zh-HK/docs/cli/fundamentals/industry-rank.md b/docs/zh-HK/docs/cli/fundamentals/industry-rank.md new file mode 100644 index 00000000..fafcec6f --- /dev/null +++ b/docs/zh-HK/docs/cli/fundamentals/industry-rank.md @@ -0,0 +1,77 @@ +--- +title: 'industry-rank' +sidebar_label: 'industry-rank' +sidebar_position: 16 +--- + +# longbridge industry-rank + +Rank all industries in a market by a chosen indicator — see which sectors are leading today, which have the strongest revenue growth, or which are attracting the most capital. + +## Basic Usage + +```bash +longbridge industry-rank --market US +``` + +``` +| rank | name | counter_id | chg | indicator | +|------|-----------------------------------------|-----------------|--------|-----------| +| 1 | Semiconductors | BK/US/IN00258 | +3.82% | ... | +| 2 | Software - Infrastructure | BK/US/IN00305 | +2.91% | ... | +| 3 | Biotechnology | BK/US/IN00043 | +2.54% | ... | +| 4 | Electronic Components | BK/US/IN00099 | +1.98% | ... | +| 5 | Asset Management | BK/US/IN00033 | +1.73% | ... | +``` + +The `counter_id` column (e.g. `BK/US/IN00258`) can be passed directly to [`industry-peers`](./industry-peers) to explore the competitive tree within that sector. + +## Examples + +### Leading industries today + +```bash +longbridge industry-rank --market US +``` + +Ranks industries by daily price performance. Replace `US` with `HK`, `CN`, or `SG` to switch markets. + +### Top industries by market cap + +```bash +longbridge industry-rank --market HK --indicator market-cap +``` + +### Top industries by revenue growth + +```bash +longbridge industry-rank --market CN --indicator revenue-growth +``` + +### Then drill into a sector + +```bash +# Get the counter_id from industry-rank, then explore its sub-sectors +longbridge industry-peers BK/US/IN00258 +``` + +## Options + +| Flag | Description | +|------|-------------| +| `--market ` | Market to rank: `US`, `HK`, `CN`, `SG` | +| `--indicator ` | Ranking indicator (see below) | +| `--format json` | Output raw JSON | + +### Indicators + +| Value | Description | +|-------|-------------| +| `leading-gainer` | Daily price performance (default) | +| `today-trend` | Intraday trend strength | +| `popularity` | Search and watchlist activity | +| `market-cap` | Total market capitalisation | +| `revenue` | Latest revenue | +| `revenue-growth` | YoY revenue growth rate | +| `net-profit` | Latest net profit | +| `net-profit-growth` | YoY net profit growth rate | diff --git a/docs/zh-HK/docs/cli/fundamentals/institution-rating.md b/docs/zh-HK/docs/cli/fundamentals/institution-rating.md index fd903897..0e3369f3 100644 --- a/docs/zh-HK/docs/cli/fundamentals/institution-rating.md +++ b/docs/zh-HK/docs/cli/fundamentals/institution-rating.md @@ -96,3 +96,20 @@ longbridge institution-rating TSLA.US --format json ``` `evaluate` 對象包含 52 位覆蓋分析師的各評級數量;`target` 對象顯示最高和最低目標價,以及上一收盤價供參考。 + +### 月度分析师情绪趋势 + +```bash +longbridge institution-rating TSLA.US --views +``` + +``` +| month | strong_buy | buy | hold | sell | under | no_opinion | total | +|---------|------------|-----|------|------|-------|------------|-------| +| 2026-04 | 18 | 5 | 17 | 6 | 2 | 4 | 52 | +| 2026-03 | 17 | 6 | 18 | 5 | 3 | 3 | 52 | +| 2026-02 | 16 | 7 | 19 | 5 | 3 | 2 | 52 | +| 2026-01 | 15 | 8 | 19 | 6 | 2 | 2 | 52 | +``` + +按月展示买入/持有/卖出评级分布的变化,最新月份在前。与 `--history`(个别分析师目标价变化)配合使用,可从两个维度了解机构情绪趋势。 diff --git a/docs/zh-HK/docs/cli/release-notes.md b/docs/zh-HK/docs/cli/release-notes.md index 229cbe78..89596895 100644 --- a/docs/zh-HK/docs/cli/release-notes.md +++ b/docs/zh-HK/docs/cli/release-notes.md @@ -7,6 +7,14 @@ sidebar_icon: newspaper # Release Notes +### [v0.21.0](https://github.com/longbridge/longbridge-terminal/releases/tag/v0.21.0) + +- **新增 `business-segments`** — 按业务分部拆解营收,支持当期数据或历史趋势对比 +- **新增 `industry-rank`** — 按市场(US/HK/CN/SG)和指标对行业排名;Counter ID 可直接传给 `industry-peers` +- **新增 `industry-peers`** — 行业子板块树形结构,展示各节点的股票数、当日涨跌和年初至今涨跌 +- **新增 `financial-report snapshot`** — AI 财报摘要,含超/低预期分析和同行即将发布财报日期 +- **新增 `institution-rating --views`** — 逐月展示机构评级分布变化趋势 + ### [v0.20.3](https://github.com/longbridge/longbridge-terminal/releases/tag/v0.20.3) - **Breaking:移除 `analyst-estimates` 指令** — 該指令已下線;EPS 及營收預測數據請改用 `consensus` diff --git a/docs/zh-HK/docs/fundamental/fundamental/business_segments.md b/docs/zh-HK/docs/fundamental/fundamental/business_segments.md new file mode 100644 index 00000000..a85f7e1e --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/business_segments.md @@ -0,0 +1,232 @@ +--- +slug: business-segments +title: 業務分部(當前期) +sidebar_position: 21 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取上市公司當前報告期的業務分部收入佔比。 + + +longbridge business-segments AAPL.US +longbridge business-segments 700.HK + + + + + +## Parameters + +> **SDK 方法參數。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | + +## Request Example + + + + +```python +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.business_segments("AAPL.US") +print(resp) +``` + + + + +```python +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.business_segments("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.businessSegments('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getBusinessSegments("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.business_segments("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.business_segments("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.BusinessSegments(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "date": "2024Q4", + "total": "124300000000", + "currency": "USD", + "business": [ + {"name": "iPhone", "percent": "0.5619"}, + {"name": "Services", "percent": "0.2196"}, + {"name": "Mac", "percent": "0.0804"}, + {"name": "iPad", "percent": "0.0700"}, + {"name": "Wearables", "percent": "0.0681"} + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [BusinessSegmentsResponse](#BusinessSegmentsResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### BusinessSegmentsResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| date | string | 否 | 報告期標籤,例如 `2024Q4` | +| total | string | 否 | 當期總收入(字串數值) | +| currency | string | 否 | 貨幣代碼,例如 `USD` | +| business | array | 否 | 業務分部列表 | +| business[].name | string | 否 | 業務分部名稱 | +| business[].percent | string | 否 | 收入佔比(0–1 小數) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/business_segments_history.md b/docs/zh-HK/docs/fundamental/fundamental/business_segments_history.md new file mode 100644 index 00000000..84c5fc51 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/business_segments_history.md @@ -0,0 +1,245 @@ +--- +slug: business-segments-history +title: 業務分部(歷史趨勢) +sidebar_position: 22 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取上市公司按報告期的歷史業務分部收入趨勢。 + + +longbridge business-segments AAPL.US --history +longbridge business-segments AAPL.US --history --report qf + + + + + +## Parameters + +> **SDK 方法參數。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| report | string | 否 | 報告類型:`qf`(季報)/ `saf`(半年報)/ `af`(年報) | +| cate | string | 否 | 分部類別過濾 | + +## Request Example + + + + +```python +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.business_segments_history("AAPL.US", report="qf") +print(resp) +``` + + + + +```python +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.business_segments_history("AAPL.US", report="qf") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.businessSegmentsHistory('AAPL.US', { report: 'qf' }) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getBusinessSegmentsHistory("AAPL.US", "qf", null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.business_segments_history("AAPL.US", Some("qf"), None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.business_segments_history("AAPL.US", "qf", "", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.BusinessSegmentsHistory(context.Background(), "AAPL.US", "qf", "") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "historical": [ + { + "date": "2024Q4", + "total": "124300000000", + "currency": "USD", + "business": [ + {"name": "iPhone", "percent": "0.5619", "value": "69900000000"}, + {"name": "Services", "percent": "0.2196", "value": "26300000000"} + ], + "regionals": [ + {"name": "Americas", "percent": "0.4280", "value": "53200000000"}, + {"name": "Europe", "percent": "0.2520", "value": "30100000000"} + ] + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [BusinessSegmentsHistoryResponse](#BusinessSegmentsHistoryResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### BusinessSegmentsHistoryResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| historical | array | 否 | 歷史報告期列表 | +| historical[].date | string | 否 | 報告期標籤,例如 `2024Q4` | +| historical[].total | string | 否 | 當期總收入(字串數值) | +| historical[].currency | string | 否 | 貨幣代碼 | +| historical[].business | array | 否 | 業務分部列表 | +| historical[].business[].name | string | 否 | 業務分部名稱 | +| historical[].business[].percent | string | 否 | 收入佔比(0–1 小數) | +| historical[].business[].value | string | 否 | 絕對收入數值 | +| historical[].regionals | array | 否 | 地區分部列表 | +| historical[].regionals[].name | string | 否 | 地區名稱 | +| historical[].regionals[].percent | string | 否 | 收入佔比(0–1 小數) | +| historical[].regionals[].value | string | 否 | 絕對收入數值 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/financial_report_snapshot.md b/docs/zh-HK/docs/fundamental/fundamental/financial_report_snapshot.md new file mode 100644 index 00000000..bf9e7bcd --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/financial_report_snapshot.md @@ -0,0 +1,261 @@ +--- +slug: financial-report-snapshot +title: 財報快照(AI 摘要 + 預測對比) +sidebar_position: 26 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取 AI 生成的財報摘要、營收/EBIT/EPS 預測對比(超預期/低於預期),以及關鍵財務指標。 + + +longbridge financial-report snapshot AAPL.US +longbridge financial-report snapshot AAPL.US --report qf --year 2024 --period 4 + + + + + +## Parameters + +> **SDK 方法參數。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| report | string | 否 | 報告類型:`qf`(季報)/ `saf`(半年報)/ `af`(年報) | +| fiscal_year | uint32 | 否 | 財政年度,例如 `2024` | +| fiscal_period | string | 否 | 財政季度,例如 `1` / `2` / `3` / `4` | + +## Request Example + + + + +```python +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.financial_report_snapshot("AAPL.US", report="qf", fiscal_year=2024, fiscal_period="4") +print(resp) +``` + + + + +```python +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.financial_report_snapshot("AAPL.US", report="qf", fiscal_year=2024, fiscal_period="4") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.financialReportSnapshot('AAPL.US', { report: 'qf', fiscalYear: 2024, fiscalPeriod: '4' }) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getFinancialReportSnapshot("AAPL.US", "qf", 2024, "4").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.financial_report_snapshot("AAPL.US", Some("qf"), Some(2024), Some("4")).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.financial_report_snapshot("AAPL.US", "qf", 2024, "4", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.FinancialReportSnapshot(context.Background(), "AAPL.US", "qf", 2024, "4") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "name": "Apple Inc.", + "ticker": "AAPL.US", + "fp_start": "2024-10-01", + "fp_end": "2024-12-31", + "currency": "USD", + "report_desc": "Apple delivered record revenue of $124.3B in Q1 FY2025...", + "fo_revenue": {"value": "124300000000", "yoy": "0.0407", "cmp_desc": "beat by 1.2%", "est_value": "123800000000"}, + "fo_ebit": {"value": "42800000000", "yoy": "0.0520", "cmp_desc": "beat by 0.8%", "est_value": "42500000000"}, + "fo_eps": {"value": "2.40", "yoy": "0.0870", "cmp_desc": "beat by 2.1%", "est_value": "2.35"}, + "fr_revenue": {"value": "124300000000", "yoy": "0.0407"}, + "fr_profit": {"value": "36330000000", "yoy": "0.0710"}, + "fr_roe_ttm": "0.1570", + "fr_profit_margin": "0.2923", + "fr_debt_assets_ratio": "0.8120" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [FinancialReportSnapshotResponse](#FinancialReportSnapshotResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### FinancialReportSnapshotResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | 否 | 公司名稱 | +| ticker | string | 否 | 證券代碼 | +| fp_start | string | 否 | 財政期開始日期 | +| fp_end | string | 否 | 財政期結束日期 | +| currency | string | 否 | 貨幣代碼 | +| report_desc | string | 否 | AI 生成的財報摘要文字 | +| fo_revenue | object | 否 | 營收預測對比 | +| fo_revenue.value | string | 否 | 實際營收 | +| fo_revenue.yoy | string | 否 | 同比增速(小數) | +| fo_revenue.cmp_desc | string | 否 | 超預期/低於預期描述 | +| fo_revenue.est_value | string | 否 | 一致預期值 | +| fo_ebit | object | 否 | EBIT 預測對比(欄位同 fo_revenue) | +| fo_eps | object | 否 | EPS 預測對比(欄位同 fo_revenue) | +| fr_revenue | object | 否 | 營收財務數據 | +| fr_revenue.value | string | 否 | 營收數值 | +| fr_revenue.yoy | string | 否 | 同比增速 | +| fr_profit | object | 否 | 淨利潤財務數據(欄位同 fr_revenue) | +| fr_operate_cash | object | 否 | 經營現金流(欄位同 fr_revenue) | +| fr_invest_cash | object | 否 | 投資現金流(欄位同 fr_revenue) | +| fr_finance_cash | object | 否 | 融資現金流(欄位同 fr_revenue) | +| fr_total_assets | object | 否 | 總資產(欄位同 fr_revenue) | +| fr_total_liability | object | 否 | 總負債(欄位同 fr_revenue) | +| fr_roe_ttm | string | 否 | 淨資產收益率 TTM(小數) | +| fr_profit_margin | string | 否 | 淨利率(小數) | +| fr_profit_margin_ttm | string | 否 | 淨利率 TTM(小數) | +| fr_asset_turn_ttm | string | 否 | 資產週轉率 TTM(小數) | +| fr_leverage_ttm | string | 否 | 槓桿率 TTM(小數) | +| fr_debt_assets_ratio | string | 否 | 資產負債率(小數) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/industry_peers.md b/docs/zh-HK/docs/fundamental/fundamental/industry_peers.md new file mode 100644 index 00000000..99917c59 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/industry_peers.md @@ -0,0 +1,245 @@ +--- +slug: industry-peers +title: 行業子板塊層級樹 +sidebar_position: 25 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取行業分組的層級子板塊樹,含各節點股票數量、日漲跌幅和年初至今漲跌幅。Counter ID 可從 `industry_rank` 返回結果中獲取。 + + +longbridge industry-peers BK/US/IN00258 +longbridge industry-peers BK/HK/IN20337 + + + + + +## Parameters + +> **SDK 方法參數。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| counter_id | string | 是 | 行業唯一標識(BK/市場/ID 格式),來源於 `industry_rank` | +| market | string | 是 | 市場代碼:`US` / `HK` / `CN` / `SG` | + +## Request Example + + + + +```python +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_peers("BK/US/IN00258", "US") +print(resp) +``` + + + + +```python +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_peers("BK/US/IN00258", "US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.industryPeers('BK/US/IN00258', 'US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getIndustryPeers("BK/US/IN00258", "US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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_peers("BK/US/IN00258", "US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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_peers("BK/US/IN00258", "US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.IndustryPeers(context.Background(), "BK/US/IN00258", "US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "top": {"name": "All Industries", "market": "US"}, + "chain": { + "name": "Technology", + "counter_id": "BK/US/IN00258", + "stock_num": 542, + "chg": "0.0231", + "ytd_chg": "0.0875", + "next": [ + { + "name": "Semiconductors", + "counter_id": "BK/US/IN00297", + "stock_num": 87, + "chg": "0.0512", + "ytd_chg": "0.1243", + "next": [] + } + ] + } + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryPeersResponse](#IndustryPeersResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### IndustryPeersResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| top | object | 否 | 頂層行業資訊 | +| top.name | string | 否 | 頂層行業名稱 | +| top.market | string | 否 | 市場代碼 | +| chain | object | 否 | 行業層級樹根節點 | +| chain.name | string | 否 | 板塊名稱 | +| chain.counter_id | string | 否 | 板塊唯一標識 | +| chain.stock_num | integer | 否 | 板塊內股票數量 | +| chain.chg | string | 否 | 當日漲跌幅(小數) | +| chain.ytd_chg | string | 否 | 年初至今漲跌幅(小數) | +| chain.next | array | 否 | 子板塊列表(結構與 chain 相同,遞迴) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/industry_rank.md b/docs/zh-HK/docs/fundamental/fundamental/industry_rank.md new file mode 100644 index 00000000..d16eba30 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/industry_rank.md @@ -0,0 +1,245 @@ +--- +slug: industry-rank +title: 行業排行榜 +sidebar_position: 24 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +按市場和指標獲取行業排行榜。返回的 Counter ID 可直接傳入 `industry_peers` 查詢子行業樹。 + + +longbridge industry-rank --market US +longbridge industry-rank --market HK --indicator market-cap + + + + + +## Parameters + +> **SDK 方法參數。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | 是 | 市場代碼:`US` / `HK` / `CN` / `SG` | +| indicator | string | 是 | 排行指標:`leading-gainer` / `today-trend` / `popularity` / `market-cap` / `revenue` / `revenue-growth` / `net-profit` / `net-profit-growth` | +| sort_type | string | 是 | 排序方式:`single`(單一排序)/ `multi`(多維排序) | +| limit | uint32 | 是 | 返回條數,預設 20 | + +## Request Example + + + + +```python +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_rank("US", "leading-gainer", "single", 20) +print(resp) +``` + + + + +```python +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_rank("US", "leading-gainer", "single", 20) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.industryRank('US', 'leading-gainer', 'single', 20) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getIndustryRank("US", "leading-gainer", "single", 20).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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_rank("US", "leading-gainer", "single", 20).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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_rank("US", "leading-gainer", "single", 20, [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.IndustryRank(context.Background(), "US", "leading-gainer", "single", 20) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "items": [ + { + "lists": [ + { + "name": "Technology", + "counter_id": "BK/US/IN00258", + "chg": "0.0231", + "leading_name": "NVIDIA", + "leading_ticker": "NVDA.US", + "leading_chg": "0.0512", + "value_name": "", + "value_data": "" + } + ] + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryRankResponse](#IndustryRankResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### IndustryRankResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| items | array | 否 | 排行分組列表 | +| items[].lists | array | 否 | 行業條目列表 | +| items[].lists[].name | string | 否 | 行業名稱 | +| items[].lists[].counter_id | string | 否 | 行業唯一標識(BK/市場/ID 格式),可傳入 `industry_peers` | +| items[].lists[].chg | string | 否 | 當日漲跌幅(小數) | +| items[].lists[].leading_name | string | 否 | 漲幅領先個股名稱 | +| items[].lists[].leading_ticker | string | 否 | 漲幅領先個股代碼 | +| items[].lists[].leading_chg | string | 否 | 漲幅領先個股漲跌幅 | +| items[].lists[].value_name | string | 否 | 指標名稱(按指標類型填充) | +| items[].lists[].value_data | string | 否 | 指標數值 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/institution_rating_views.md b/docs/zh-HK/docs/fundamental/fundamental/institution_rating_views.md new file mode 100644 index 00000000..1022d0ae --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/institution_rating_views.md @@ -0,0 +1,244 @@ +--- +slug: institution-rating-views +title: 機構評級分佈時間線 +sidebar_position: 23 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取按月統計的機構評級(買入/持有/賣出)分佈時間線,最新月份在前。 + + +longbridge institution-rating AAPL.US --views +longbridge institution-rating TSLA.US --views + + + + + +## Parameters + +> **SDK 方法參數。** + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | + +## Request Example + + + + +```python +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.institution_rating_views("AAPL.US") +print(resp) +``` + + + + +```python +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.institution_rating_views("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +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.institutionRatingViews('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +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.getInstitutionRatingViews("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, fundamental::FundamentalContext, Config}; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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.institution_rating_views("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +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.institution_rating_views("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +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.InstitutionRatingViews(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "elist": [ + { + "date": 1746057600, + "buy": 18, + "over": 5, + "hold": 17, + "under": 3, + "sell": 4, + "total": 51 + }, + { + "date": 1743379200, + "buy": 17, + "over": 6, + "hold": 18, + "under": 3, + "sell": 5, + "total": 53 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InstitutionRatingViewsResponse](#InstitutionRatingViewsResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### InstitutionRatingViewsResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| elist | array | 否 | 月度評級分佈列表,最新月份在前 | +| elist[].date | int64 | 否 | Unix 時間戳(秒) | +| elist[].buy | integer | 否 | 買入評級數量 | +| elist[].over | integer | 否 | 跑贏市場評級數量 | +| elist[].hold | integer | 否 | 持有評級數量 | +| elist[].under | integer | 否 | 跑輸市場評級數量 | +| elist[].sell | integer | 否 | 賣出評級數量 | +| elist[].total | integer | 否 | 機構總數 |