From 04848d6264b8f4e330968f8dbed8e0cb22f88200 Mon Sep 17 00:00:00 2001 From: Endless Agent Date: Fri, 8 May 2026 06:53:00 +0000 Subject: [PATCH 01/18] feat(dev): task #11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 任务:将 openapi commit 523035611 新增的 SDK 接口同步到 developers 文档站 你的任务是将 openapi 仓库 commit `523035611c81 🤖 Generated with Endless Co-authored-by: 老袁 Yuan Zhanghong --- docs/en/docs/account/_category_.json | 1 + docs/en/docs/account/alert/_category_.json | 1 + docs/en/docs/account/alert/create_alert.md | 240 ++++++++++++++++ docs/en/docs/account/alert/delete_alert.md | 233 ++++++++++++++++ docs/en/docs/account/alert/list_alerts.md | 252 +++++++++++++++++ docs/en/docs/account/alert/update_alert.md | 234 ++++++++++++++++ docs/en/docs/account/dca/_category_.json | 1 + docs/en/docs/account/dca/create_dca.md | 241 ++++++++++++++++ docs/en/docs/account/dca/dca_history.md | 252 +++++++++++++++++ docs/en/docs/account/dca/delete_dca.md | 231 ++++++++++++++++ docs/en/docs/account/dca/list_dca.md | 255 +++++++++++++++++ docs/en/docs/account/dca/update_dca.md | 234 ++++++++++++++++ .../en/docs/account/portfolio/_category_.json | 1 + .../en/docs/account/portfolio/capital_flow.md | 259 ++++++++++++++++++ .../docs/account/portfolio/exchange_rates.md | 246 +++++++++++++++++ .../portfolio/profit_analysis_by_market.md | 258 +++++++++++++++++ .../portfolio/profit_analysis_detail.md | 251 +++++++++++++++++ .../portfolio/profit_analysis_summary.md | 254 +++++++++++++++++ .../en/docs/account/sharelist/_category_.json | 1 + .../account/sharelist/create_sharelist.md | 237 ++++++++++++++++ .../account/sharelist/delete_sharelist.md | 231 ++++++++++++++++ .../docs/account/sharelist/list_sharelist.md | 254 +++++++++++++++++ .../account/sharelist/update_sharelist.md | 236 ++++++++++++++++ docs/en/docs/fundamental/_category_.json | 1 + .../docs/fundamental/calendar/_category_.json | 1 + .../fundamental/calendar/dividend_calendar.md | 254 +++++++++++++++++ .../fundamental/calendar/earnings_calendar.md | 254 +++++++++++++++++ .../docs/fundamental/calendar/ipo_calendar.md | 254 +++++++++++++++++ .../fundamental/calendar/macro_calendar.md | 256 +++++++++++++++++ .../fundamental/calendar/split_calendar.md | 252 +++++++++++++++++ .../fundamental/fundamental/_category_.json | 1 + .../fundamental/company_profile.md | 249 +++++++++++++++++ .../fundamental/corporate_actions.md | 250 +++++++++++++++++ .../docs/fundamental/fundamental/dividends.md | 252 +++++++++++++++++ .../fundamental/fundamental/executives.md | 248 +++++++++++++++++ .../fundamental/financial_report.md | 254 +++++++++++++++++ .../fundamental/fundamental/fund_holdings.md | 248 +++++++++++++++++ .../docs/fundamental/fundamental/ratings.md | 250 +++++++++++++++++ .../fundamental/fundamental/shareholders.md | 248 +++++++++++++++++ .../fundamental/fundamental/valuations.md | 246 +++++++++++++++++ .../docs/fundamental/market/_category_.json | 1 + docs/en/docs/fundamental/market/ah_premium.md | 250 +++++++++++++++++ .../fundamental/market/broker_positions.md | 252 +++++++++++++++++ .../fundamental/market/index_components.md | 256 +++++++++++++++++ .../docs/fundamental/market/market_status.md | 249 +++++++++++++++++ .../docs/fundamental/market/trading_stats.md | 252 +++++++++++++++++ .../docs/fundamental/market/unusual_items.md | 250 +++++++++++++++++ .../en/docs/quote/individual/update_pinned.md | 210 ++++++++++++++ docs/en/docs/quote/pull/option_volume.md | 249 +++++++++++++++++ .../en/docs/quote/pull/option_volume_daily.md | 257 +++++++++++++++++ docs/en/docs/quote/pull/short_positions.md | 253 +++++++++++++++++ docs/zh-CN/docs/account/_category_.json | 1 + docs/zh-CN/docs/account/alert/_category_.json | 1 + docs/zh-CN/docs/account/alert/create_alert.md | 240 ++++++++++++++++ docs/zh-CN/docs/account/alert/delete_alert.md | 233 ++++++++++++++++ docs/zh-CN/docs/account/alert/list_alerts.md | 252 +++++++++++++++++ docs/zh-CN/docs/account/alert/update_alert.md | 234 ++++++++++++++++ docs/zh-CN/docs/account/dca/_category_.json | 1 + docs/zh-CN/docs/account/dca/create_dca.md | 241 ++++++++++++++++ docs/zh-CN/docs/account/dca/dca_history.md | 252 +++++++++++++++++ docs/zh-CN/docs/account/dca/delete_dca.md | 231 ++++++++++++++++ docs/zh-CN/docs/account/dca/list_dca.md | 255 +++++++++++++++++ docs/zh-CN/docs/account/dca/update_dca.md | 234 ++++++++++++++++ .../docs/account/portfolio/_category_.json | 1 + .../docs/account/portfolio/capital_flow.md | 259 ++++++++++++++++++ .../docs/account/portfolio/exchange_rates.md | 246 +++++++++++++++++ .../portfolio/profit_analysis_by_market.md | 258 +++++++++++++++++ .../portfolio/profit_analysis_detail.md | 251 +++++++++++++++++ .../portfolio/profit_analysis_summary.md | 254 +++++++++++++++++ .../docs/account/sharelist/_category_.json | 1 + .../account/sharelist/create_sharelist.md | 237 ++++++++++++++++ .../account/sharelist/delete_sharelist.md | 231 ++++++++++++++++ .../docs/account/sharelist/list_sharelist.md | 254 +++++++++++++++++ .../account/sharelist/update_sharelist.md | 236 ++++++++++++++++ docs/zh-CN/docs/fundamental/_category_.json | 1 + .../docs/fundamental/calendar/_category_.json | 1 + .../fundamental/calendar/dividend_calendar.md | 254 +++++++++++++++++ .../fundamental/calendar/earnings_calendar.md | 254 +++++++++++++++++ .../docs/fundamental/calendar/ipo_calendar.md | 254 +++++++++++++++++ .../fundamental/calendar/macro_calendar.md | 256 +++++++++++++++++ .../fundamental/calendar/split_calendar.md | 252 +++++++++++++++++ .../fundamental/fundamental/_category_.json | 1 + .../fundamental/company_profile.md | 249 +++++++++++++++++ .../fundamental/corporate_actions.md | 250 +++++++++++++++++ .../docs/fundamental/fundamental/dividends.md | 252 +++++++++++++++++ .../fundamental/fundamental/executives.md | 248 +++++++++++++++++ .../fundamental/financial_report.md | 254 +++++++++++++++++ .../fundamental/fundamental/fund_holdings.md | 248 +++++++++++++++++ .../docs/fundamental/fundamental/ratings.md | 250 +++++++++++++++++ .../fundamental/fundamental/shareholders.md | 248 +++++++++++++++++ .../fundamental/fundamental/valuations.md | 246 +++++++++++++++++ .../docs/fundamental/market/_category_.json | 1 + .../docs/fundamental/market/ah_premium.md | 250 +++++++++++++++++ .../fundamental/market/broker_positions.md | 252 +++++++++++++++++ .../fundamental/market/index_components.md | 256 +++++++++++++++++ .../docs/fundamental/market/market_status.md | 249 +++++++++++++++++ .../docs/fundamental/market/trading_stats.md | 252 +++++++++++++++++ .../docs/fundamental/market/unusual_items.md | 250 +++++++++++++++++ .../docs/quote/individual/update_pinned.md | 210 ++++++++++++++ docs/zh-CN/docs/quote/pull/option_volume.md | 249 +++++++++++++++++ .../docs/quote/pull/option_volume_daily.md | 257 +++++++++++++++++ docs/zh-CN/docs/quote/pull/short_positions.md | 253 +++++++++++++++++ docs/zh-HK/docs/account/_category_.json | 1 + docs/zh-HK/docs/account/alert/_category_.json | 1 + docs/zh-HK/docs/account/alert/create_alert.md | 240 ++++++++++++++++ docs/zh-HK/docs/account/alert/delete_alert.md | 233 ++++++++++++++++ docs/zh-HK/docs/account/alert/list_alerts.md | 252 +++++++++++++++++ docs/zh-HK/docs/account/alert/update_alert.md | 234 ++++++++++++++++ docs/zh-HK/docs/account/dca/_category_.json | 1 + docs/zh-HK/docs/account/dca/create_dca.md | 241 ++++++++++++++++ docs/zh-HK/docs/account/dca/dca_history.md | 252 +++++++++++++++++ docs/zh-HK/docs/account/dca/delete_dca.md | 231 ++++++++++++++++ docs/zh-HK/docs/account/dca/list_dca.md | 255 +++++++++++++++++ docs/zh-HK/docs/account/dca/update_dca.md | 234 ++++++++++++++++ .../docs/account/portfolio/_category_.json | 1 + .../docs/account/portfolio/capital_flow.md | 259 ++++++++++++++++++ .../docs/account/portfolio/exchange_rates.md | 246 +++++++++++++++++ .../portfolio/profit_analysis_by_market.md | 258 +++++++++++++++++ .../portfolio/profit_analysis_detail.md | 251 +++++++++++++++++ .../portfolio/profit_analysis_summary.md | 254 +++++++++++++++++ .../docs/account/sharelist/_category_.json | 1 + .../account/sharelist/create_sharelist.md | 237 ++++++++++++++++ .../account/sharelist/delete_sharelist.md | 231 ++++++++++++++++ .../docs/account/sharelist/list_sharelist.md | 254 +++++++++++++++++ .../account/sharelist/update_sharelist.md | 236 ++++++++++++++++ docs/zh-HK/docs/fundamental/_category_.json | 1 + .../docs/fundamental/calendar/_category_.json | 1 + .../fundamental/calendar/dividend_calendar.md | 254 +++++++++++++++++ .../fundamental/calendar/earnings_calendar.md | 254 +++++++++++++++++ .../docs/fundamental/calendar/ipo_calendar.md | 254 +++++++++++++++++ .../fundamental/calendar/macro_calendar.md | 256 +++++++++++++++++ .../fundamental/calendar/split_calendar.md | 252 +++++++++++++++++ .../fundamental/fundamental/_category_.json | 1 + .../fundamental/company_profile.md | 249 +++++++++++++++++ .../fundamental/corporate_actions.md | 250 +++++++++++++++++ .../docs/fundamental/fundamental/dividends.md | 252 +++++++++++++++++ .../fundamental/fundamental/executives.md | 248 +++++++++++++++++ .../fundamental/financial_report.md | 254 +++++++++++++++++ .../fundamental/fundamental/fund_holdings.md | 248 +++++++++++++++++ .../docs/fundamental/fundamental/ratings.md | 250 +++++++++++++++++ .../fundamental/fundamental/shareholders.md | 248 +++++++++++++++++ .../fundamental/fundamental/valuations.md | 246 +++++++++++++++++ .../docs/fundamental/market/_category_.json | 1 + .../docs/fundamental/market/ah_premium.md | 250 +++++++++++++++++ .../fundamental/market/broker_positions.md | 252 +++++++++++++++++ .../fundamental/market/index_components.md | 256 +++++++++++++++++ .../docs/fundamental/market/market_status.md | 249 +++++++++++++++++ .../docs/fundamental/market/trading_stats.md | 252 +++++++++++++++++ .../docs/fundamental/market/unusual_items.md | 250 +++++++++++++++++ .../docs/quote/individual/update_pinned.md | 210 ++++++++++++++ docs/zh-HK/docs/quote/pull/option_volume.md | 249 +++++++++++++++++ .../docs/quote/pull/option_volume_daily.md | 257 +++++++++++++++++ docs/zh-HK/docs/quote/pull/short_positions.md | 253 +++++++++++++++++ 153 files changed, 31200 insertions(+) create mode 100644 docs/en/docs/account/_category_.json create mode 100644 docs/en/docs/account/alert/_category_.json create mode 100644 docs/en/docs/account/alert/create_alert.md create mode 100644 docs/en/docs/account/alert/delete_alert.md create mode 100644 docs/en/docs/account/alert/list_alerts.md create mode 100644 docs/en/docs/account/alert/update_alert.md create mode 100644 docs/en/docs/account/dca/_category_.json create mode 100644 docs/en/docs/account/dca/create_dca.md create mode 100644 docs/en/docs/account/dca/dca_history.md create mode 100644 docs/en/docs/account/dca/delete_dca.md create mode 100644 docs/en/docs/account/dca/list_dca.md create mode 100644 docs/en/docs/account/dca/update_dca.md create mode 100644 docs/en/docs/account/portfolio/_category_.json create mode 100644 docs/en/docs/account/portfolio/capital_flow.md create mode 100644 docs/en/docs/account/portfolio/exchange_rates.md create mode 100644 docs/en/docs/account/portfolio/profit_analysis_by_market.md create mode 100644 docs/en/docs/account/portfolio/profit_analysis_detail.md create mode 100644 docs/en/docs/account/portfolio/profit_analysis_summary.md create mode 100644 docs/en/docs/account/sharelist/_category_.json create mode 100644 docs/en/docs/account/sharelist/create_sharelist.md create mode 100644 docs/en/docs/account/sharelist/delete_sharelist.md create mode 100644 docs/en/docs/account/sharelist/list_sharelist.md create mode 100644 docs/en/docs/account/sharelist/update_sharelist.md create mode 100644 docs/en/docs/fundamental/_category_.json create mode 100644 docs/en/docs/fundamental/calendar/_category_.json create mode 100644 docs/en/docs/fundamental/calendar/dividend_calendar.md create mode 100644 docs/en/docs/fundamental/calendar/earnings_calendar.md create mode 100644 docs/en/docs/fundamental/calendar/ipo_calendar.md create mode 100644 docs/en/docs/fundamental/calendar/macro_calendar.md create mode 100644 docs/en/docs/fundamental/calendar/split_calendar.md create mode 100644 docs/en/docs/fundamental/fundamental/_category_.json create mode 100644 docs/en/docs/fundamental/fundamental/company_profile.md create mode 100644 docs/en/docs/fundamental/fundamental/corporate_actions.md create mode 100644 docs/en/docs/fundamental/fundamental/dividends.md create mode 100644 docs/en/docs/fundamental/fundamental/executives.md create mode 100644 docs/en/docs/fundamental/fundamental/financial_report.md create mode 100644 docs/en/docs/fundamental/fundamental/fund_holdings.md create mode 100644 docs/en/docs/fundamental/fundamental/ratings.md create mode 100644 docs/en/docs/fundamental/fundamental/shareholders.md create mode 100644 docs/en/docs/fundamental/fundamental/valuations.md create mode 100644 docs/en/docs/fundamental/market/_category_.json create mode 100644 docs/en/docs/fundamental/market/ah_premium.md create mode 100644 docs/en/docs/fundamental/market/broker_positions.md create mode 100644 docs/en/docs/fundamental/market/index_components.md create mode 100644 docs/en/docs/fundamental/market/market_status.md create mode 100644 docs/en/docs/fundamental/market/trading_stats.md create mode 100644 docs/en/docs/fundamental/market/unusual_items.md create mode 100644 docs/en/docs/quote/individual/update_pinned.md create mode 100644 docs/en/docs/quote/pull/option_volume.md create mode 100644 docs/en/docs/quote/pull/option_volume_daily.md create mode 100644 docs/en/docs/quote/pull/short_positions.md create mode 100644 docs/zh-CN/docs/account/_category_.json create mode 100644 docs/zh-CN/docs/account/alert/_category_.json create mode 100644 docs/zh-CN/docs/account/alert/create_alert.md create mode 100644 docs/zh-CN/docs/account/alert/delete_alert.md create mode 100644 docs/zh-CN/docs/account/alert/list_alerts.md create mode 100644 docs/zh-CN/docs/account/alert/update_alert.md create mode 100644 docs/zh-CN/docs/account/dca/_category_.json create mode 100644 docs/zh-CN/docs/account/dca/create_dca.md create mode 100644 docs/zh-CN/docs/account/dca/dca_history.md create mode 100644 docs/zh-CN/docs/account/dca/delete_dca.md create mode 100644 docs/zh-CN/docs/account/dca/list_dca.md create mode 100644 docs/zh-CN/docs/account/dca/update_dca.md create mode 100644 docs/zh-CN/docs/account/portfolio/_category_.json create mode 100644 docs/zh-CN/docs/account/portfolio/capital_flow.md create mode 100644 docs/zh-CN/docs/account/portfolio/exchange_rates.md create mode 100644 docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md create mode 100644 docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md create mode 100644 docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md create mode 100644 docs/zh-CN/docs/account/sharelist/_category_.json create mode 100644 docs/zh-CN/docs/account/sharelist/create_sharelist.md create mode 100644 docs/zh-CN/docs/account/sharelist/delete_sharelist.md create mode 100644 docs/zh-CN/docs/account/sharelist/list_sharelist.md create mode 100644 docs/zh-CN/docs/account/sharelist/update_sharelist.md create mode 100644 docs/zh-CN/docs/fundamental/_category_.json create mode 100644 docs/zh-CN/docs/fundamental/calendar/_category_.json create mode 100644 docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md create mode 100644 docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md create mode 100644 docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md create mode 100644 docs/zh-CN/docs/fundamental/calendar/macro_calendar.md create mode 100644 docs/zh-CN/docs/fundamental/calendar/split_calendar.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/_category_.json create mode 100644 docs/zh-CN/docs/fundamental/fundamental/company_profile.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/dividends.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/executives.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/financial_report.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/ratings.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/shareholders.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/valuations.md create mode 100644 docs/zh-CN/docs/fundamental/market/_category_.json create mode 100644 docs/zh-CN/docs/fundamental/market/ah_premium.md create mode 100644 docs/zh-CN/docs/fundamental/market/broker_positions.md create mode 100644 docs/zh-CN/docs/fundamental/market/index_components.md create mode 100644 docs/zh-CN/docs/fundamental/market/market_status.md create mode 100644 docs/zh-CN/docs/fundamental/market/trading_stats.md create mode 100644 docs/zh-CN/docs/fundamental/market/unusual_items.md create mode 100644 docs/zh-CN/docs/quote/individual/update_pinned.md create mode 100644 docs/zh-CN/docs/quote/pull/option_volume.md create mode 100644 docs/zh-CN/docs/quote/pull/option_volume_daily.md create mode 100644 docs/zh-CN/docs/quote/pull/short_positions.md create mode 100644 docs/zh-HK/docs/account/_category_.json create mode 100644 docs/zh-HK/docs/account/alert/_category_.json create mode 100644 docs/zh-HK/docs/account/alert/create_alert.md create mode 100644 docs/zh-HK/docs/account/alert/delete_alert.md create mode 100644 docs/zh-HK/docs/account/alert/list_alerts.md create mode 100644 docs/zh-HK/docs/account/alert/update_alert.md create mode 100644 docs/zh-HK/docs/account/dca/_category_.json create mode 100644 docs/zh-HK/docs/account/dca/create_dca.md create mode 100644 docs/zh-HK/docs/account/dca/dca_history.md create mode 100644 docs/zh-HK/docs/account/dca/delete_dca.md create mode 100644 docs/zh-HK/docs/account/dca/list_dca.md create mode 100644 docs/zh-HK/docs/account/dca/update_dca.md create mode 100644 docs/zh-HK/docs/account/portfolio/_category_.json create mode 100644 docs/zh-HK/docs/account/portfolio/capital_flow.md create mode 100644 docs/zh-HK/docs/account/portfolio/exchange_rates.md create mode 100644 docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md create mode 100644 docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md create mode 100644 docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md create mode 100644 docs/zh-HK/docs/account/sharelist/_category_.json create mode 100644 docs/zh-HK/docs/account/sharelist/create_sharelist.md create mode 100644 docs/zh-HK/docs/account/sharelist/delete_sharelist.md create mode 100644 docs/zh-HK/docs/account/sharelist/list_sharelist.md create mode 100644 docs/zh-HK/docs/account/sharelist/update_sharelist.md create mode 100644 docs/zh-HK/docs/fundamental/_category_.json create mode 100644 docs/zh-HK/docs/fundamental/calendar/_category_.json create mode 100644 docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md create mode 100644 docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md create mode 100644 docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md create mode 100644 docs/zh-HK/docs/fundamental/calendar/macro_calendar.md create mode 100644 docs/zh-HK/docs/fundamental/calendar/split_calendar.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/_category_.json create mode 100644 docs/zh-HK/docs/fundamental/fundamental/company_profile.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/dividends.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/executives.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/financial_report.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/ratings.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/shareholders.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/valuations.md create mode 100644 docs/zh-HK/docs/fundamental/market/_category_.json create mode 100644 docs/zh-HK/docs/fundamental/market/ah_premium.md create mode 100644 docs/zh-HK/docs/fundamental/market/broker_positions.md create mode 100644 docs/zh-HK/docs/fundamental/market/index_components.md create mode 100644 docs/zh-HK/docs/fundamental/market/market_status.md create mode 100644 docs/zh-HK/docs/fundamental/market/trading_stats.md create mode 100644 docs/zh-HK/docs/fundamental/market/unusual_items.md create mode 100644 docs/zh-HK/docs/quote/individual/update_pinned.md create mode 100644 docs/zh-HK/docs/quote/pull/option_volume.md create mode 100644 docs/zh-HK/docs/quote/pull/option_volume_daily.md create mode 100644 docs/zh-HK/docs/quote/pull/short_positions.md diff --git a/docs/en/docs/account/_category_.json b/docs/en/docs/account/_category_.json new file mode 100644 index 00000000..02325a35 --- /dev/null +++ b/docs/en/docs/account/_category_.json @@ -0,0 +1 @@ +{ "position": 6, "label": "Account", "collapsed": false } diff --git a/docs/en/docs/account/alert/_category_.json b/docs/en/docs/account/alert/_category_.json new file mode 100644 index 00000000..6722410e --- /dev/null +++ b/docs/en/docs/account/alert/_category_.json @@ -0,0 +1 @@ +{ "position": 2, "label": "Alerts", "collapsed": false } diff --git a/docs/en/docs/account/alert/create_alert.md b/docs/en/docs/account/alert/create_alert.md new file mode 100644 index 00000000..f369dee3 --- /dev/null +++ b/docs/en/docs/account/alert/create_alert.md @@ -0,0 +1,240 @@ +--- +slug: create-alert +title: Create Alert +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Create a new price alert for a security when it rises above or falls below a target price. + + +longbridge alert add TSLA.US --price 300 --direction rise +longbridge alert add AAPL.US --price 150 --direction fall + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/account/alerts
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.US` | +| price | string | YES | Target price | +| direction | string | YES | Alert direction: `rise` or `fall` | +| frequency | string | NO | Trigger frequency: `once` (default) or `every` | + +### Request Example + + + + + +longbridge alert add TSLA.US --price 300 --direction rise +longbridge alert add AAPL.US --price 150 --direction fall + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.create_alert() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.create_alert() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.create_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getCreateAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.create_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.create_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 486469 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_alert_rsp](#create_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_alert_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | ID of the newly created alert | diff --git a/docs/en/docs/account/alert/delete_alert.md b/docs/en/docs/account/alert/delete_alert.md new file mode 100644 index 00000000..3d0828e8 --- /dev/null +++ b/docs/en/docs/account/alert/delete_alert.md @@ -0,0 +1,233 @@ +--- +slug: delete-alert +title: Delete Alert +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Delete a price alert by its ID. + + +longbridge alert delete 486469 +longbridge alert delete 112326 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/account/alerts/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Alert ID (path parameter) | + +### Request Example + + + + + +longbridge alert delete 486469 +longbridge alert delete 112326 + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.delete_alert("486469") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.delete_alert("486469") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.delete_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getDeleteAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.delete_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.delete_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_alert_rsp](#delete_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_alert_rsp + + + +No response body fields. diff --git a/docs/en/docs/account/alert/list_alerts.md b/docs/en/docs/account/alert/list_alerts.md new file mode 100644 index 00000000..3ebdc4d1 --- /dev/null +++ b/docs/en/docs/account/alert/list_alerts.md @@ -0,0 +1,252 @@ +--- +slug: list-alerts +title: List Alerts +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get all price alerts for the current user, with optional filtering by symbol. + + +longbridge alert +longbridge alert TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/alerts
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | NO | Filter by security symbol, e.g. `TSLA.US` | + +### Request Example + + + + + +longbridge alert +longbridge alert TSLA.US + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.list_alerts() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.list_alerts() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.list_alerts() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getListAlerts().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.list_alerts().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.list_alerts([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListAlerts(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "id": 112326, + "symbol": "TSLA.US", + "price": "348.950", + "direction": "fall", + "enabled": true, + "frequency": "every" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_alerts_rsp](#list_alerts_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_alerts_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Alert list | +| ∟ id | int64 | true | Alert ID | +| ∟ symbol | string | true | Security symbol | +| ∟ price | string | true | Target price | +| ∟ direction | string | true | Direction: `rise` or `fall` | +| ∟ enabled | bool | true | Whether alert is enabled | +| ∟ frequency | string | true | Trigger frequency: `once` or `every` | diff --git a/docs/en/docs/account/alert/update_alert.md b/docs/en/docs/account/alert/update_alert.md new file mode 100644 index 00000000..edcc0642 --- /dev/null +++ b/docs/en/docs/account/alert/update_alert.md @@ -0,0 +1,234 @@ +--- +slug: update-alert +title: Update Alert +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Enable or disable an existing price alert. + + +longbridge alert enable 112326 +longbridge alert disable 112326 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Alert ID (path parameter) | +| enabled | bool | YES | Set to `true` to enable or `false` to disable | + +### Request Example + + + + + +longbridge alert enable 112326 +longbridge alert disable 112326 + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.update_alert("112326", enabled=True) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.update_alert("112326", enabled=True) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.update_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getUpdateAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.update_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.update_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_alert_rsp](#update_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_alert_rsp + + + +No response body fields. diff --git a/docs/en/docs/account/dca/_category_.json b/docs/en/docs/account/dca/_category_.json new file mode 100644 index 00000000..3d43361f --- /dev/null +++ b/docs/en/docs/account/dca/_category_.json @@ -0,0 +1 @@ +{ "position": 3, "label": "DCA", "collapsed": false } diff --git a/docs/en/docs/account/dca/create_dca.md b/docs/en/docs/account/dca/create_dca.md new file mode 100644 index 00000000..c3421c40 --- /dev/null +++ b/docs/en/docs/account/dca/create_dca.md @@ -0,0 +1,241 @@ +--- +slug: create-dca +title: Create DCA Plan +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Create a new recurring investment plan for a security. + + +longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 +longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/account/dca
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| amount | string | YES | Recurring investment amount | +| frequency | string | YES | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | +| day_of_week | string | NO | Day of week for weekly/fortnightly plans: `mon`–`fri` | +| day_of_month | integer | NO | Day of month for monthly plans (1–28) | + +### Request Example + + + + + +longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 +longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.create_dca("AAPL.US", amount="500", frequency="Monthly", day_of_month=15) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.create_dca("AAPL.US", amount="500", frequency="Monthly", day_of_month=15) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.create_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getCreateDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.create_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.create_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": "1225781523156889601" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_dca_rsp](#create_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_dca_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | true | ID of the newly created plan | diff --git a/docs/en/docs/account/dca/dca_history.md b/docs/en/docs/account/dca/dca_history.md new file mode 100644 index 00000000..c2c9921b --- /dev/null +++ b/docs/en/docs/account/dca/dca_history.md @@ -0,0 +1,252 @@ +--- +slug: dca-history +title: DCA Trade History +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the execution history for a specific DCA plan including trade dates, amounts, and prices. + + +longbridge dca history 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/dca/:id/history
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | +| page | integer | NO | Page number (1-based, default: 1) | +| size | integer | NO | Records per page (default: 20) | + +### Request Example + + + + + +longbridge dca history 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.dca_history("1225781523156889600") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.dca_history("1225781523156889600") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.dca_history() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getDcaHistory().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.dca_history().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.dca_history([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DcaHistory(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "trade_date": "2026-04-08T14:00:00Z", + "symbol": "SPY.US", + "amount": "750", + "price": "548.20", + "quantity": "1.37", + "status": "Filled" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dca_history_rsp](#dca_history_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dca_history_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Trade history records | +| ∟ trade_date | string | true | Trade execution date (ISO 8601) | +| ∟ symbol | string | true | Security symbol | +| ∟ amount | string | true | Invested amount | +| ∟ price | string | false | Execution price | +| ∟ quantity | string | false | Quantity purchased | +| ∟ status | string | true | Trade status: `Filled`, `Failed` | diff --git a/docs/en/docs/account/dca/delete_dca.md b/docs/en/docs/account/dca/delete_dca.md new file mode 100644 index 00000000..168ddb0e --- /dev/null +++ b/docs/en/docs/account/dca/delete_dca.md @@ -0,0 +1,231 @@ +--- +slug: delete-dca +title: Delete DCA Plan +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Permanently stop and delete a recurring investment plan. This action cannot be undone. + + +longbridge dca stop 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/account/dca/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | + +### Request Example + + + + + +longbridge dca stop 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.delete_dca("1225781523156889600") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.delete_dca("1225781523156889600") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.delete_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getDeleteDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.delete_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.delete_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_dca_rsp](#delete_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_dca_rsp + + + +No response body fields. diff --git a/docs/en/docs/account/dca/list_dca.md b/docs/en/docs/account/dca/list_dca.md new file mode 100644 index 00000000..8228a431 --- /dev/null +++ b/docs/en/docs/account/dca/list_dca.md @@ -0,0 +1,255 @@ +--- +slug: list-dca +title: List DCA Plans +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get all recurring investment (DCA) plans for the current user. + + +longbridge dca +longbridge dca --status Active + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/dca
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| status | string | NO | Filter by plan status: `Active`, `Suspended`, `Finished` | +| symbol | string | NO | Filter by security symbol | + +### Request Example + + + + + +longbridge dca +longbridge dca --status Active + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.list_dca() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.list_dca() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.list_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getListDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.list_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.list_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "id": "1225781523156889600", + "symbol": "SPY.US", + "status": "Finished", + "amount": "750", + "frequency": "Fortnightly", + "day_of_week": "Wed", + "next_trade_date": "2026-04-08T14:00:00Z" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_dca_rsp](#list_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_dca_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | DCA plan list | +| ∟ id | string | true | Plan ID | +| ∟ symbol | string | true | Security symbol | +| ∟ status | string | true | Plan status: `Active`, `Suspended`, `Finished` | +| ∟ amount | string | true | Recurring investment amount | +| ∟ frequency | string | true | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | +| ∟ day_of_week | string | false | Day of week for weekly/fortnightly plans | +| ∟ next_trade_date | string | false | Next scheduled trade date (ISO 8601) | diff --git a/docs/en/docs/account/dca/update_dca.md b/docs/en/docs/account/dca/update_dca.md new file mode 100644 index 00000000..386c00fe --- /dev/null +++ b/docs/en/docs/account/dca/update_dca.md @@ -0,0 +1,234 @@ +--- +slug: update-dca +title: Update DCA Plan +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Pause or resume an existing recurring investment plan. + + +longbridge dca pause 1225781523156889600 +longbridge dca resume 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/dca/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | +| action | string | YES | Action to perform: `pause` or `resume` | + +### Request Example + + + + + +longbridge dca pause 1225781523156889600 +longbridge dca resume 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.update_dca("1225781523156889600", action="pause") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.update_dca("1225781523156889600", action="pause") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.update_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getUpdateDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.update_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.update_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_dca_rsp](#update_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_dca_rsp + + + +No response body fields. diff --git a/docs/en/docs/account/portfolio/_category_.json b/docs/en/docs/account/portfolio/_category_.json new file mode 100644 index 00000000..7cc2901d --- /dev/null +++ b/docs/en/docs/account/portfolio/_category_.json @@ -0,0 +1 @@ +{ "position": 1, "label": "Portfolio", "collapsed": false } diff --git a/docs/en/docs/account/portfolio/capital_flow.md b/docs/en/docs/account/portfolio/capital_flow.md new file mode 100644 index 00000000..95d7d5f5 --- /dev/null +++ b/docs/en/docs/account/portfolio/capital_flow.md @@ -0,0 +1,259 @@ +--- +slug: capital-flow +title: Capital Flow +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Query account cash flow history including deposits, withdrawals, dividends, and settlements. + + +longbridge cash-flow +longbridge cash-flow --format json + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/capital_flow
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_time | integer | NO | Start time as Unix timestamp (seconds) | +| end_time | integer | NO | End time as Unix timestamp (seconds) | +| business_type | integer | NO | Business type filter. Omit for all types. | +| symbol | string | NO | Filter by security symbol | +| page | integer | NO | Page number (1-based, default: 1) | +| size | integer | NO | Records per page (default: 20) | + +### Request Example + + + + + +longbridge cash-flow +longbridge cash-flow --format json + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.capital_flow() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.capital_flow() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.capital_flow() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getCapitalFlow().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.capital_flow().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.capital_flow([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CapitalFlow(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "transaction_flow_name": "Cash Dividend", + "direction": 1, + "business_type": 2, + "balance": "25.00", + "currency": "USD", + "business_time": "1774310400", + "symbol": "AAPL.US" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [capital_flow_rsp](#capital_flow_rsp) | +| 400 | Bad request | None | + +## Schemas + +### capital_flow_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Cash flow records | +| ∟ transaction_flow_name | string | true | Flow type description | +| ∟ direction | int32 | true | `1` = inflow, `-1` = outflow | +| ∟ business_type | int32 | true | Business type code | +| ∟ balance | string | true | Amount | +| ∟ currency | string | true | Currency | +| ∟ business_time | string | true | Transaction time as Unix timestamp | +| ∟ symbol | string | false | Associated security symbol | diff --git a/docs/en/docs/account/portfolio/exchange_rates.md b/docs/en/docs/account/portfolio/exchange_rates.md new file mode 100644 index 00000000..1f194c73 --- /dev/null +++ b/docs/en/docs/account/portfolio/exchange_rates.md @@ -0,0 +1,246 @@ +--- +slug: exchange-rates +title: Exchange Rates +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get current foreign exchange rates for all currency pairs used in your account. + + +longbridge exchange-rate + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/exchange_rates
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| base | string | NO | Base currency, e.g. `USD`. Omit for all pairs. | + +### Request Example + + + + + +longbridge exchange-rate + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.exchange_rates() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.exchange_rates() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.exchange_rates() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getExchangeRates().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.exchange_rates().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.exchange_rates([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ExchangeRates(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "pair": "HKD/USD", + "bid_rate": "0.1284", + "offer_rate": "0.1285", + "average_rate": "0.12845" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [exchange_rates_rsp](#exchange_rates_rsp) | +| 400 | Bad request | None | + +## Schemas + +### exchange_rates_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Exchange rate list | +| ∟ pair | string | true | Currency pair, e.g. `HKD/USD` | +| ∟ bid_rate | string | true | Bid rate | +| ∟ offer_rate | string | true | Offer rate | +| ∟ average_rate | string | true | Average rate | diff --git a/docs/en/docs/account/portfolio/profit_analysis_by_market.md b/docs/en/docs/account/portfolio/profit_analysis_by_market.md new file mode 100644 index 00000000..8932c71b --- /dev/null +++ b/docs/en/docs/account/portfolio/profit_analysis_by_market.md @@ -0,0 +1,258 @@ +--- +slug: profit-analysis-by-market +title: Profit Analysis by Market +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get P&L breakdown grouped by market (US, HK, CN, SG). + + +longbridge profit-analysis --format json +longbridge profit-analysis --start 2026-01-01 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis/by_market
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis --format json +longbridge profit-analysis --start 2026-01-01 + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_by_market() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_by_market() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_by_market() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisByMarket().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_by_market().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_by_market([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisByMarket(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "market": "US", + "pnl": "42000.00", + "pnl_pct": "0.5412", + "market_value": "120000.00", + "currency": "USD" + }, + { + "market": "HK", + "pnl": "5203.00", + "pnl_pct": "0.1832", + "market_value": "28400.00", + "currency": "HKD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_by_market_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | P&L by market list | +| ∟ market | string | true | Market code | +| ∟ pnl | string | true | P&L for this market | +| ∟ pnl_pct | string | true | P&L percentage | +| ∟ market_value | string | false | Market value | +| ∟ currency | string | true | Settlement currency | diff --git a/docs/en/docs/account/portfolio/profit_analysis_detail.md b/docs/en/docs/account/portfolio/profit_analysis_detail.md new file mode 100644 index 00000000..d0e3b49f --- /dev/null +++ b/docs/en/docs/account/portfolio/profit_analysis_detail.md @@ -0,0 +1,251 @@ +--- +slug: profit-analysis-detail +title: Profit Analysis Detail +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get detailed P&L for a specific security including transaction flow and cost breakdown. + + +longbridge profit-analysis detail TSLA.US +longbridge profit-analysis detail AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis/detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.US` | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis detail TSLA.US +longbridge profit-analysis detail AAPL.US + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_detail("TSLA.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_detail("TSLA.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_detail() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisDetail().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_detail().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_detail([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisDetail(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "name": "Tesla Inc.", + "pnl": "12450.00", + "pnl_pct": "0.2891", + "cost": "43085.00", + "market_value": "55535.00", + "currency": "USD" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_detail_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| name | string | true | Security name | +| pnl | string | true | Total P&L | +| pnl_pct | string | true | P&L percentage | +| cost | string | true | Total cost basis | +| market_value | string | false | Current market value | +| currency | string | true | Currency | diff --git a/docs/en/docs/account/portfolio/profit_analysis_summary.md b/docs/en/docs/account/portfolio/profit_analysis_summary.md new file mode 100644 index 00000000..862562b2 --- /dev/null +++ b/docs/en/docs/account/portfolio/profit_analysis_summary.md @@ -0,0 +1,254 @@ +--- +slug: profit-analysis-summary +title: Profit Analysis Summary +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get a P&L summary for the account including total asset, total P&L, and yield metrics. + + +longbridge profit-analysis +longbridge profit-analysis --start 2026-01-01 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis +longbridge profit-analysis --start 2026-01-01 + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_summary() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_summary() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_summary() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisSummary().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_summary().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_summary([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisSummary(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "currency": "USD", + "total_asset": "125413.01", + "invest_amount": "76997.11", + "total_pnl": "48415.89", + "simple_yield": "0.6288", + "twr": "0.5841", + "stocks_traded": 12, + "start_date": "2023-12-04", + "end_date": "2026-04-17" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_summary_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| currency | string | true | Settlement currency | +| total_asset | string | true | Total asset value | +| invest_amount | string | true | Total invested amount | +| total_pnl | string | true | Total P&L | +| simple_yield | string | true | Simple yield ratio | +| twr | string | true | Time-weighted return | +| stocks_traded | int32 | true | Number of stocks traded | +| start_date | string | true | Analysis start date | +| end_date | string | true | Analysis end date | diff --git a/docs/en/docs/account/sharelist/_category_.json b/docs/en/docs/account/sharelist/_category_.json new file mode 100644 index 00000000..896f0ec1 --- /dev/null +++ b/docs/en/docs/account/sharelist/_category_.json @@ -0,0 +1 @@ +{ "position": 4, "label": "Sharelist", "collapsed": false } diff --git a/docs/en/docs/account/sharelist/create_sharelist.md b/docs/en/docs/account/sharelist/create_sharelist.md new file mode 100644 index 00000000..96546239 --- /dev/null +++ b/docs/en/docs/account/sharelist/create_sharelist.md @@ -0,0 +1,237 @@ +--- +slug: create-sharelist +title: Create Sharelist +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Create a new community stock list with an optional initial set of securities. + + +longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/community/sharelists
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | YES | Sharelist name | +| description | string | NO | Description | +| securities | string[] | NO | Initial list of security symbols, e.g. `["AAPL.US", "NVDA.US"]` | + +### Request Example + + + + + +longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.create_sharelist(name="AI Picks", description="Top AI infrastructure stocks") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.create_sharelist(name="AI Picks", description="Top AI infrastructure stocks") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.create_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getCreateSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.create_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.create_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 15922 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_sharelist_rsp](#create_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_sharelist_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | ID of the newly created sharelist | diff --git a/docs/en/docs/account/sharelist/delete_sharelist.md b/docs/en/docs/account/sharelist/delete_sharelist.md new file mode 100644 index 00000000..ee3f64d7 --- /dev/null +++ b/docs/en/docs/account/sharelist/delete_sharelist.md @@ -0,0 +1,231 @@ +--- +slug: delete-sharelist +title: Delete Sharelist +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Permanently delete a sharelist you own. This action cannot be undone. + + +longbridge sharelist delete 15921 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/community/sharelists/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Sharelist ID (path parameter) | + +### Request Example + + + + + +longbridge sharelist delete 15921 + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.delete_sharelist(15921) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.delete_sharelist(15921) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.delete_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getDeleteSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.delete_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.delete_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_sharelist_rsp](#delete_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_sharelist_rsp + + + +No response body fields. diff --git a/docs/en/docs/account/sharelist/list_sharelist.md b/docs/en/docs/account/sharelist/list_sharelist.md new file mode 100644 index 00000000..6533f07a --- /dev/null +++ b/docs/en/docs/account/sharelist/list_sharelist.md @@ -0,0 +1,254 @@ +--- +slug: list-sharelist +title: List Sharelists +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get all community stock lists (sharelists) created by or subscribed to by the current user. + + +longbridge sharelist +longbridge sharelist --format json + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/community/sharelists
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| type | string | NO | Filter: `mine` or `subscribed`. Omit for both. | + +### Request Example + + + + + +longbridge sharelist +longbridge sharelist --format json + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.list_sharelist() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.list_sharelist() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.list_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getListSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.list_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.list_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "mine": [ + { + "id": 15921, + "name": "AI Picks", + "type": "Regular", + "day_change": "-0.40", + "ytd_change": "6.64", + "subscribers": 500 + } + ], + "subscribed": [] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_sharelist_rsp](#list_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_sharelist_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| mine | object[] | true | Sharelists created by the user | +| subscribed | object[] | true | Sharelists subscribed by the user | +| ∟ id | int64 | true | Sharelist ID | +| ∟ name | string | true | Sharelist name | +| ∟ type | string | true | Type: `Regular`, `Official` | +| ∟ day_change | string | false | Day change percentage | +| ∟ ytd_change | string | false | Year-to-date change | +| ∟ subscribers | int32 | false | Subscriber count | diff --git a/docs/en/docs/account/sharelist/update_sharelist.md b/docs/en/docs/account/sharelist/update_sharelist.md new file mode 100644 index 00000000..70899d74 --- /dev/null +++ b/docs/en/docs/account/sharelist/update_sharelist.md @@ -0,0 +1,236 @@ +--- +slug: update-sharelist +title: Update Sharelist +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Add, remove, or reorder securities in a sharelist, or rename it. + + +longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US +longbridge sharelist remove 15921 AAPL.US + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/community/sharelists/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Sharelist ID (path parameter) | +| name | string | NO | New name. Omit to keep existing. | +| mode | string | NO | Operation mode for securities: `add`, `remove`, or `replace` | +| securities | string[] | NO | Security symbols affected by the operation | + +### Request Example + + + + + +longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US +longbridge sharelist remove 15921 AAPL.US + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.update_sharelist(15921, mode="add", securities=["TSLA.US", "NVDA.US"]) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.update_sharelist(15921, mode="add", securities=["TSLA.US", "NVDA.US"]) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.update_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getUpdateSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.update_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.update_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_sharelist_rsp](#update_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_sharelist_rsp + + + +No response body fields. diff --git a/docs/en/docs/fundamental/_category_.json b/docs/en/docs/fundamental/_category_.json new file mode 100644 index 00000000..8aa51261 --- /dev/null +++ b/docs/en/docs/fundamental/_category_.json @@ -0,0 +1 @@ +{ "position": 5, "label": "Fundamental", "collapsed": false } diff --git a/docs/en/docs/fundamental/calendar/_category_.json b/docs/en/docs/fundamental/calendar/_category_.json new file mode 100644 index 00000000..749c348f --- /dev/null +++ b/docs/en/docs/fundamental/calendar/_category_.json @@ -0,0 +1 @@ +{ "position": 3, "label": "Calendar", "collapsed": false } diff --git a/docs/en/docs/fundamental/calendar/dividend_calendar.md b/docs/en/docs/fundamental/calendar/dividend_calendar.md new file mode 100644 index 00000000..d674e146 --- /dev/null +++ b/docs/en/docs/fundamental/calendar/dividend_calendar.md @@ -0,0 +1,254 @@ +--- +slug: dividend-calendar +title: Dividend Calendar +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get upcoming and past dividend events including ex-date, pay date, and dividend amount. + + +longbridge finance-calendar dividend +longbridge finance-calendar dividend --filter positions + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/dividends
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar dividend +longbridge finance-calendar dividend --filter positions + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.dividend_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.dividend_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.dividend_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getDividendCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.dividend_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.dividend_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DividendCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "name": "Apple Inc.", + "ex_date": "2026-05-09", + "pay_date": "2026-05-15", + "amount": "0.25", + "currency": "USD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dividend_calendar_rsp](#dividend_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dividend_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Dividend event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ ex_date | string | true | Ex-dividend date | +| ∟ pay_date | string | false | Payment date | +| ∟ amount | string | true | Dividend amount per share | +| ∟ currency | string | true | Currency | diff --git a/docs/en/docs/fundamental/calendar/earnings_calendar.md b/docs/en/docs/fundamental/calendar/earnings_calendar.md new file mode 100644 index 00000000..cf414f85 --- /dev/null +++ b/docs/en/docs/fundamental/calendar/earnings_calendar.md @@ -0,0 +1,254 @@ +--- +slug: earnings-calendar +title: Earnings Calendar +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Browse upcoming earnings reports and recent results, with EPS and revenue estimates. + + +longbridge finance-calendar report +longbridge finance-calendar report --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/earnings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar report +longbridge finance-calendar report --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.earnings_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.earnings_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.earnings_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getEarningsCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.earnings_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.earnings_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.EarningsCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "name": "Apple Inc.", + "report_date": "2026-04-30", + "eps_estimate": "1.62", + "eps_actual": null, + "revenue_estimate": "94500000000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [earnings_calendar_rsp](#earnings_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### earnings_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Earnings event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ report_date | string | true | Expected report date | +| ∟ eps_estimate | string | false | EPS estimate | +| ∟ eps_actual | string | false | Actual EPS (null if not yet reported) | +| ∟ revenue_estimate | string | false | Revenue estimate | diff --git a/docs/en/docs/fundamental/calendar/ipo_calendar.md b/docs/en/docs/fundamental/calendar/ipo_calendar.md new file mode 100644 index 00000000..9d7a603b --- /dev/null +++ b/docs/en/docs/fundamental/calendar/ipo_calendar.md @@ -0,0 +1,254 @@ +--- +slug: ipo-calendar +title: IPO Calendar +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get upcoming and recent IPO listings with expected offer price and listing date. + + +longbridge finance-calendar ipo +longbridge finance-calendar ipo --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/ipos
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar ipo +longbridge finance-calendar ipo --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.ipo_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.ipo_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.ipo_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getIpoCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.ipo_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.ipo_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.IpoCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NEWCO.US", + "name": "New Company Inc.", + "listing_date": "2026-05-15", + "offer_price": "18.00", + "currency": "USD", + "market": "US" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ipo_calendar_rsp](#ipo_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ipo_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | IPO event list | +| ∟ symbol | string | false | Security symbol (assigned after listing) | +| ∟ name | string | true | Company name | +| ∟ listing_date | string | true | Expected listing date | +| ∟ offer_price | string | false | IPO offer price | +| ∟ currency | string | false | Currency | +| ∟ market | string | true | Market code | diff --git a/docs/en/docs/fundamental/calendar/macro_calendar.md b/docs/en/docs/fundamental/calendar/macro_calendar.md new file mode 100644 index 00000000..2050d7ae --- /dev/null +++ b/docs/en/docs/fundamental/calendar/macro_calendar.md @@ -0,0 +1,256 @@ +--- +slug: macro-calendar +title: Macro Calendar +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get upcoming macroeconomic data release events such as CPI, GDP, and Fed meetings. + + +longbridge finance-calendar macrodata +longbridge finance-calendar macrodata --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/macro
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| country | string | NO | Country code: `US`, `CN`, `EU`, `JP`. Omit for global. | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar macrodata +longbridge finance-calendar macrodata --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.macro_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.macro_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.macro_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getMacroCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.macro_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.macro_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.MacroCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "event": "US CPI (YoY)", + "country": "US", + "release_date": "2026-05-13", + "actual": null, + "forecast": "2.4", + "previous": "2.4", + "importance": "High" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [macro_calendar_rsp](#macro_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### macro_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Macro event list | +| ∟ event | string | true | Event name | +| ∟ country | string | true | Country code | +| ∟ release_date | string | true | Release date | +| ∟ actual | string | false | Actual value (null if not yet released) | +| ∟ forecast | string | false | Consensus forecast | +| ∟ previous | string | false | Previous period value | +| ∟ importance | string | false | Importance level: `High`, `Medium`, `Low` | diff --git a/docs/en/docs/fundamental/calendar/split_calendar.md b/docs/en/docs/fundamental/calendar/split_calendar.md new file mode 100644 index 00000000..d8964db5 --- /dev/null +++ b/docs/en/docs/fundamental/calendar/split_calendar.md @@ -0,0 +1,252 @@ +--- +slug: split-calendar +title: Split Calendar +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get upcoming and historical stock split and reverse split events. + + +longbridge finance-calendar split +longbridge finance-calendar split --market HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/splits
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar split +longbridge finance-calendar split --market HK + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.split_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.split_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.split_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getSplitCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.split_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.split_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.SplitCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NVDA.US", + "name": "NVIDIA Corp", + "date": "2024-06-10", + "ratio": "10:1", + "type": "Split" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [split_calendar_rsp](#split_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### split_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Split event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ date | string | true | Effective date | +| ∟ ratio | string | true | Split ratio, e.g. `10:1` | +| ∟ type | string | true | `Split` or `ReverseSplit` | diff --git a/docs/en/docs/fundamental/fundamental/_category_.json b/docs/en/docs/fundamental/fundamental/_category_.json new file mode 100644 index 00000000..1e080d05 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/_category_.json @@ -0,0 +1 @@ +{ "position": 1, "label": "Fundamentals", "collapsed": false } diff --git a/docs/en/docs/fundamental/fundamental/company_profile.md b/docs/en/docs/fundamental/fundamental/company_profile.md new file mode 100644 index 00000000..5b874b90 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/company_profile.md @@ -0,0 +1,249 @@ +--- +slug: company-profile +title: Company Profile +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get a company's profile information including founding year, employee count, headquarters, and description. + + +longbridge company TSLA.US +longbridge company AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/company_profile
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge company TSLA.US +longbridge company AAPL.US + + + + + +```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.company_profile("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.company_profile("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.company_profile('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.getCompanyProfile("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.company_profile("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.company_profile("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.CompanyProfile(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "name": "Apple Inc.", + "symbol": "AAPL.US", + "founded": "1976", + "ceo": "Timothy D. Cook", + "employees": 166000, + "website": "www.apple.com", + "description": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide." + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [company_profile_rsp](#company_profile_rsp) | +| 400 | Bad request | None | + +## Schemas + +### company_profile_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | true | Company name | +| symbol | string | true | Security symbol | +| founded | string | false | Founding year | +| ceo | string | false | Current CEO | +| employees | int32 | false | Number of employees | +| website | string | false | Company website | +| description | string | false | Business description | diff --git a/docs/en/docs/fundamental/fundamental/corporate_actions.md b/docs/en/docs/fundamental/fundamental/corporate_actions.md new file mode 100644 index 00000000..ece51be0 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/corporate_actions.md @@ -0,0 +1,250 @@ +--- +slug: corporate-actions +title: Corporate Actions +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get corporate action history (splits, mergers, spin-offs, rights issues) for a security. + + +longbridge corp-action TSLA.US +longbridge corp-action AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/corporate_actions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge corp-action TSLA.US +longbridge corp-action AAPL.US + + + + + +```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.corporate_actions("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.corporate_actions("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.corporate_actions('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.getCorporateActions("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.corporate_actions("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.corporate_actions("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.CorporateActions(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "type": "Split", + "date": "2020-08-31", + "ratio": "4:1", + "description": "4-for-1 stock split" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [corporate_actions_rsp](#corporate_actions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### corporate_actions_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Corporate action list | +| ∟ type | string | true | Action type: `Split`, `Merger`, `Spinoff`, `Rights` | +| ∟ date | string | true | Effective date | +| ∟ ratio | string | false | Split/merge ratio | +| ∟ description | string | false | Action description | diff --git a/docs/en/docs/fundamental/fundamental/dividends.md b/docs/en/docs/fundamental/fundamental/dividends.md new file mode 100644 index 00000000..2d0e1635 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/dividends.md @@ -0,0 +1,252 @@ +--- +slug: dividends +title: Dividends +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get dividend history and upcoming dividend announcements for a security. + + +longbridge dividend TSLA.US +longbridge dividend AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/dividends
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge dividend TSLA.US +longbridge dividend AAPL.US + + + + + +```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.dividends("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.dividends("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.dividends('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.getDividends("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.dividends("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.dividends("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.Dividends(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "ex_date": "2026-02-07", + "pay_date": "2026-02-13", + "amount": "0.25", + "currency": "USD", + "type": "Cash" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dividends_rsp](#dividends_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dividends_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Dividend records | +| ∟ ex_date | string | true | Ex-dividend date | +| ∟ pay_date | string | false | Payment date | +| ∟ amount | string | true | Dividend amount per share | +| ∟ currency | string | true | Currency | +| ∟ type | string | true | Dividend type, e.g. `Cash`, `Stock` | diff --git a/docs/en/docs/fundamental/fundamental/executives.md b/docs/en/docs/fundamental/fundamental/executives.md new file mode 100644 index 00000000..25dedde1 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/executives.md @@ -0,0 +1,248 @@ +--- +slug: executives +title: Executives +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the list of key executives (CEO, CFO, etc.) for a company. + + +longbridge executive TSLA.US +longbridge executive AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/executives
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge executive TSLA.US +longbridge executive AAPL.US + + + + + +```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.executives("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.executives("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.executives('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.getExecutives("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.executives("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.executives("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.Executives(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "name": "Timothy D. Cook", + "title": "Chief Executive Officer", + "age": 63, + "since": "2011" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [executives_rsp](#executives_rsp) | +| 400 | Bad request | None | + +## Schemas + +### executives_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Executive list | +| ∟ name | string | true | Executive name | +| ∟ title | string | true | Job title | +| ∟ age | int32 | false | Age | +| ∟ since | string | false | Year appointed | diff --git a/docs/en/docs/fundamental/fundamental/financial_report.md b/docs/en/docs/fundamental/fundamental/financial_report.md new file mode 100644 index 00000000..ce9b1d4a --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/financial_report.md @@ -0,0 +1,254 @@ +--- +slug: financial-report +title: Financial Report +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Fetch income statement, balance sheet, and cash flow statement for any public company. + + +longbridge financial-report TSLA.US --kind IS +longbridge financial-report AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/financial_reports
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| kind | string | NO | Statement type: `IS` (income), `BS` (balance sheet), `CF` (cash flow), `ALL` (default) | +| report | string | NO | Reporting period: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | + +### Request Example + + + + + +longbridge financial-report TSLA.US --kind IS +longbridge financial-report AAPL.US + + + + + +```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("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.financial_report("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.financial_report('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.getFinancialReport("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.financial_report("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.financial_report("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.FinancialReport(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "type": "IS", + "period": "Q4 2025", + "eps": "0.24", + "revenue": "24900000000", + "net_income": "840000000", + "gross_margin": "0.2012" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [financial_report_rsp](#financial_report_rsp) | +| 400 | Bad request | None | + +## Schemas + +### financial_report_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of financial statement records | +| ∟ type | string | true | Statement type: `IS`, `BS`, `CF` | +| ∟ period | string | true | Reporting period label | +| ∟ eps | string | false | Earnings per share | +| ∟ revenue | string | false | Total revenue | +| ∟ net_income | string | false | Net income | +| ∟ gross_margin | string | false | Gross margin ratio | diff --git a/docs/en/docs/fundamental/fundamental/fund_holdings.md b/docs/en/docs/fundamental/fundamental/fund_holdings.md new file mode 100644 index 00000000..5bf55ac0 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/fund_holdings.md @@ -0,0 +1,248 @@ +--- +slug: fund-holdings +title: Fund Holdings +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the list of funds that hold a given security, with the number of shares and ownership percentage. + + +longbridge fund-holder TSLA.US +longbridge fund-holder AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/fund_holdings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge fund-holder TSLA.US +longbridge fund-holder AAPL.US + + + + + +```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.fund_holdings("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.fund_holdings("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.fund_holdings('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.getFundHoldings("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.fund_holdings("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.fund_holdings("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.FundHoldings(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "fund_name": "Vanguard Total Stock Market ETF", + "shares": "289000000", + "percentage": "1.88", + "date": "2026-03-31" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [fund_holdings_rsp](#fund_holdings_rsp) | +| 400 | Bad request | None | + +## Schemas + +### fund_holdings_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Fund holder list | +| ∟ fund_name | string | true | Fund name | +| ∟ shares | string | true | Number of shares held | +| ∟ percentage | string | true | Ownership percentage | +| ∟ date | string | false | Report date | diff --git a/docs/en/docs/fundamental/fundamental/ratings.md b/docs/en/docs/fundamental/fundamental/ratings.md new file mode 100644 index 00000000..fcb7ecba --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/ratings.md @@ -0,0 +1,250 @@ +--- +slug: ratings +title: Analyst Ratings +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get analyst institution ratings and consensus data for a security. + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/ratings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + + +```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.ratings("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.ratings("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.ratings('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.getRatings("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.ratings("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.ratings("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.Ratings(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "broker_name": "Goldman Sachs", + "rating": "Buy", + "target_price": "230.00", + "currency": "USD", + "date": "2026-01-10" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ratings_rsp](#ratings_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ratings_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of analyst ratings | +| ∟ broker_name | string | true | Institution name | +| ∟ rating | string | true | Rating: `Buy`, `Hold`, `Sell` | +| ∟ target_price | string | false | Target price | +| ∟ currency | string | false | Currency | +| ∟ date | string | true | Rating date in `YYYY-MM-DD` format | diff --git a/docs/en/docs/fundamental/fundamental/shareholders.md b/docs/en/docs/fundamental/fundamental/shareholders.md new file mode 100644 index 00000000..320f0cf3 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/shareholders.md @@ -0,0 +1,248 @@ +--- +slug: shareholders +title: Shareholders +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the top institutional and individual shareholders of a company. + + +longbridge shareholder TSLA.US +longbridge shareholder AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/shareholders
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge shareholder TSLA.US +longbridge shareholder AAPL.US + + + + + +```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.shareholders("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.shareholders("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.shareholders('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.getShareholders("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.shareholders("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.shareholders("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.Shareholders(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "name": "The Vanguard Group", + "shares": "1236787000", + "percentage": "8.04", + "type": "Institution" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [shareholders_rsp](#shareholders_rsp) | +| 400 | Bad request | None | + +## Schemas + +### shareholders_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Shareholder list | +| ∟ name | string | true | Shareholder name | +| ∟ shares | string | true | Number of shares held | +| ∟ percentage | string | true | Ownership percentage | +| ∟ type | string | false | `Institution` or `Individual` | diff --git a/docs/en/docs/fundamental/fundamental/valuations.md b/docs/en/docs/fundamental/fundamental/valuations.md new file mode 100644 index 00000000..cedc078e --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/valuations.md @@ -0,0 +1,246 @@ +--- +slug: valuations +title: Valuations +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get current valuation metrics (P/E, P/B, P/S, dividend yield) with 5-year historical context. + + +longbridge valuation TSLA.US --indicator pe +longbridge valuation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/valuations
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| indicator | string | NO | Indicator filter: `pe`, `pb`, `ps`, `dvd_yld` | + +### Request Example + + + + + +longbridge valuation TSLA.US --indicator pe +longbridge valuation AAPL.US + + + + + +```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.valuations("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.valuations("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.valuations('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.getValuations("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.valuations("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.valuations("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.Valuations(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "metrics": { + "pe": { "current": "29.5", "high": "35.2", "low": "18.0", "median": "26.0" }, + "pb": { "current": "45.1", "high": "50.0", "low": "30.0", "median": "42.0" } + } + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [valuations_rsp](#valuations_rsp) | +| 400 | Bad request | None | + +## Schemas + +### valuations_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| metrics | object | true | Valuation metrics map | +| ∟ pe | object | false | P/E ratio data | +| ∟∟ current | string | true | Current value | +| ∟∟ high | string | true | 5-year high | +| ∟∟ low | string | true | 5-year low | +| ∟∟ median | string | true | 5-year median | diff --git a/docs/en/docs/fundamental/market/_category_.json b/docs/en/docs/fundamental/market/_category_.json new file mode 100644 index 00000000..d98f6649 --- /dev/null +++ b/docs/en/docs/fundamental/market/_category_.json @@ -0,0 +1 @@ +{ "position": 2, "label": "Market", "collapsed": false } diff --git a/docs/en/docs/fundamental/market/ah_premium.md b/docs/en/docs/fundamental/market/ah_premium.md new file mode 100644 index 00000000..cdfbd58e --- /dev/null +++ b/docs/en/docs/fundamental/market/ah_premium.md @@ -0,0 +1,250 @@ +--- +slug: ah-premium +title: A/H Premium +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the A/H premium ratio for dual-listed stocks comparing A-share and H-share prices. + + +longbridge ah-premium 939.HK +longbridge ah-premium 0939.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/ah_premium
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | H-share symbol of a dual-listed stock, e.g. `939.HK` | + +### Request Example + + + + + +longbridge ah-premium 939.HK +longbridge ah-premium 0939.HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.ah_premium("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.ah_premium("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.ah_premium('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getAhPremium("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.ah_premium("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.ah_premium("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.AhPremium(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "date": "2026-04-08", + "a_price": "9.28", + "h_price": "6.70", + "premium": "1.0847", + "fx_rate": "0.8947" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ah_premium_rsp](#ah_premium_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ah_premium_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | A/H premium records | +| ∟ date | string | true | Date in `YYYY-MM-DD` format | +| ∟ a_price | string | true | A-share price in CNY | +| ∟ h_price | string | true | H-share price in HKD | +| ∟ premium | string | true | A/H premium ratio | +| ∟ fx_rate | string | true | CNH/HKD exchange rate | diff --git a/docs/en/docs/fundamental/market/broker_positions.md b/docs/en/docs/fundamental/market/broker_positions.md new file mode 100644 index 00000000..b91042ba --- /dev/null +++ b/docs/en/docs/fundamental/market/broker_positions.md @@ -0,0 +1,252 @@ +--- +slug: broker-positions +title: Broker Positions +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +View broker holding positions for HK-listed stocks, including top buyers/sellers and full detail. + + +longbridge broker-holding 700.HK +longbridge broker-holding 9988.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_positions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | HK security symbol, e.g. `700.HK` | + +### Request Example + + + + + +longbridge broker-holding 700.HK +longbridge broker-holding 9988.HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_positions("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_positions("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.broker_positions('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerPositions("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_positions("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.broker_positions("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerPositions(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "updated_at": "1774310400", + "participants": [ + { + "broker_id": 1234, + "broker_name": "HSBC Securities", + "buy_qty": "100000", + "sell_qty": "80000", + "net_qty": "20000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [broker_positions_rsp](#broker_positions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### broker_positions_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| updated_at | string | true | Last updated Unix timestamp | +| participants | object[] | true | Broker position list | +| ∟ broker_id | int32 | true | Broker ID | +| ∟ broker_name | string | true | Broker name | +| ∟ buy_qty | string | true | Buy quantity | +| ∟ sell_qty | string | true | Sell quantity | +| ∟ net_qty | string | true | Net quantity (buy - sell) | diff --git a/docs/en/docs/fundamental/market/index_components.md b/docs/en/docs/fundamental/market/index_components.md new file mode 100644 index 00000000..267f425d --- /dev/null +++ b/docs/en/docs/fundamental/market/index_components.md @@ -0,0 +1,256 @@ +--- +slug: index-components +title: Index Components +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the constituent stocks of an index or ETF with sorting options and rise/fall statistics. + + +longbridge constituent HSI.HK +longbridge constituent SPY.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/index_components
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Index or ETF symbol, e.g. `HSI.HK`, `SPY.US` | + +### Request Example + + + + + +longbridge constituent HSI.HK +longbridge constituent SPY.US + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.index_components("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.index_components("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.index_components('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getIndexComponents("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.index_components("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.index_components("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.IndexComponents(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "total": 90, + "rise": 45, + "fall": 42, + "flat": 3, + "components": [ + { + "symbol": "HSBC.HK", + "name": "HSBC Holdings", + "price": "68.40", + "change_pct": "0.88" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [index_components_rsp](#index_components_rsp) | +| 400 | Bad request | None | + +## Schemas + +### index_components_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| total | int32 | true | Total number of components | +| rise | int32 | true | Number of rising components | +| fall | int32 | true | Number of falling components | +| flat | int32 | true | Number of flat components | +| components | object[] | true | Component list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Security name | +| ∟ price | string | false | Current price | +| ∟ change_pct | string | false | Percentage change | diff --git a/docs/en/docs/fundamental/market/market_status.md b/docs/en/docs/fundamental/market/market_status.md new file mode 100644 index 00000000..f0b74ff4 --- /dev/null +++ b/docs/en/docs/fundamental/market/market_status.md @@ -0,0 +1,249 @@ +--- +slug: market-status +title: Market Status +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the current open/close status for each exchange. + + +longbridge market-status + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/status
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market code: `US`, `HK`, `SH`, `SZ`, `SG`. Omit for all markets. | + +### Request Example + + + + + +longbridge market-status + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.market_status("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.market_status("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.market_status('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getMarketStatus("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.market_status("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.market_status("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.MarketStatus(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "market": "US", + "status": "normal_trading", + "trade_session": "Regular" + }, + { + "market": "HK", + "status": "closed", + "trade_session": "Closed" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [market_status_rsp](#market_status_rsp) | +| 400 | Bad request | None | + +## Schemas + +### market_status_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Market status list | +| ∟ market | string | true | Market code | +| ∟ status | string | true | Status: `normal_trading`, `closed`, `pre_trading`, `after_trading` | +| ∟ trade_session | string | false | Current trading session | diff --git a/docs/en/docs/fundamental/market/trading_stats.md b/docs/en/docs/fundamental/market/trading_stats.md new file mode 100644 index 00000000..20b84719 --- /dev/null +++ b/docs/en/docs/fundamental/market/trading_stats.md @@ -0,0 +1,252 @@ +--- +slug: trading-stats +title: Trading Stats +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get trade statistics showing price distribution by volume for a security. + + +longbridge trade-stats 700.HK +longbridge trade-stats TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/trading_stats
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `700.HK` | + +### Request Example + + + + + +longbridge trade-stats 700.HK +longbridge trade-stats TSLA.US + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.trading_stats("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.trading_stats("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.trading_stats('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getTradingStats("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.trading_stats("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.trading_stats("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.TradingStats(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "prev_close": "504.500", + "avg_price": "491.63", + "trades": 32782, + "volume": "15200000", + "turnover": "7382000000", + "distribution": [ + { "price": "490.00", "volume": "1200000", "pct": "7.89" } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [trading_stats_rsp](#trading_stats_rsp) | +| 400 | Bad request | None | + +## Schemas + +### trading_stats_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| prev_close | string | true | Previous close price | +| avg_price | string | true | Average trading price | +| trades | int32 | true | Number of trades | +| volume | string | true | Total volume | +| turnover | string | true | Total turnover | +| distribution | object[] | true | Price-volume distribution | +| ∟ price | string | true | Price level | +| ∟ volume | string | true | Volume at this price | +| ∟ pct | string | true | Percentage of total volume | diff --git a/docs/en/docs/fundamental/market/unusual_items.md b/docs/en/docs/fundamental/market/unusual_items.md new file mode 100644 index 00000000..ad3ea8a2 --- /dev/null +++ b/docs/en/docs/fundamental/market/unusual_items.md @@ -0,0 +1,250 @@ +--- +slug: unusual-items +title: Unusual Items +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Detect unusual market movements — price spikes, volume surges, and other abnormal trading activity. + + +longbridge anomaly --market US +longbridge anomaly --market HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/unusual_items
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | YES | Market code: `US`, `HK`, `SH`, `SZ`, `SG` | + +### Request Example + + + + + +longbridge anomaly --market US +longbridge anomaly --market HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.unusual_items("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.unusual_items("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.unusual_items('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getUnusualItems("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.unusual_items("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.unusual_items("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UnusualItems(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NVDA.US", + "name": "NVIDIA Corp", + "alert": "Volume surge", + "emotion": "Bullish", + "time": "1774310400" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [unusual_items_rsp](#unusual_items_rsp) | +| 400 | Bad request | None | + +## Schemas + +### unusual_items_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Unusual item list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Security name | +| ∟ alert | string | true | Alert description | +| ∟ emotion | string | false | Market sentiment: `Bullish`, `Bearish` | +| ∟ time | string | true | Alert time as Unix timestamp | diff --git a/docs/en/docs/quote/individual/update_pinned.md b/docs/en/docs/quote/individual/update_pinned.md new file mode 100644 index 00000000..d3d70549 --- /dev/null +++ b/docs/en/docs/quote/individual/update_pinned.md @@ -0,0 +1,210 @@ +--- +slug: update-pinned +title: Update Pinned Security +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Pin or unpin a security within a watchlist group to control its display order. + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/watchlist/groups
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| --------- | ------ | -------- | -------------------------------------------------------- | +| id | string | YES | Watchlist group ID | +| symbol | string | YES | Security symbol to pin or unpin, e.g. `AAPL.US` | +| is_pinned | bool | YES | Set to `true` to pin the security, `false` to unpin it | + +### Request Example + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + await ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + await ctx.updatePinned('2630', 'AAPL.US', true) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + ctx.updatePinned("2630", "AAPL.US", true).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + ctx.update_pinned("2630", "AAPL.US", true).await?; + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.update_pinned("2630", "AAPL.US", true, [](auto) {}); + }); + 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + if err := qctx.UpdatePinned(context.Background(), "2630", "AAPL.US", true); err != nil { + log.Fatal(err) + } + fmt.Println("OK") +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | + +## Schemas + +No response schemas. The endpoint returns an empty `data` object on success. diff --git a/docs/en/docs/quote/pull/option_volume.md b/docs/en/docs/quote/pull/option_volume.md new file mode 100644 index 00000000..31cc1c8b --- /dev/null +++ b/docs/en/docs/quote/pull/option_volume.md @@ -0,0 +1,249 @@ +--- +slug: option-volume +title: Option Volume +sidebar_position: 26 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get real-time call/put volume snapshot for today, including total volume, open interest, and put/call ratios. + + +longbridge option volume AAPL.US +longbridge option volume TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/option_volume
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------ | -------- | ---------------------------------------------- | +| symbol | string | YES | US stock symbol, e.g. `AAPL.US`, `TSLA.US` | + +### Request Example + + + + + +longbridge option volume AAPL.US +longbridge option volume TSLA.US + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.option_volume("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.option_volume("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.optionVolume('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getOptionVolume("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.option_volume("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.option_volume("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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.OptionVolume(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "call_volume": 284512, + "put_volume": 195830, + "call_open_interest": 1824500, + "put_open_interest": 1532100, + "pc_vol": "0.6886", + "pc_oi": "0.8398" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [option_volume_rsp](#option_volume_rsp) | +| 400 | Bad request | None | + +## Schemas + +### option_volume_rsp + + + +| Name | Type | Required | Description | +| ------------------ | ------ | -------- | ---------------------------------------- | +| symbol | string | true | Security symbol | +| call_volume | int64 | true | Total call volume for today | +| put_volume | int64 | true | Total put volume for today | +| call_open_interest | int64 | true | Total call open interest | +| put_open_interest | int64 | true | Total put open interest | +| pc_vol | string | true | Put/call volume ratio | +| pc_oi | string | true | Put/call open interest ratio | diff --git a/docs/en/docs/quote/pull/option_volume_daily.md b/docs/en/docs/quote/pull/option_volume_daily.md new file mode 100644 index 00000000..db9d1d43 --- /dev/null +++ b/docs/en/docs/quote/pull/option_volume_daily.md @@ -0,0 +1,257 @@ +--- +slug: option-volume-daily +title: Option Volume Daily +sidebar_position: 27 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get historical daily call/put volume and open interest data for a US stock's options. + + +longbridge option volume daily AAPL.US +longbridge option volume daily TSLA.US --count 60 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/option_volume_daily
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------- | -------- | -------------------------------------------------- | +| symbol | string | YES | US stock symbol, e.g. `AAPL.US`, `TSLA.US` | +| count | integer | NO | Number of trading days to return (default: 20) | + +### Request Example + + + + + +longbridge option volume daily AAPL.US +longbridge option volume daily TSLA.US --count 60 + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.option_volume_daily("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.option_volume_daily("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.optionVolumeDaily('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getOptionVolumeDaily("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.option_volume_daily("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.option_volume_daily("AAPL.US", [](auto resp) { + if (resp) std::cout << resp->size() << 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.OptionVolumeDaily(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "date": "2026-05-07", + "call_volume": 284512, + "put_volume": 195830, + "call_open_interest": 1824500, + "put_open_interest": 1532100, + "pc_vol": "0.6886", + "pc_oi": "0.8398" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [option_volume_daily_rsp](#option_volume_daily_rsp) | +| 400 | Bad request | None | + +## Schemas + +### option_volume_daily_rsp + + + +| Name | Type | Required | Description | +| ------------------ | -------- | -------- | ---------------------------------------- | +| symbol | string | true | Security symbol | +| list | object[] | true | Daily volume records | +| ∟ date | string | true | Date in `YYYY-MM-DD` format | +| ∟ call_volume | int64 | true | Call volume on that day | +| ∟ put_volume | int64 | true | Put volume on that day | +| ∟ call_open_interest | int64 | true | Call open interest | +| ∟ put_open_interest | int64 | true | Put open interest | +| ∟ pc_vol | string | true | Put/call volume ratio | +| ∟ pc_oi | string | true | Put/call open interest ratio | diff --git a/docs/en/docs/quote/pull/short_positions.md b/docs/en/docs/quote/pull/short_positions.md new file mode 100644 index 00000000..43476a5f --- /dev/null +++ b/docs/en/docs/quote/pull/short_positions.md @@ -0,0 +1,253 @@ +--- +slug: short-positions +title: Short Positions +sidebar_position: 25 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get US stock short selling data — short interest, short ratio, days to cover, and average daily volume. Records are updated bi-monthly by FINRA. Only US-listed stocks and ETFs are supported. + + +longbridge short-positions TSLA.US +longbridge short-positions AAPL.US --count 50 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/short_positions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------ | -------- | --------------------------------------------------- | +| symbol | string | YES | US security symbol, e.g. `TSLA.US`, `AAPL.US` | +| count | integer | NO | Number of records to return (1–100, default: 20) | + +### Request Example + + + + + +longbridge short-positions TSLA.US +longbridge short-positions AAPL.US --count 50 + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.short_positions("TSLA.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.short_positions("TSLA.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.shortPositions('TSLA.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getShortPositions("TSLA.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.short_positions("TSLA.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.short_positions("TSLA.US", [](auto resp) { + if (resp) std::cout << resp->size() << 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.ShortPositions(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "date": "2026-03-31", + "rate": "0.0175", + "short_shares": "65598603", + "avg_daily_vol": "62121644", + "days_cover": "1.06", + "close": "371.750" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [short_positions_rsp](#short_positions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### short_positions_rsp + + + +| Name | Type | Required | Description | +| ------------- | -------- | -------- | ------------------------------------------------ | +| list | object[] | true | Short position records | +| ∟ date | string | true | Settlement date in `YYYY-MM-DD` format | +| ∟ rate | string | true | Short ratio (short shares ÷ float) | +| ∟ short_shares | string | true | Number of short shares | +| ∟ avg_daily_vol | string | true | Average daily volume | +| ∟ days_cover | string | true | Days-to-cover ratio (short shares ÷ avg daily vol) | +| ∟ close | string | true | Closing price on that date | diff --git a/docs/zh-CN/docs/account/_category_.json b/docs/zh-CN/docs/account/_category_.json new file mode 100644 index 00000000..02325a35 --- /dev/null +++ b/docs/zh-CN/docs/account/_category_.json @@ -0,0 +1 @@ +{ "position": 6, "label": "Account", "collapsed": false } diff --git a/docs/zh-CN/docs/account/alert/_category_.json b/docs/zh-CN/docs/account/alert/_category_.json new file mode 100644 index 00000000..6722410e --- /dev/null +++ b/docs/zh-CN/docs/account/alert/_category_.json @@ -0,0 +1 @@ +{ "position": 2, "label": "Alerts", "collapsed": false } diff --git a/docs/zh-CN/docs/account/alert/create_alert.md b/docs/zh-CN/docs/account/alert/create_alert.md new file mode 100644 index 00000000..4c0dfe8c --- /dev/null +++ b/docs/zh-CN/docs/account/alert/create_alert.md @@ -0,0 +1,240 @@ +--- +slug: create-alert +title: 创建价格提醒 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +为指定证券创建价格提醒,当价格高于或低于目标价时触发通知。 + + +longbridge alert add TSLA.US --price 300 --direction rise +longbridge alert add AAPL.US --price 150 --direction fall + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/account/alerts
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.US` | +| price | string | YES | Target price | +| direction | string | YES | Alert direction: `rise` or `fall` | +| frequency | string | NO | Trigger frequency: `once` (default) or `every` | + +### Request Example + + + + + +longbridge alert add TSLA.US --price 300 --direction rise +longbridge alert add AAPL.US --price 150 --direction fall + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.create_alert() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.create_alert() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.create_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getCreateAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.create_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.create_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 486469 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_alert_rsp](#create_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_alert_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | ID of the newly created alert | diff --git a/docs/zh-CN/docs/account/alert/delete_alert.md b/docs/zh-CN/docs/account/alert/delete_alert.md new file mode 100644 index 00000000..3c099e4a --- /dev/null +++ b/docs/zh-CN/docs/account/alert/delete_alert.md @@ -0,0 +1,233 @@ +--- +slug: delete-alert +title: 删除价格提醒 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +根据 ID 删除指定的价格提醒。 + + +longbridge alert delete 486469 +longbridge alert delete 112326 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/account/alerts/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Alert ID (path parameter) | + +### Request Example + + + + + +longbridge alert delete 486469 +longbridge alert delete 112326 + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.delete_alert("486469") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.delete_alert("486469") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.delete_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getDeleteAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.delete_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.delete_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_alert_rsp](#delete_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_alert_rsp + + + +No response body fields. diff --git a/docs/zh-CN/docs/account/alert/list_alerts.md b/docs/zh-CN/docs/account/alert/list_alerts.md new file mode 100644 index 00000000..df3da496 --- /dev/null +++ b/docs/zh-CN/docs/account/alert/list_alerts.md @@ -0,0 +1,252 @@ +--- +slug: list-alerts +title: 获取价格提醒列表 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取当前用户的所有价格提醒,支持按标的筛选。 + + +longbridge alert +longbridge alert TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/alerts
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | NO | Filter by security symbol, e.g. `TSLA.US` | + +### Request Example + + + + + +longbridge alert +longbridge alert TSLA.US + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.list_alerts() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.list_alerts() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.list_alerts() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getListAlerts().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.list_alerts().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.list_alerts([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListAlerts(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "id": 112326, + "symbol": "TSLA.US", + "price": "348.950", + "direction": "fall", + "enabled": true, + "frequency": "every" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_alerts_rsp](#list_alerts_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_alerts_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Alert list | +| ∟ id | int64 | true | Alert ID | +| ∟ symbol | string | true | Security symbol | +| ∟ price | string | true | Target price | +| ∟ direction | string | true | Direction: `rise` or `fall` | +| ∟ enabled | bool | true | Whether alert is enabled | +| ∟ frequency | string | true | Trigger frequency: `once` or `every` | diff --git a/docs/zh-CN/docs/account/alert/update_alert.md b/docs/zh-CN/docs/account/alert/update_alert.md new file mode 100644 index 00000000..b1f200a2 --- /dev/null +++ b/docs/zh-CN/docs/account/alert/update_alert.md @@ -0,0 +1,234 @@ +--- +slug: update-alert +title: 更新价格提醒 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +启用或禁用已有的价格提醒。 + + +longbridge alert enable 112326 +longbridge alert disable 112326 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Alert ID (path parameter) | +| enabled | bool | YES | Set to `true` to enable or `false` to disable | + +### Request Example + + + + + +longbridge alert enable 112326 +longbridge alert disable 112326 + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.update_alert("112326", enabled=True) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.update_alert("112326", enabled=True) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.update_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getUpdateAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.update_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.update_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_alert_rsp](#update_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_alert_rsp + + + +No response body fields. diff --git a/docs/zh-CN/docs/account/dca/_category_.json b/docs/zh-CN/docs/account/dca/_category_.json new file mode 100644 index 00000000..3d43361f --- /dev/null +++ b/docs/zh-CN/docs/account/dca/_category_.json @@ -0,0 +1 @@ +{ "position": 3, "label": "DCA", "collapsed": false } diff --git a/docs/zh-CN/docs/account/dca/create_dca.md b/docs/zh-CN/docs/account/dca/create_dca.md new file mode 100644 index 00000000..b48edb95 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/create_dca.md @@ -0,0 +1,241 @@ +--- +slug: create-dca +title: 创建定期投资计划 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +为指定证券创建新的定期投资计划。 + + +longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 +longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/account/dca
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| amount | string | YES | Recurring investment amount | +| frequency | string | YES | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | +| day_of_week | string | NO | Day of week for weekly/fortnightly plans: `mon`–`fri` | +| day_of_month | integer | NO | Day of month for monthly plans (1–28) | + +### Request Example + + + + + +longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 +longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.create_dca("AAPL.US", amount="500", frequency="Monthly", day_of_month=15) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.create_dca("AAPL.US", amount="500", frequency="Monthly", day_of_month=15) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.create_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getCreateDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.create_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.create_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": "1225781523156889601" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_dca_rsp](#create_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_dca_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | true | ID of the newly created plan | diff --git a/docs/zh-CN/docs/account/dca/dca_history.md b/docs/zh-CN/docs/account/dca/dca_history.md new file mode 100644 index 00000000..22a6113c --- /dev/null +++ b/docs/zh-CN/docs/account/dca/dca_history.md @@ -0,0 +1,252 @@ +--- +slug: dca-history +title: 定期投资交易历史 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指定定期投资计划的执行历史,包含交易日期、金额和价格。 + + +longbridge dca history 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/dca/:id/history
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | +| page | integer | NO | Page number (1-based, default: 1) | +| size | integer | NO | Records per page (default: 20) | + +### Request Example + + + + + +longbridge dca history 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.dca_history("1225781523156889600") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.dca_history("1225781523156889600") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.dca_history() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getDcaHistory().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.dca_history().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.dca_history([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DcaHistory(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "trade_date": "2026-04-08T14:00:00Z", + "symbol": "SPY.US", + "amount": "750", + "price": "548.20", + "quantity": "1.37", + "status": "Filled" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dca_history_rsp](#dca_history_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dca_history_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Trade history records | +| ∟ trade_date | string | true | Trade execution date (ISO 8601) | +| ∟ symbol | string | true | Security symbol | +| ∟ amount | string | true | Invested amount | +| ∟ price | string | false | Execution price | +| ∟ quantity | string | false | Quantity purchased | +| ∟ status | string | true | Trade status: `Filled`, `Failed` | diff --git a/docs/zh-CN/docs/account/dca/delete_dca.md b/docs/zh-CN/docs/account/dca/delete_dca.md new file mode 100644 index 00000000..7eae222d --- /dev/null +++ b/docs/zh-CN/docs/account/dca/delete_dca.md @@ -0,0 +1,231 @@ +--- +slug: delete-dca +title: 删除定期投资计划 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +永久停止并删除定期投资计划,此操作不可撤销。 + + +longbridge dca stop 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/account/dca/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | + +### Request Example + + + + + +longbridge dca stop 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.delete_dca("1225781523156889600") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.delete_dca("1225781523156889600") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.delete_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getDeleteDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.delete_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.delete_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_dca_rsp](#delete_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_dca_rsp + + + +No response body fields. diff --git a/docs/zh-CN/docs/account/dca/list_dca.md b/docs/zh-CN/docs/account/dca/list_dca.md new file mode 100644 index 00000000..2baaa021 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/list_dca.md @@ -0,0 +1,255 @@ +--- +slug: list-dca +title: 获取定期投资计划列表 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取当前用户的所有定期投资(DCA)计划。 + + +longbridge dca +longbridge dca --status Active + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/dca
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| status | string | NO | Filter by plan status: `Active`, `Suspended`, `Finished` | +| symbol | string | NO | Filter by security symbol | + +### Request Example + + + + + +longbridge dca +longbridge dca --status Active + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.list_dca() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.list_dca() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.list_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getListDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.list_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.list_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "id": "1225781523156889600", + "symbol": "SPY.US", + "status": "Finished", + "amount": "750", + "frequency": "Fortnightly", + "day_of_week": "Wed", + "next_trade_date": "2026-04-08T14:00:00Z" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_dca_rsp](#list_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_dca_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | DCA plan list | +| ∟ id | string | true | Plan ID | +| ∟ symbol | string | true | Security symbol | +| ∟ status | string | true | Plan status: `Active`, `Suspended`, `Finished` | +| ∟ amount | string | true | Recurring investment amount | +| ∟ frequency | string | true | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | +| ∟ day_of_week | string | false | Day of week for weekly/fortnightly plans | +| ∟ next_trade_date | string | false | Next scheduled trade date (ISO 8601) | diff --git a/docs/zh-CN/docs/account/dca/update_dca.md b/docs/zh-CN/docs/account/dca/update_dca.md new file mode 100644 index 00000000..d28e5aec --- /dev/null +++ b/docs/zh-CN/docs/account/dca/update_dca.md @@ -0,0 +1,234 @@ +--- +slug: update-dca +title: 更新定期投资计划 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +暂停或恢复已有的定期投资计划。 + + +longbridge dca pause 1225781523156889600 +longbridge dca resume 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/dca/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | +| action | string | YES | Action to perform: `pause` or `resume` | + +### Request Example + + + + + +longbridge dca pause 1225781523156889600 +longbridge dca resume 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.update_dca("1225781523156889600", action="pause") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.update_dca("1225781523156889600", action="pause") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.update_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getUpdateDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.update_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.update_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_dca_rsp](#update_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_dca_rsp + + + +No response body fields. diff --git a/docs/zh-CN/docs/account/portfolio/_category_.json b/docs/zh-CN/docs/account/portfolio/_category_.json new file mode 100644 index 00000000..7cc2901d --- /dev/null +++ b/docs/zh-CN/docs/account/portfolio/_category_.json @@ -0,0 +1 @@ +{ "position": 1, "label": "Portfolio", "collapsed": false } diff --git a/docs/zh-CN/docs/account/portfolio/capital_flow.md b/docs/zh-CN/docs/account/portfolio/capital_flow.md new file mode 100644 index 00000000..a8cbf4c8 --- /dev/null +++ b/docs/zh-CN/docs/account/portfolio/capital_flow.md @@ -0,0 +1,259 @@ +--- +slug: capital-flow +title: 资金流水 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +查询账户资金流水历史,包含入金、出金、分红和结算等。 + + +longbridge cash-flow +longbridge cash-flow --format json + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/capital_flow
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_time | integer | NO | Start time as Unix timestamp (seconds) | +| end_time | integer | NO | End time as Unix timestamp (seconds) | +| business_type | integer | NO | Business type filter. Omit for all types. | +| symbol | string | NO | Filter by security symbol | +| page | integer | NO | Page number (1-based, default: 1) | +| size | integer | NO | Records per page (default: 20) | + +### Request Example + + + + + +longbridge cash-flow +longbridge cash-flow --format json + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.capital_flow() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.capital_flow() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.capital_flow() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getCapitalFlow().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.capital_flow().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.capital_flow([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CapitalFlow(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "transaction_flow_name": "Cash Dividend", + "direction": 1, + "business_type": 2, + "balance": "25.00", + "currency": "USD", + "business_time": "1774310400", + "symbol": "AAPL.US" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [capital_flow_rsp](#capital_flow_rsp) | +| 400 | Bad request | None | + +## Schemas + +### capital_flow_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Cash flow records | +| ∟ transaction_flow_name | string | true | Flow type description | +| ∟ direction | int32 | true | `1` = inflow, `-1` = outflow | +| ∟ business_type | int32 | true | Business type code | +| ∟ balance | string | true | Amount | +| ∟ currency | string | true | Currency | +| ∟ business_time | string | true | Transaction time as Unix timestamp | +| ∟ symbol | string | false | Associated security symbol | diff --git a/docs/zh-CN/docs/account/portfolio/exchange_rates.md b/docs/zh-CN/docs/account/portfolio/exchange_rates.md new file mode 100644 index 00000000..28c79903 --- /dev/null +++ b/docs/zh-CN/docs/account/portfolio/exchange_rates.md @@ -0,0 +1,246 @@ +--- +slug: exchange-rates +title: 汇率 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取账户中所有货币对的当前外汇汇率。 + + +longbridge exchange-rate + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/exchange_rates
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| base | string | NO | Base currency, e.g. `USD`. Omit for all pairs. | + +### Request Example + + + + + +longbridge exchange-rate + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.exchange_rates() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.exchange_rates() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.exchange_rates() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getExchangeRates().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.exchange_rates().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.exchange_rates([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ExchangeRates(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "pair": "HKD/USD", + "bid_rate": "0.1284", + "offer_rate": "0.1285", + "average_rate": "0.12845" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [exchange_rates_rsp](#exchange_rates_rsp) | +| 400 | Bad request | None | + +## Schemas + +### exchange_rates_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Exchange rate list | +| ∟ pair | string | true | Currency pair, e.g. `HKD/USD` | +| ∟ bid_rate | string | true | Bid rate | +| ∟ offer_rate | string | true | Offer rate | +| ∟ average_rate | string | true | Average rate | diff --git a/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md new file mode 100644 index 00000000..26531851 --- /dev/null +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md @@ -0,0 +1,258 @@ +--- +slug: profit-analysis-by-market +title: 按市场盈亏分析 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取按市场分组的盈亏分析(美股、港股、A 股、新加坡股)。 + + +longbridge profit-analysis --format json +longbridge profit-analysis --start 2026-01-01 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis/by_market
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis --format json +longbridge profit-analysis --start 2026-01-01 + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_by_market() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_by_market() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_by_market() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisByMarket().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_by_market().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_by_market([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisByMarket(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "market": "US", + "pnl": "42000.00", + "pnl_pct": "0.5412", + "market_value": "120000.00", + "currency": "USD" + }, + { + "market": "HK", + "pnl": "5203.00", + "pnl_pct": "0.1832", + "market_value": "28400.00", + "currency": "HKD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_by_market_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | P&L by market list | +| ∟ market | string | true | Market code | +| ∟ pnl | string | true | P&L for this market | +| ∟ pnl_pct | string | true | P&L percentage | +| ∟ market_value | string | false | Market value | +| ∟ currency | string | true | Settlement currency | diff --git a/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md new file mode 100644 index 00000000..1865c13e --- /dev/null +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md @@ -0,0 +1,251 @@ +--- +slug: profit-analysis-detail +title: 盈亏分析明细 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指定证券的详细盈亏分析,包含交易流水和成本分解。 + + +longbridge profit-analysis detail TSLA.US +longbridge profit-analysis detail AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis/detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.US` | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis detail TSLA.US +longbridge profit-analysis detail AAPL.US + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_detail("TSLA.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_detail("TSLA.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_detail() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisDetail().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_detail().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_detail([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisDetail(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "name": "Tesla Inc.", + "pnl": "12450.00", + "pnl_pct": "0.2891", + "cost": "43085.00", + "market_value": "55535.00", + "currency": "USD" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_detail_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| name | string | true | Security name | +| pnl | string | true | Total P&L | +| pnl_pct | string | true | P&L percentage | +| cost | string | true | Total cost basis | +| market_value | string | false | Current market value | +| currency | string | true | Currency | diff --git a/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md new file mode 100644 index 00000000..a577386c --- /dev/null +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md @@ -0,0 +1,254 @@ +--- +slug: profit-analysis-summary +title: 盈亏分析汇总 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取账户盈亏汇总,包含总资产、总盈亏和收益率指标。 + + +longbridge profit-analysis +longbridge profit-analysis --start 2026-01-01 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis +longbridge profit-analysis --start 2026-01-01 + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_summary() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_summary() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_summary() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisSummary().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_summary().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_summary([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisSummary(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "currency": "USD", + "total_asset": "125413.01", + "invest_amount": "76997.11", + "total_pnl": "48415.89", + "simple_yield": "0.6288", + "twr": "0.5841", + "stocks_traded": 12, + "start_date": "2023-12-04", + "end_date": "2026-04-17" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_summary_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| currency | string | true | Settlement currency | +| total_asset | string | true | Total asset value | +| invest_amount | string | true | Total invested amount | +| total_pnl | string | true | Total P&L | +| simple_yield | string | true | Simple yield ratio | +| twr | string | true | Time-weighted return | +| stocks_traded | int32 | true | Number of stocks traded | +| start_date | string | true | Analysis start date | +| end_date | string | true | Analysis end date | diff --git a/docs/zh-CN/docs/account/sharelist/_category_.json b/docs/zh-CN/docs/account/sharelist/_category_.json new file mode 100644 index 00000000..896f0ec1 --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/_category_.json @@ -0,0 +1 @@ +{ "position": 4, "label": "Sharelist", "collapsed": false } diff --git a/docs/zh-CN/docs/account/sharelist/create_sharelist.md b/docs/zh-CN/docs/account/sharelist/create_sharelist.md new file mode 100644 index 00000000..3d7c2e80 --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/create_sharelist.md @@ -0,0 +1,237 @@ +--- +slug: create-sharelist +title: 创建自选列表 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +创建新的社区自选股列表,可选择预设初始证券。 + + +longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/community/sharelists
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | YES | Sharelist name | +| description | string | NO | Description | +| securities | string[] | NO | Initial list of security symbols, e.g. `["AAPL.US", "NVDA.US"]` | + +### Request Example + + + + + +longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.create_sharelist(name="AI Picks", description="Top AI infrastructure stocks") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.create_sharelist(name="AI Picks", description="Top AI infrastructure stocks") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.create_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getCreateSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.create_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.create_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 15922 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_sharelist_rsp](#create_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_sharelist_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | ID of the newly created sharelist | diff --git a/docs/zh-CN/docs/account/sharelist/delete_sharelist.md b/docs/zh-CN/docs/account/sharelist/delete_sharelist.md new file mode 100644 index 00000000..f11b4e0d --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/delete_sharelist.md @@ -0,0 +1,231 @@ +--- +slug: delete-sharelist +title: 删除自选列表 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +永久删除您创建的自选股列表,此操作不可撤销。 + + +longbridge sharelist delete 15921 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/community/sharelists/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Sharelist ID (path parameter) | + +### Request Example + + + + + +longbridge sharelist delete 15921 + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.delete_sharelist(15921) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.delete_sharelist(15921) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.delete_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getDeleteSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.delete_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.delete_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_sharelist_rsp](#delete_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_sharelist_rsp + + + +No response body fields. diff --git a/docs/zh-CN/docs/account/sharelist/list_sharelist.md b/docs/zh-CN/docs/account/sharelist/list_sharelist.md new file mode 100644 index 00000000..d930390f --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/list_sharelist.md @@ -0,0 +1,254 @@ +--- +slug: list-sharelist +title: 获取自选列表 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取当前用户创建的或订阅的所有社区自选股列表。 + + +longbridge sharelist +longbridge sharelist --format json + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/community/sharelists
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| type | string | NO | Filter: `mine` or `subscribed`. Omit for both. | + +### Request Example + + + + + +longbridge sharelist +longbridge sharelist --format json + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.list_sharelist() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.list_sharelist() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.list_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getListSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.list_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.list_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "mine": [ + { + "id": 15921, + "name": "AI Picks", + "type": "Regular", + "day_change": "-0.40", + "ytd_change": "6.64", + "subscribers": 500 + } + ], + "subscribed": [] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_sharelist_rsp](#list_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_sharelist_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| mine | object[] | true | Sharelists created by the user | +| subscribed | object[] | true | Sharelists subscribed by the user | +| ∟ id | int64 | true | Sharelist ID | +| ∟ name | string | true | Sharelist name | +| ∟ type | string | true | Type: `Regular`, `Official` | +| ∟ day_change | string | false | Day change percentage | +| ∟ ytd_change | string | false | Year-to-date change | +| ∟ subscribers | int32 | false | Subscriber count | diff --git a/docs/zh-CN/docs/account/sharelist/update_sharelist.md b/docs/zh-CN/docs/account/sharelist/update_sharelist.md new file mode 100644 index 00000000..085e5d34 --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/update_sharelist.md @@ -0,0 +1,236 @@ +--- +slug: update-sharelist +title: 更新自选列表 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +在自选股列表中添加、移除或重排证券,或对列表重命名。 + + +longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US +longbridge sharelist remove 15921 AAPL.US + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/community/sharelists/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Sharelist ID (path parameter) | +| name | string | NO | New name. Omit to keep existing. | +| mode | string | NO | Operation mode for securities: `add`, `remove`, or `replace` | +| securities | string[] | NO | Security symbols affected by the operation | + +### Request Example + + + + + +longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US +longbridge sharelist remove 15921 AAPL.US + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.update_sharelist(15921, mode="add", securities=["TSLA.US", "NVDA.US"]) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.update_sharelist(15921, mode="add", securities=["TSLA.US", "NVDA.US"]) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.update_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getUpdateSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.update_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.update_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_sharelist_rsp](#update_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_sharelist_rsp + + + +No response body fields. diff --git a/docs/zh-CN/docs/fundamental/_category_.json b/docs/zh-CN/docs/fundamental/_category_.json new file mode 100644 index 00000000..8aa51261 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/_category_.json @@ -0,0 +1 @@ +{ "position": 5, "label": "Fundamental", "collapsed": false } diff --git a/docs/zh-CN/docs/fundamental/calendar/_category_.json b/docs/zh-CN/docs/fundamental/calendar/_category_.json new file mode 100644 index 00000000..749c348f --- /dev/null +++ b/docs/zh-CN/docs/fundamental/calendar/_category_.json @@ -0,0 +1 @@ +{ "position": 3, "label": "Calendar", "collapsed": false } diff --git a/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md b/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md new file mode 100644 index 00000000..46122263 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md @@ -0,0 +1,254 @@ +--- +slug: dividend-calendar +title: 分红日历 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取即将到来和历史分红事件,包含除息日、派息日和分红金额。 + + +longbridge finance-calendar dividend +longbridge finance-calendar dividend --filter positions + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/dividends
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar dividend +longbridge finance-calendar dividend --filter positions + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.dividend_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.dividend_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.dividend_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getDividendCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.dividend_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.dividend_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DividendCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "name": "Apple Inc.", + "ex_date": "2026-05-09", + "pay_date": "2026-05-15", + "amount": "0.25", + "currency": "USD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dividend_calendar_rsp](#dividend_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dividend_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Dividend event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ ex_date | string | true | Ex-dividend date | +| ∟ pay_date | string | false | Payment date | +| ∟ amount | string | true | Dividend amount per share | +| ∟ currency | string | true | Currency | diff --git a/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md b/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md new file mode 100644 index 00000000..9814a012 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md @@ -0,0 +1,254 @@ +--- +slug: earnings-calendar +title: 财报日历 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +浏览即将发布的财报及近期业绩,包含 EPS 和营收预期。 + + +longbridge finance-calendar report +longbridge finance-calendar report --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/earnings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar report +longbridge finance-calendar report --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.earnings_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.earnings_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.earnings_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getEarningsCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.earnings_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.earnings_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.EarningsCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "name": "Apple Inc.", + "report_date": "2026-04-30", + "eps_estimate": "1.62", + "eps_actual": null, + "revenue_estimate": "94500000000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [earnings_calendar_rsp](#earnings_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### earnings_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Earnings event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ report_date | string | true | Expected report date | +| ∟ eps_estimate | string | false | EPS estimate | +| ∟ eps_actual | string | false | Actual EPS (null if not yet reported) | +| ∟ revenue_estimate | string | false | Revenue estimate | diff --git a/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md b/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md new file mode 100644 index 00000000..aea34b45 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md @@ -0,0 +1,254 @@ +--- +slug: ipo-calendar +title: IPO 日历 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取即将上市和近期 IPO 信息,包含预计发行价和上市日期。 + + +longbridge finance-calendar ipo +longbridge finance-calendar ipo --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/ipos
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar ipo +longbridge finance-calendar ipo --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.ipo_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.ipo_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.ipo_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getIpoCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.ipo_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.ipo_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.IpoCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NEWCO.US", + "name": "New Company Inc.", + "listing_date": "2026-05-15", + "offer_price": "18.00", + "currency": "USD", + "market": "US" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ipo_calendar_rsp](#ipo_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ipo_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | IPO event list | +| ∟ symbol | string | false | Security symbol (assigned after listing) | +| ∟ name | string | true | Company name | +| ∟ listing_date | string | true | Expected listing date | +| ∟ offer_price | string | false | IPO offer price | +| ∟ currency | string | false | Currency | +| ∟ market | string | true | Market code | diff --git a/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md b/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md new file mode 100644 index 00000000..4dced0fb --- /dev/null +++ b/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md @@ -0,0 +1,256 @@ +--- +slug: macro-calendar +title: 宏观日历 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取即将发布的宏观经济数据,如 CPI、GDP 和美联储会议等。 + + +longbridge finance-calendar macrodata +longbridge finance-calendar macrodata --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/macro
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| country | string | NO | Country code: `US`, `CN`, `EU`, `JP`. Omit for global. | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar macrodata +longbridge finance-calendar macrodata --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.macro_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.macro_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.macro_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getMacroCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.macro_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.macro_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.MacroCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "event": "US CPI (YoY)", + "country": "US", + "release_date": "2026-05-13", + "actual": null, + "forecast": "2.4", + "previous": "2.4", + "importance": "High" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [macro_calendar_rsp](#macro_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### macro_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Macro event list | +| ∟ event | string | true | Event name | +| ∟ country | string | true | Country code | +| ∟ release_date | string | true | Release date | +| ∟ actual | string | false | Actual value (null if not yet released) | +| ∟ forecast | string | false | Consensus forecast | +| ∟ previous | string | false | Previous period value | +| ∟ importance | string | false | Importance level: `High`, `Medium`, `Low` | diff --git a/docs/zh-CN/docs/fundamental/calendar/split_calendar.md b/docs/zh-CN/docs/fundamental/calendar/split_calendar.md new file mode 100644 index 00000000..255d11de --- /dev/null +++ b/docs/zh-CN/docs/fundamental/calendar/split_calendar.md @@ -0,0 +1,252 @@ +--- +slug: split-calendar +title: 拆股日历 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取即将到来和历史拆股及合股事件。 + + +longbridge finance-calendar split +longbridge finance-calendar split --market HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/splits
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar split +longbridge finance-calendar split --market HK + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.split_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.split_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.split_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getSplitCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.split_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.split_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.SplitCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NVDA.US", + "name": "NVIDIA Corp", + "date": "2024-06-10", + "ratio": "10:1", + "type": "Split" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [split_calendar_rsp](#split_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### split_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Split event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ date | string | true | Effective date | +| ∟ ratio | string | true | Split ratio, e.g. `10:1` | +| ∟ type | string | true | `Split` or `ReverseSplit` | diff --git a/docs/zh-CN/docs/fundamental/fundamental/_category_.json b/docs/zh-CN/docs/fundamental/fundamental/_category_.json new file mode 100644 index 00000000..1e080d05 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/_category_.json @@ -0,0 +1 @@ +{ "position": 1, "label": "Fundamentals", "collapsed": false } diff --git a/docs/zh-CN/docs/fundamental/fundamental/company_profile.md b/docs/zh-CN/docs/fundamental/fundamental/company_profile.md new file mode 100644 index 00000000..23687fe5 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/company_profile.md @@ -0,0 +1,249 @@ +--- +slug: company-profile +title: 公司概况 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取公司基本资料,包括成立年份、员工人数、总部地址和业务描述。 + + +longbridge company TSLA.US +longbridge company AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/company_profile
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge company TSLA.US +longbridge company AAPL.US + + + + + +```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.company_profile("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.company_profile("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.company_profile('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.getCompanyProfile("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.company_profile("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.company_profile("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.CompanyProfile(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "name": "Apple Inc.", + "symbol": "AAPL.US", + "founded": "1976", + "ceo": "Timothy D. Cook", + "employees": 166000, + "website": "www.apple.com", + "description": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide." + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [company_profile_rsp](#company_profile_rsp) | +| 400 | Bad request | None | + +## Schemas + +### company_profile_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | true | Company name | +| symbol | string | true | Security symbol | +| founded | string | false | Founding year | +| ceo | string | false | Current CEO | +| employees | int32 | false | Number of employees | +| website | string | false | Company website | +| description | string | false | Business description | diff --git a/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md b/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md new file mode 100644 index 00000000..29a8df3e --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md @@ -0,0 +1,250 @@ +--- +slug: corporate-actions +title: 公司行动 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指定证券的公司行动历史,包括拆股、合并、分拆和配股等。 + + +longbridge corp-action TSLA.US +longbridge corp-action AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/corporate_actions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge corp-action TSLA.US +longbridge corp-action AAPL.US + + + + + +```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.corporate_actions("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.corporate_actions("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.corporate_actions('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.getCorporateActions("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.corporate_actions("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.corporate_actions("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.CorporateActions(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "type": "Split", + "date": "2020-08-31", + "ratio": "4:1", + "description": "4-for-1 stock split" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [corporate_actions_rsp](#corporate_actions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### corporate_actions_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Corporate action list | +| ∟ type | string | true | Action type: `Split`, `Merger`, `Spinoff`, `Rights` | +| ∟ date | string | true | Effective date | +| ∟ ratio | string | false | Split/merge ratio | +| ∟ description | string | false | Action description | diff --git a/docs/zh-CN/docs/fundamental/fundamental/dividends.md b/docs/zh-CN/docs/fundamental/fundamental/dividends.md new file mode 100644 index 00000000..f922d8e9 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/dividends.md @@ -0,0 +1,252 @@ +--- +slug: dividends +title: 分红历史 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指定证券的分红历史及即将公布的分红信息。 + + +longbridge dividend TSLA.US +longbridge dividend AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/dividends
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge dividend TSLA.US +longbridge dividend AAPL.US + + + + + +```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.dividends("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.dividends("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.dividends('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.getDividends("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.dividends("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.dividends("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.Dividends(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "ex_date": "2026-02-07", + "pay_date": "2026-02-13", + "amount": "0.25", + "currency": "USD", + "type": "Cash" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dividends_rsp](#dividends_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dividends_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Dividend records | +| ∟ ex_date | string | true | Ex-dividend date | +| ∟ pay_date | string | false | Payment date | +| ∟ amount | string | true | Dividend amount per share | +| ∟ currency | string | true | Currency | +| ∟ type | string | true | Dividend type, e.g. `Cash`, `Stock` | diff --git a/docs/zh-CN/docs/fundamental/fundamental/executives.md b/docs/zh-CN/docs/fundamental/fundamental/executives.md new file mode 100644 index 00000000..4d7ad25b --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/executives.md @@ -0,0 +1,248 @@ +--- +slug: executives +title: 高管团队 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取公司关键高管列表(CEO、CFO 等)。 + + +longbridge executive TSLA.US +longbridge executive AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/executives
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge executive TSLA.US +longbridge executive AAPL.US + + + + + +```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.executives("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.executives("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.executives('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.getExecutives("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.executives("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.executives("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.Executives(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "name": "Timothy D. Cook", + "title": "Chief Executive Officer", + "age": 63, + "since": "2011" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [executives_rsp](#executives_rsp) | +| 400 | Bad request | None | + +## Schemas + +### executives_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Executive list | +| ∟ name | string | true | Executive name | +| ∟ title | string | true | Job title | +| ∟ age | int32 | false | Age | +| ∟ since | string | false | Year appointed | diff --git a/docs/zh-CN/docs/fundamental/fundamental/financial_report.md b/docs/zh-CN/docs/fundamental/fundamental/financial_report.md new file mode 100644 index 00000000..0dad6670 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/financial_report.md @@ -0,0 +1,254 @@ +--- +slug: financial-report +title: 财务报告 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取任意上市公司的利润表、资产负债表和现金流量表。 + + +longbridge financial-report TSLA.US --kind IS +longbridge financial-report AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/financial_reports
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| kind | string | NO | Statement type: `IS` (income), `BS` (balance sheet), `CF` (cash flow), `ALL` (default) | +| report | string | NO | Reporting period: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | + +### Request Example + + + + + +longbridge financial-report TSLA.US --kind IS +longbridge financial-report AAPL.US + + + + + +```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("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.financial_report("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.financial_report('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.getFinancialReport("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.financial_report("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.financial_report("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.FinancialReport(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "type": "IS", + "period": "Q4 2025", + "eps": "0.24", + "revenue": "24900000000", + "net_income": "840000000", + "gross_margin": "0.2012" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [financial_report_rsp](#financial_report_rsp) | +| 400 | Bad request | None | + +## Schemas + +### financial_report_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of financial statement records | +| ∟ type | string | true | Statement type: `IS`, `BS`, `CF` | +| ∟ period | string | true | Reporting period label | +| ∟ eps | string | false | Earnings per share | +| ∟ revenue | string | false | Total revenue | +| ∟ net_income | string | false | Net income | +| ∟ gross_margin | string | false | Gross margin ratio | diff --git a/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md b/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md new file mode 100644 index 00000000..df070ce5 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md @@ -0,0 +1,248 @@ +--- +slug: fund-holdings +title: 基金持仓 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取持有指定证券的基金列表,含持股数量和持股比例。 + + +longbridge fund-holder TSLA.US +longbridge fund-holder AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/fund_holdings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge fund-holder TSLA.US +longbridge fund-holder AAPL.US + + + + + +```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.fund_holdings("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.fund_holdings("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.fund_holdings('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.getFundHoldings("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.fund_holdings("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.fund_holdings("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.FundHoldings(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "fund_name": "Vanguard Total Stock Market ETF", + "shares": "289000000", + "percentage": "1.88", + "date": "2026-03-31" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [fund_holdings_rsp](#fund_holdings_rsp) | +| 400 | Bad request | None | + +## Schemas + +### fund_holdings_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Fund holder list | +| ∟ fund_name | string | true | Fund name | +| ∟ shares | string | true | Number of shares held | +| ∟ percentage | string | true | Ownership percentage | +| ∟ date | string | false | Report date | diff --git a/docs/zh-CN/docs/fundamental/fundamental/ratings.md b/docs/zh-CN/docs/fundamental/fundamental/ratings.md new file mode 100644 index 00000000..5d8b499b --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/ratings.md @@ -0,0 +1,250 @@ +--- +slug: ratings +title: 分析师评级 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指定证券的机构分析师评级和一致预期数据。 + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/ratings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + + +```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.ratings("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.ratings("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.ratings('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.getRatings("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.ratings("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.ratings("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.Ratings(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "broker_name": "Goldman Sachs", + "rating": "Buy", + "target_price": "230.00", + "currency": "USD", + "date": "2026-01-10" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ratings_rsp](#ratings_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ratings_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of analyst ratings | +| ∟ broker_name | string | true | Institution name | +| ∟ rating | string | true | Rating: `Buy`, `Hold`, `Sell` | +| ∟ target_price | string | false | Target price | +| ∟ currency | string | false | Currency | +| ∟ date | string | true | Rating date in `YYYY-MM-DD` format | diff --git a/docs/zh-CN/docs/fundamental/fundamental/shareholders.md b/docs/zh-CN/docs/fundamental/fundamental/shareholders.md new file mode 100644 index 00000000..036f2e22 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/shareholders.md @@ -0,0 +1,248 @@ +--- +slug: shareholders +title: 主要股东 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取公司主要机构股东和个人股东信息。 + + +longbridge shareholder TSLA.US +longbridge shareholder AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/shareholders
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge shareholder TSLA.US +longbridge shareholder AAPL.US + + + + + +```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.shareholders("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.shareholders("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.shareholders('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.getShareholders("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.shareholders("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.shareholders("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.Shareholders(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "name": "The Vanguard Group", + "shares": "1236787000", + "percentage": "8.04", + "type": "Institution" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [shareholders_rsp](#shareholders_rsp) | +| 400 | Bad request | None | + +## Schemas + +### shareholders_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Shareholder list | +| ∟ name | string | true | Shareholder name | +| ∟ shares | string | true | Number of shares held | +| ∟ percentage | string | true | Ownership percentage | +| ∟ type | string | false | `Institution` or `Individual` | diff --git a/docs/zh-CN/docs/fundamental/fundamental/valuations.md b/docs/zh-CN/docs/fundamental/fundamental/valuations.md new file mode 100644 index 00000000..997ba3df --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/valuations.md @@ -0,0 +1,246 @@ +--- +slug: valuations +title: 估值指标 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取当前估值指标(市盈率、市净率、市销率、股息率)及 5 年历史区间数据。 + + +longbridge valuation TSLA.US --indicator pe +longbridge valuation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/valuations
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| indicator | string | NO | Indicator filter: `pe`, `pb`, `ps`, `dvd_yld` | + +### Request Example + + + + + +longbridge valuation TSLA.US --indicator pe +longbridge valuation AAPL.US + + + + + +```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.valuations("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.valuations("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.valuations('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.getValuations("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.valuations("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.valuations("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.Valuations(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "metrics": { + "pe": { "current": "29.5", "high": "35.2", "low": "18.0", "median": "26.0" }, + "pb": { "current": "45.1", "high": "50.0", "low": "30.0", "median": "42.0" } + } + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [valuations_rsp](#valuations_rsp) | +| 400 | Bad request | None | + +## Schemas + +### valuations_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| metrics | object | true | Valuation metrics map | +| ∟ pe | object | false | P/E ratio data | +| ∟∟ current | string | true | Current value | +| ∟∟ high | string | true | 5-year high | +| ∟∟ low | string | true | 5-year low | +| ∟∟ median | string | true | 5-year median | diff --git a/docs/zh-CN/docs/fundamental/market/_category_.json b/docs/zh-CN/docs/fundamental/market/_category_.json new file mode 100644 index 00000000..d98f6649 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/_category_.json @@ -0,0 +1 @@ +{ "position": 2, "label": "Market", "collapsed": false } diff --git a/docs/zh-CN/docs/fundamental/market/ah_premium.md b/docs/zh-CN/docs/fundamental/market/ah_premium.md new file mode 100644 index 00000000..c227b168 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/ah_premium.md @@ -0,0 +1,250 @@ +--- +slug: ah-premium +title: A/H 溢价 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取 A+H 两地上市股票的 A/H 溢价比率,对比 A 股和 H 股价格。 + + +longbridge ah-premium 939.HK +longbridge ah-premium 0939.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/ah_premium
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | H-share symbol of a dual-listed stock, e.g. `939.HK` | + +### Request Example + + + + + +longbridge ah-premium 939.HK +longbridge ah-premium 0939.HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.ah_premium("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.ah_premium("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.ah_premium('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getAhPremium("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.ah_premium("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.ah_premium("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.AhPremium(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "date": "2026-04-08", + "a_price": "9.28", + "h_price": "6.70", + "premium": "1.0847", + "fx_rate": "0.8947" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ah_premium_rsp](#ah_premium_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ah_premium_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | A/H premium records | +| ∟ date | string | true | Date in `YYYY-MM-DD` format | +| ∟ a_price | string | true | A-share price in CNY | +| ∟ h_price | string | true | H-share price in HKD | +| ∟ premium | string | true | A/H premium ratio | +| ∟ fx_rate | string | true | CNH/HKD exchange rate | diff --git a/docs/zh-CN/docs/fundamental/market/broker_positions.md b/docs/zh-CN/docs/fundamental/market/broker_positions.md new file mode 100644 index 00000000..5e1e282a --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/broker_positions.md @@ -0,0 +1,252 @@ +--- +slug: broker-positions +title: 经纪商持仓 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +查看港股券商持仓情况,包含主要买卖方和详细持仓列表。 + + +longbridge broker-holding 700.HK +longbridge broker-holding 9988.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_positions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | HK security symbol, e.g. `700.HK` | + +### Request Example + + + + + +longbridge broker-holding 700.HK +longbridge broker-holding 9988.HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_positions("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_positions("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.broker_positions('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerPositions("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_positions("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.broker_positions("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerPositions(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "updated_at": "1774310400", + "participants": [ + { + "broker_id": 1234, + "broker_name": "HSBC Securities", + "buy_qty": "100000", + "sell_qty": "80000", + "net_qty": "20000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [broker_positions_rsp](#broker_positions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### broker_positions_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| updated_at | string | true | Last updated Unix timestamp | +| participants | object[] | true | Broker position list | +| ∟ broker_id | int32 | true | Broker ID | +| ∟ broker_name | string | true | Broker name | +| ∟ buy_qty | string | true | Buy quantity | +| ∟ sell_qty | string | true | Sell quantity | +| ∟ net_qty | string | true | Net quantity (buy - sell) | diff --git a/docs/zh-CN/docs/fundamental/market/index_components.md b/docs/zh-CN/docs/fundamental/market/index_components.md new file mode 100644 index 00000000..35208ff5 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/index_components.md @@ -0,0 +1,256 @@ +--- +slug: index-components +title: 指数成分股 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指数或 ETF 的成分股列表,支持排序并显示涨跌统计。 + + +longbridge constituent HSI.HK +longbridge constituent SPY.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/index_components
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Index or ETF symbol, e.g. `HSI.HK`, `SPY.US` | + +### Request Example + + + + + +longbridge constituent HSI.HK +longbridge constituent SPY.US + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.index_components("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.index_components("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.index_components('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getIndexComponents("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.index_components("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.index_components("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.IndexComponents(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "total": 90, + "rise": 45, + "fall": 42, + "flat": 3, + "components": [ + { + "symbol": "HSBC.HK", + "name": "HSBC Holdings", + "price": "68.40", + "change_pct": "0.88" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [index_components_rsp](#index_components_rsp) | +| 400 | Bad request | None | + +## Schemas + +### index_components_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| total | int32 | true | Total number of components | +| rise | int32 | true | Number of rising components | +| fall | int32 | true | Number of falling components | +| flat | int32 | true | Number of flat components | +| components | object[] | true | Component list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Security name | +| ∟ price | string | false | Current price | +| ∟ change_pct | string | false | Percentage change | diff --git a/docs/zh-CN/docs/fundamental/market/market_status.md b/docs/zh-CN/docs/fundamental/market/market_status.md new file mode 100644 index 00000000..4b2bb10d --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/market_status.md @@ -0,0 +1,249 @@ +--- +slug: market-status +title: 市场状态 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取各交易所当前的开市/休市状态。 + + +longbridge market-status + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/status
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market code: `US`, `HK`, `SH`, `SZ`, `SG`. Omit for all markets. | + +### Request Example + + + + + +longbridge market-status + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.market_status("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.market_status("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.market_status('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getMarketStatus("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.market_status("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.market_status("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.MarketStatus(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "market": "US", + "status": "normal_trading", + "trade_session": "Regular" + }, + { + "market": "HK", + "status": "closed", + "trade_session": "Closed" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [market_status_rsp](#market_status_rsp) | +| 400 | Bad request | None | + +## Schemas + +### market_status_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Market status list | +| ∟ market | string | true | Market code | +| ∟ status | string | true | Status: `normal_trading`, `closed`, `pre_trading`, `after_trading` | +| ∟ trade_session | string | false | Current trading session | diff --git a/docs/zh-CN/docs/fundamental/market/trading_stats.md b/docs/zh-CN/docs/fundamental/market/trading_stats.md new file mode 100644 index 00000000..7299f616 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/trading_stats.md @@ -0,0 +1,252 @@ +--- +slug: trading-stats +title: 成交统计 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取指定证券的成交统计数据,展示成交量的价格分布。 + + +longbridge trade-stats 700.HK +longbridge trade-stats TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/trading_stats
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `700.HK` | + +### Request Example + + + + + +longbridge trade-stats 700.HK +longbridge trade-stats TSLA.US + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.trading_stats("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.trading_stats("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.trading_stats('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getTradingStats("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.trading_stats("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.trading_stats("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.TradingStats(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "prev_close": "504.500", + "avg_price": "491.63", + "trades": 32782, + "volume": "15200000", + "turnover": "7382000000", + "distribution": [ + { "price": "490.00", "volume": "1200000", "pct": "7.89" } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [trading_stats_rsp](#trading_stats_rsp) | +| 400 | Bad request | None | + +## Schemas + +### trading_stats_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| prev_close | string | true | Previous close price | +| avg_price | string | true | Average trading price | +| trades | int32 | true | Number of trades | +| volume | string | true | Total volume | +| turnover | string | true | Total turnover | +| distribution | object[] | true | Price-volume distribution | +| ∟ price | string | true | Price level | +| ∟ volume | string | true | Volume at this price | +| ∟ pct | string | true | Percentage of total volume | diff --git a/docs/zh-CN/docs/fundamental/market/unusual_items.md b/docs/zh-CN/docs/fundamental/market/unusual_items.md new file mode 100644 index 00000000..8dea5b00 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/unusual_items.md @@ -0,0 +1,250 @@ +--- +slug: unusual-items +title: 异动行情 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +识别市场异动,包括价格异常波动、成交量激增等非正常交易行为。 + + +longbridge anomaly --market US +longbridge anomaly --market HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/unusual_items
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | YES | Market code: `US`, `HK`, `SH`, `SZ`, `SG` | + +### Request Example + + + + + +longbridge anomaly --market US +longbridge anomaly --market HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.unusual_items("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.unusual_items("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.unusual_items('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getUnusualItems("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.unusual_items("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.unusual_items("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UnusualItems(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NVDA.US", + "name": "NVIDIA Corp", + "alert": "Volume surge", + "emotion": "Bullish", + "time": "1774310400" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [unusual_items_rsp](#unusual_items_rsp) | +| 400 | Bad request | None | + +## Schemas + +### unusual_items_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Unusual item list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Security name | +| ∟ alert | string | true | Alert description | +| ∟ emotion | string | false | Market sentiment: `Bullish`, `Bearish` | +| ∟ time | string | true | Alert time as Unix timestamp | diff --git a/docs/zh-CN/docs/quote/individual/update_pinned.md b/docs/zh-CN/docs/quote/individual/update_pinned.md new file mode 100644 index 00000000..d892b02d --- /dev/null +++ b/docs/zh-CN/docs/quote/individual/update_pinned.md @@ -0,0 +1,210 @@ +--- +slug: update-pinned +title: 更新置顶证券 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +在自选股分组中置顶或取消置顶指定证券,以控制显示顺序。 + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/watchlist/groups
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| --------- | ------ | -------- | -------------------------------------------------------- | +| id | string | YES | Watchlist group ID | +| symbol | string | YES | Security symbol to pin or unpin, e.g. `AAPL.US` | +| is_pinned | bool | YES | Set to `true` to pin the security, `false` to unpin it | + +### Request Example + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + await ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + await ctx.updatePinned('2630', 'AAPL.US', true) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + ctx.updatePinned("2630", "AAPL.US", true).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + ctx.update_pinned("2630", "AAPL.US", true).await?; + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.update_pinned("2630", "AAPL.US", true, [](auto) {}); + }); + 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + if err := qctx.UpdatePinned(context.Background(), "2630", "AAPL.US", true); err != nil { + log.Fatal(err) + } + fmt.Println("OK") +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | + +## Schemas + +No response schemas. The endpoint returns an empty `data` object on success. diff --git a/docs/zh-CN/docs/quote/pull/option_volume.md b/docs/zh-CN/docs/quote/pull/option_volume.md new file mode 100644 index 00000000..3dfae0d5 --- /dev/null +++ b/docs/zh-CN/docs/quote/pull/option_volume.md @@ -0,0 +1,249 @@ +--- +slug: option-volume +title: 期权成交量 +sidebar_position: 26 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取今日认购/认沽期权成交量快照,包含总量、未平仓量和认沽/认购比率。 + + +longbridge option volume AAPL.US +longbridge option volume TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/option_volume
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------ | -------- | ---------------------------------------------- | +| symbol | string | YES | US stock symbol, e.g. `AAPL.US`, `TSLA.US` | + +### Request Example + + + + + +longbridge option volume AAPL.US +longbridge option volume TSLA.US + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.option_volume("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.option_volume("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.optionVolume('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getOptionVolume("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.option_volume("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.option_volume("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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.OptionVolume(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "call_volume": 284512, + "put_volume": 195830, + "call_open_interest": 1824500, + "put_open_interest": 1532100, + "pc_vol": "0.6886", + "pc_oi": "0.8398" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [option_volume_rsp](#option_volume_rsp) | +| 400 | Bad request | None | + +## Schemas + +### option_volume_rsp + + + +| Name | Type | Required | Description | +| ------------------ | ------ | -------- | ---------------------------------------- | +| symbol | string | true | Security symbol | +| call_volume | int64 | true | Total call volume for today | +| put_volume | int64 | true | Total put volume for today | +| call_open_interest | int64 | true | Total call open interest | +| put_open_interest | int64 | true | Total put open interest | +| pc_vol | string | true | Put/call volume ratio | +| pc_oi | string | true | Put/call open interest ratio | diff --git a/docs/zh-CN/docs/quote/pull/option_volume_daily.md b/docs/zh-CN/docs/quote/pull/option_volume_daily.md new file mode 100644 index 00000000..8c678db6 --- /dev/null +++ b/docs/zh-CN/docs/quote/pull/option_volume_daily.md @@ -0,0 +1,257 @@ +--- +slug: option-volume-daily +title: 期权历史成交量 +sidebar_position: 27 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取美股期权的历史每日认购/认沽成交量和未平仓量数据。 + + +longbridge option volume daily AAPL.US +longbridge option volume daily TSLA.US --count 60 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/option_volume_daily
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------- | -------- | -------------------------------------------------- | +| symbol | string | YES | US stock symbol, e.g. `AAPL.US`, `TSLA.US` | +| count | integer | NO | Number of trading days to return (default: 20) | + +### Request Example + + + + + +longbridge option volume daily AAPL.US +longbridge option volume daily TSLA.US --count 60 + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.option_volume_daily("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.option_volume_daily("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.optionVolumeDaily('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getOptionVolumeDaily("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.option_volume_daily("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.option_volume_daily("AAPL.US", [](auto resp) { + if (resp) std::cout << resp->size() << 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.OptionVolumeDaily(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "date": "2026-05-07", + "call_volume": 284512, + "put_volume": 195830, + "call_open_interest": 1824500, + "put_open_interest": 1532100, + "pc_vol": "0.6886", + "pc_oi": "0.8398" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [option_volume_daily_rsp](#option_volume_daily_rsp) | +| 400 | Bad request | None | + +## Schemas + +### option_volume_daily_rsp + + + +| Name | Type | Required | Description | +| ------------------ | -------- | -------- | ---------------------------------------- | +| symbol | string | true | Security symbol | +| list | object[] | true | Daily volume records | +| ∟ date | string | true | Date in `YYYY-MM-DD` format | +| ∟ call_volume | int64 | true | Call volume on that day | +| ∟ put_volume | int64 | true | Put volume on that day | +| ∟ call_open_interest | int64 | true | Call open interest | +| ∟ put_open_interest | int64 | true | Put open interest | +| ∟ pc_vol | string | true | Put/call volume ratio | +| ∟ pc_oi | string | true | Put/call open interest ratio | diff --git a/docs/zh-CN/docs/quote/pull/short_positions.md b/docs/zh-CN/docs/quote/pull/short_positions.md new file mode 100644 index 00000000..aceadffc --- /dev/null +++ b/docs/zh-CN/docs/quote/pull/short_positions.md @@ -0,0 +1,253 @@ +--- +slug: short-positions +title: 做空数据 +sidebar_position: 25 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get US stock short selling data — short interest, short ratio, days to cover, and average daily volume. Records are updated bi-monthly by FINRA. Only US-listed stocks and ETFs are supported. + + +longbridge short-positions TSLA.US +longbridge short-positions AAPL.US --count 50 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/short_positions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------ | -------- | --------------------------------------------------- | +| symbol | string | YES | US security symbol, e.g. `TSLA.US`, `AAPL.US` | +| count | integer | NO | Number of records to return (1–100, default: 20) | + +### Request Example + + + + + +longbridge short-positions TSLA.US +longbridge short-positions AAPL.US --count 50 + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.short_positions("TSLA.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.short_positions("TSLA.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.shortPositions('TSLA.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getShortPositions("TSLA.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.short_positions("TSLA.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.short_positions("TSLA.US", [](auto resp) { + if (resp) std::cout << resp->size() << 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.ShortPositions(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "date": "2026-03-31", + "rate": "0.0175", + "short_shares": "65598603", + "avg_daily_vol": "62121644", + "days_cover": "1.06", + "close": "371.750" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [short_positions_rsp](#short_positions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### short_positions_rsp + + + +| Name | Type | Required | Description | +| ------------- | -------- | -------- | ------------------------------------------------ | +| list | object[] | true | Short position records | +| ∟ date | string | true | Settlement date in `YYYY-MM-DD` format | +| ∟ rate | string | true | Short ratio (short shares ÷ float) | +| ∟ short_shares | string | true | Number of short shares | +| ∟ avg_daily_vol | string | true | Average daily volume | +| ∟ days_cover | string | true | Days-to-cover ratio (short shares ÷ avg daily vol) | +| ∟ close | string | true | Closing price on that date | diff --git a/docs/zh-HK/docs/account/_category_.json b/docs/zh-HK/docs/account/_category_.json new file mode 100644 index 00000000..02325a35 --- /dev/null +++ b/docs/zh-HK/docs/account/_category_.json @@ -0,0 +1 @@ +{ "position": 6, "label": "Account", "collapsed": false } diff --git a/docs/zh-HK/docs/account/alert/_category_.json b/docs/zh-HK/docs/account/alert/_category_.json new file mode 100644 index 00000000..6722410e --- /dev/null +++ b/docs/zh-HK/docs/account/alert/_category_.json @@ -0,0 +1 @@ +{ "position": 2, "label": "Alerts", "collapsed": false } diff --git a/docs/zh-HK/docs/account/alert/create_alert.md b/docs/zh-HK/docs/account/alert/create_alert.md new file mode 100644 index 00000000..1666ad93 --- /dev/null +++ b/docs/zh-HK/docs/account/alert/create_alert.md @@ -0,0 +1,240 @@ +--- +slug: create-alert +title: 建立價格提醒 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +為指定證券建立價格提醒,當價格高於或低於目標價時觸發通知。 + + +longbridge alert add TSLA.US --price 300 --direction rise +longbridge alert add AAPL.US --price 150 --direction fall + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/account/alerts
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.US` | +| price | string | YES | Target price | +| direction | string | YES | Alert direction: `rise` or `fall` | +| frequency | string | NO | Trigger frequency: `once` (default) or `every` | + +### Request Example + + + + + +longbridge alert add TSLA.US --price 300 --direction rise +longbridge alert add AAPL.US --price 150 --direction fall + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.create_alert() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.create_alert() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.create_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getCreateAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.create_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.create_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 486469 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_alert_rsp](#create_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_alert_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | ID of the newly created alert | diff --git a/docs/zh-HK/docs/account/alert/delete_alert.md b/docs/zh-HK/docs/account/alert/delete_alert.md new file mode 100644 index 00000000..16089796 --- /dev/null +++ b/docs/zh-HK/docs/account/alert/delete_alert.md @@ -0,0 +1,233 @@ +--- +slug: delete-alert +title: 刪除價格提醒 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +根據 ID 刪除指定的價格提醒。 + + +longbridge alert delete 486469 +longbridge alert delete 112326 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/account/alerts/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Alert ID (path parameter) | + +### Request Example + + + + + +longbridge alert delete 486469 +longbridge alert delete 112326 + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.delete_alert("486469") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.delete_alert("486469") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.delete_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getDeleteAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.delete_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.delete_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_alert_rsp](#delete_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_alert_rsp + + + +No response body fields. diff --git a/docs/zh-HK/docs/account/alert/list_alerts.md b/docs/zh-HK/docs/account/alert/list_alerts.md new file mode 100644 index 00000000..f92432a8 --- /dev/null +++ b/docs/zh-HK/docs/account/alert/list_alerts.md @@ -0,0 +1,252 @@ +--- +slug: list-alerts +title: 獲取價格提醒列表 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取當前用戶的所有價格提醒,支持按標的篩選。 + + +longbridge alert +longbridge alert TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/alerts
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | NO | Filter by security symbol, e.g. `TSLA.US` | + +### Request Example + + + + + +longbridge alert +longbridge alert TSLA.US + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.list_alerts() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.list_alerts() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.list_alerts() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getListAlerts().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.list_alerts().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.list_alerts([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListAlerts(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "id": 112326, + "symbol": "TSLA.US", + "price": "348.950", + "direction": "fall", + "enabled": true, + "frequency": "every" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_alerts_rsp](#list_alerts_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_alerts_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Alert list | +| ∟ id | int64 | true | Alert ID | +| ∟ symbol | string | true | Security symbol | +| ∟ price | string | true | Target price | +| ∟ direction | string | true | Direction: `rise` or `fall` | +| ∟ enabled | bool | true | Whether alert is enabled | +| ∟ frequency | string | true | Trigger frequency: `once` or `every` | diff --git a/docs/zh-HK/docs/account/alert/update_alert.md b/docs/zh-HK/docs/account/alert/update_alert.md new file mode 100644 index 00000000..5c42b14e --- /dev/null +++ b/docs/zh-HK/docs/account/alert/update_alert.md @@ -0,0 +1,234 @@ +--- +slug: update-alert +title: 更新價格提醒 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +啟用或停用已有的價格提醒。 + + +longbridge alert enable 112326 +longbridge alert disable 112326 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Alert ID (path parameter) | +| enabled | bool | YES | Set to `true` to enable or `false` to disable | + +### Request Example + + + + + +longbridge alert enable 112326 +longbridge alert disable 112326 + + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +resp = ctx.update_alert("112326", enabled=True) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + resp = await ctx.update_alert("112326", enabled=True) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + const resp = await ctx.update_alert() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + var resp = ctx.getUpdateAlert().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + let resp = ctx.update_alert().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::alert; + +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); + AlertContext ctx = AlertContext::create(config); + ctx.update_alert([](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/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateAlert(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_alert_rsp](#update_alert_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_alert_rsp + + + +No response body fields. diff --git a/docs/zh-HK/docs/account/dca/_category_.json b/docs/zh-HK/docs/account/dca/_category_.json new file mode 100644 index 00000000..3d43361f --- /dev/null +++ b/docs/zh-HK/docs/account/dca/_category_.json @@ -0,0 +1 @@ +{ "position": 3, "label": "DCA", "collapsed": false } diff --git a/docs/zh-HK/docs/account/dca/create_dca.md b/docs/zh-HK/docs/account/dca/create_dca.md new file mode 100644 index 00000000..bce1fb24 --- /dev/null +++ b/docs/zh-HK/docs/account/dca/create_dca.md @@ -0,0 +1,241 @@ +--- +slug: create-dca +title: 建立定期投資計劃 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +為指定證券建立新的定期投資計劃。 + + +longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 +longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/account/dca
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| amount | string | YES | Recurring investment amount | +| frequency | string | YES | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | +| day_of_week | string | NO | Day of week for weekly/fortnightly plans: `mon`–`fri` | +| day_of_month | integer | NO | Day of month for monthly plans (1–28) | + +### Request Example + + + + + +longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 +longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.create_dca("AAPL.US", amount="500", frequency="Monthly", day_of_month=15) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.create_dca("AAPL.US", amount="500", frequency="Monthly", day_of_month=15) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.create_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getCreateDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.create_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.create_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": "1225781523156889601" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_dca_rsp](#create_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_dca_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | true | ID of the newly created plan | diff --git a/docs/zh-HK/docs/account/dca/dca_history.md b/docs/zh-HK/docs/account/dca/dca_history.md new file mode 100644 index 00000000..6d757cbf --- /dev/null +++ b/docs/zh-HK/docs/account/dca/dca_history.md @@ -0,0 +1,252 @@ +--- +slug: dca-history +title: 定期投資交易歷史 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指定定期投資計劃的執行歷史,包含交易日期、金額和價格。 + + +longbridge dca history 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/dca/:id/history
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | +| page | integer | NO | Page number (1-based, default: 1) | +| size | integer | NO | Records per page (default: 20) | + +### Request Example + + + + + +longbridge dca history 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.dca_history("1225781523156889600") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.dca_history("1225781523156889600") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.dca_history() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getDcaHistory().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.dca_history().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.dca_history([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DcaHistory(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "trade_date": "2026-04-08T14:00:00Z", + "symbol": "SPY.US", + "amount": "750", + "price": "548.20", + "quantity": "1.37", + "status": "Filled" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dca_history_rsp](#dca_history_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dca_history_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Trade history records | +| ∟ trade_date | string | true | Trade execution date (ISO 8601) | +| ∟ symbol | string | true | Security symbol | +| ∟ amount | string | true | Invested amount | +| ∟ price | string | false | Execution price | +| ∟ quantity | string | false | Quantity purchased | +| ∟ status | string | true | Trade status: `Filled`, `Failed` | diff --git a/docs/zh-HK/docs/account/dca/delete_dca.md b/docs/zh-HK/docs/account/dca/delete_dca.md new file mode 100644 index 00000000..4479ba25 --- /dev/null +++ b/docs/zh-HK/docs/account/dca/delete_dca.md @@ -0,0 +1,231 @@ +--- +slug: delete-dca +title: 刪除定期投資計劃 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +永久停止並刪除定期投資計劃,此操作不可撤銷。 + + +longbridge dca stop 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/account/dca/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | + +### Request Example + + + + + +longbridge dca stop 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.delete_dca("1225781523156889600") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.delete_dca("1225781523156889600") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.delete_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getDeleteDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.delete_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.delete_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_dca_rsp](#delete_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_dca_rsp + + + +No response body fields. diff --git a/docs/zh-HK/docs/account/dca/list_dca.md b/docs/zh-HK/docs/account/dca/list_dca.md new file mode 100644 index 00000000..ffb15e6a --- /dev/null +++ b/docs/zh-HK/docs/account/dca/list_dca.md @@ -0,0 +1,255 @@ +--- +slug: list-dca +title: 獲取定期投資計劃列表 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取當前用戶的所有定期投資(DCA)計劃。 + + +longbridge dca +longbridge dca --status Active + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/dca
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| status | string | NO | Filter by plan status: `Active`, `Suspended`, `Finished` | +| symbol | string | NO | Filter by security symbol | + +### Request Example + + + + + +longbridge dca +longbridge dca --status Active + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.list_dca() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.list_dca() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.list_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getListDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.list_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.list_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "id": "1225781523156889600", + "symbol": "SPY.US", + "status": "Finished", + "amount": "750", + "frequency": "Fortnightly", + "day_of_week": "Wed", + "next_trade_date": "2026-04-08T14:00:00Z" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_dca_rsp](#list_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_dca_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | DCA plan list | +| ∟ id | string | true | Plan ID | +| ∟ symbol | string | true | Security symbol | +| ∟ status | string | true | Plan status: `Active`, `Suspended`, `Finished` | +| ∟ amount | string | true | Recurring investment amount | +| ∟ frequency | string | true | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | +| ∟ day_of_week | string | false | Day of week for weekly/fortnightly plans | +| ∟ next_trade_date | string | false | Next scheduled trade date (ISO 8601) | diff --git a/docs/zh-HK/docs/account/dca/update_dca.md b/docs/zh-HK/docs/account/dca/update_dca.md new file mode 100644 index 00000000..2672a225 --- /dev/null +++ b/docs/zh-HK/docs/account/dca/update_dca.md @@ -0,0 +1,234 @@ +--- +slug: update-dca +title: 更新定期投資計劃 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +暫停或恢復已有的定期投資計劃。 + + +longbridge dca pause 1225781523156889600 +longbridge dca resume 1225781523156889600 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/dca/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | string | YES | Plan ID (path parameter) | +| action | string | YES | Action to perform: `pause` or `resume` | + +### Request Example + + + + + +longbridge dca pause 1225781523156889600 +longbridge dca resume 1225781523156889600 + + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.update_dca("1225781523156889600", action="pause") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.update_dca("1225781523156889600", action="pause") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.update_dca() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.getUpdateDca().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.update_dca().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::dca; + +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); + DCAContext ctx = DCAContext::create(config); + ctx.update_dca([](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/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateDca(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_dca_rsp](#update_dca_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_dca_rsp + + + +No response body fields. diff --git a/docs/zh-HK/docs/account/portfolio/_category_.json b/docs/zh-HK/docs/account/portfolio/_category_.json new file mode 100644 index 00000000..7cc2901d --- /dev/null +++ b/docs/zh-HK/docs/account/portfolio/_category_.json @@ -0,0 +1 @@ +{ "position": 1, "label": "Portfolio", "collapsed": false } diff --git a/docs/zh-HK/docs/account/portfolio/capital_flow.md b/docs/zh-HK/docs/account/portfolio/capital_flow.md new file mode 100644 index 00000000..3291a532 --- /dev/null +++ b/docs/zh-HK/docs/account/portfolio/capital_flow.md @@ -0,0 +1,259 @@ +--- +slug: capital-flow +title: 資金流水 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +查詢賬戶資金流水歷史,包含入金、出金、分紅和結算等。 + + +longbridge cash-flow +longbridge cash-flow --format json + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/capital_flow
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_time | integer | NO | Start time as Unix timestamp (seconds) | +| end_time | integer | NO | End time as Unix timestamp (seconds) | +| business_type | integer | NO | Business type filter. Omit for all types. | +| symbol | string | NO | Filter by security symbol | +| page | integer | NO | Page number (1-based, default: 1) | +| size | integer | NO | Records per page (default: 20) | + +### Request Example + + + + + +longbridge cash-flow +longbridge cash-flow --format json + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.capital_flow() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.capital_flow() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.capital_flow() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getCapitalFlow().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.capital_flow().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.capital_flow([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CapitalFlow(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "transaction_flow_name": "Cash Dividend", + "direction": 1, + "business_type": 2, + "balance": "25.00", + "currency": "USD", + "business_time": "1774310400", + "symbol": "AAPL.US" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [capital_flow_rsp](#capital_flow_rsp) | +| 400 | Bad request | None | + +## Schemas + +### capital_flow_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Cash flow records | +| ∟ transaction_flow_name | string | true | Flow type description | +| ∟ direction | int32 | true | `1` = inflow, `-1` = outflow | +| ∟ business_type | int32 | true | Business type code | +| ∟ balance | string | true | Amount | +| ∟ currency | string | true | Currency | +| ∟ business_time | string | true | Transaction time as Unix timestamp | +| ∟ symbol | string | false | Associated security symbol | diff --git a/docs/zh-HK/docs/account/portfolio/exchange_rates.md b/docs/zh-HK/docs/account/portfolio/exchange_rates.md new file mode 100644 index 00000000..a8240224 --- /dev/null +++ b/docs/zh-HK/docs/account/portfolio/exchange_rates.md @@ -0,0 +1,246 @@ +--- +slug: exchange-rates +title: 匯率 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取賬戶中所有貨幣對的當前外匯匯率。 + + +longbridge exchange-rate + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/exchange_rates
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| base | string | NO | Base currency, e.g. `USD`. Omit for all pairs. | + +### Request Example + + + + + +longbridge exchange-rate + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.exchange_rates() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.exchange_rates() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.exchange_rates() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getExchangeRates().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.exchange_rates().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.exchange_rates([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ExchangeRates(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "pair": "HKD/USD", + "bid_rate": "0.1284", + "offer_rate": "0.1285", + "average_rate": "0.12845" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [exchange_rates_rsp](#exchange_rates_rsp) | +| 400 | Bad request | None | + +## Schemas + +### exchange_rates_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Exchange rate list | +| ∟ pair | string | true | Currency pair, e.g. `HKD/USD` | +| ∟ bid_rate | string | true | Bid rate | +| ∟ offer_rate | string | true | Offer rate | +| ∟ average_rate | string | true | Average rate | diff --git a/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md new file mode 100644 index 00000000..6a224ccd --- /dev/null +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md @@ -0,0 +1,258 @@ +--- +slug: profit-analysis-by-market +title: 按市場盈虧分析 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取按市場分組的盈虧分析(美股、港股、A 股、新加坡股)。 + + +longbridge profit-analysis --format json +longbridge profit-analysis --start 2026-01-01 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis/by_market
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis --format json +longbridge profit-analysis --start 2026-01-01 + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_by_market() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_by_market() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_by_market() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisByMarket().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_by_market().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_by_market([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisByMarket(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "market": "US", + "pnl": "42000.00", + "pnl_pct": "0.5412", + "market_value": "120000.00", + "currency": "USD" + }, + { + "market": "HK", + "pnl": "5203.00", + "pnl_pct": "0.1832", + "market_value": "28400.00", + "currency": "HKD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_by_market_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | P&L by market list | +| ∟ market | string | true | Market code | +| ∟ pnl | string | true | P&L for this market | +| ∟ pnl_pct | string | true | P&L percentage | +| ∟ market_value | string | false | Market value | +| ∟ currency | string | true | Settlement currency | diff --git a/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md new file mode 100644 index 00000000..c6790ad3 --- /dev/null +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md @@ -0,0 +1,251 @@ +--- +slug: profit-analysis-detail +title: 盈虧分析明細 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指定證券的詳細盈虧分析,包含交易流水和成本分解。 + + +longbridge profit-analysis detail TSLA.US +longbridge profit-analysis detail AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis/detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.US` | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis detail TSLA.US +longbridge profit-analysis detail AAPL.US + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_detail("TSLA.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_detail("TSLA.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_detail() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisDetail().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_detail().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_detail([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisDetail(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "name": "Tesla Inc.", + "pnl": "12450.00", + "pnl_pct": "0.2891", + "cost": "43085.00", + "market_value": "55535.00", + "currency": "USD" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_detail_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| name | string | true | Security name | +| pnl | string | true | Total P&L | +| pnl_pct | string | true | P&L percentage | +| cost | string | true | Total cost basis | +| market_value | string | false | Current market value | +| currency | string | true | Currency | diff --git a/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md new file mode 100644 index 00000000..83f8890e --- /dev/null +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md @@ -0,0 +1,254 @@ +--- +slug: profit-analysis-summary +title: 盈虧分析匯總 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取賬戶盈虧匯總,包含總資產、總盈虧和收益率指標。 + + +longbridge profit-analysis +longbridge profit-analysis --start 2026-01-01 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/account/profit_analysis
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | +| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge profit-analysis +longbridge profit-analysis --start 2026-01-01 + + + + + +```python +from longbridge.openapi import PortfolioContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = PortfolioContext(config) + +resp = ctx.profit_analysis_summary() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncPortfolioContext, 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 = AsyncPortfolioContext.create(config) + + resp = await ctx.profit_analysis_summary() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, PortfolioContext, 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 = PortfolioContext.new(config) + const resp = await ctx.profit_analysis_summary() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.portfolio.*; + +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); + PortfolioContext ctx = PortfolioContext.create(config)) { + var resp = ctx.getProfitAnalysisSummary().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, portfolio::PortfolioContext, 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 = PortfolioContext::new(config); + let resp = ctx.profit_analysis_summary().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::portfolio; + +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); + PortfolioContext ctx = PortfolioContext::create(config); + ctx.profit_analysis_summary([](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/portfolio" +) + +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 := portfolio.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ProfitAnalysisSummary(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "currency": "USD", + "total_asset": "125413.01", + "invest_amount": "76997.11", + "total_pnl": "48415.89", + "simple_yield": "0.6288", + "twr": "0.5841", + "stocks_traded": 12, + "start_date": "2023-12-04", + "end_date": "2026-04-17" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | +| 400 | Bad request | None | + +## Schemas + +### profit_analysis_summary_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| currency | string | true | Settlement currency | +| total_asset | string | true | Total asset value | +| invest_amount | string | true | Total invested amount | +| total_pnl | string | true | Total P&L | +| simple_yield | string | true | Simple yield ratio | +| twr | string | true | Time-weighted return | +| stocks_traded | int32 | true | Number of stocks traded | +| start_date | string | true | Analysis start date | +| end_date | string | true | Analysis end date | diff --git a/docs/zh-HK/docs/account/sharelist/_category_.json b/docs/zh-HK/docs/account/sharelist/_category_.json new file mode 100644 index 00000000..896f0ec1 --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/_category_.json @@ -0,0 +1 @@ +{ "position": 4, "label": "Sharelist", "collapsed": false } diff --git a/docs/zh-HK/docs/account/sharelist/create_sharelist.md b/docs/zh-HK/docs/account/sharelist/create_sharelist.md new file mode 100644 index 00000000..526865a6 --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/create_sharelist.md @@ -0,0 +1,237 @@ +--- +slug: create-sharelist +title: 建立自選列表 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +建立新的社群自選股列表,可選擇預設初始證券。 + + +longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/community/sharelists
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | YES | Sharelist name | +| description | string | NO | Description | +| securities | string[] | NO | Initial list of security symbols, e.g. `["AAPL.US", "NVDA.US"]` | + +### Request Example + + + + + +longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.create_sharelist(name="AI Picks", description="Top AI infrastructure stocks") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.create_sharelist(name="AI Picks", description="Top AI infrastructure stocks") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.create_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getCreateSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.create_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.create_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CreateSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 15922 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [create_sharelist_rsp](#create_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### create_sharelist_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | ID of the newly created sharelist | diff --git a/docs/zh-HK/docs/account/sharelist/delete_sharelist.md b/docs/zh-HK/docs/account/sharelist/delete_sharelist.md new file mode 100644 index 00000000..7aed322a --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/delete_sharelist.md @@ -0,0 +1,231 @@ +--- +slug: delete-sharelist +title: 刪除自選列表 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +永久刪除您建立的自選股列表,此操作不可撤銷。 + + +longbridge sharelist delete 15921 + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/community/sharelists/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Sharelist ID (path parameter) | + +### Request Example + + + + + +longbridge sharelist delete 15921 + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.delete_sharelist(15921) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.delete_sharelist(15921) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.delete_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getDeleteSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.delete_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.delete_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DeleteSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [delete_sharelist_rsp](#delete_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### delete_sharelist_rsp + + + +No response body fields. diff --git a/docs/zh-HK/docs/account/sharelist/list_sharelist.md b/docs/zh-HK/docs/account/sharelist/list_sharelist.md new file mode 100644 index 00000000..a986c389 --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/list_sharelist.md @@ -0,0 +1,254 @@ +--- +slug: list-sharelist +title: 獲取自選列表 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取當前用戶建立的或訂閱的所有社群自選股列表。 + + +longbridge sharelist +longbridge sharelist --format json + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/community/sharelists
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| type | string | NO | Filter: `mine` or `subscribed`. Omit for both. | + +### Request Example + + + + + +longbridge sharelist +longbridge sharelist --format json + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.list_sharelist() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.list_sharelist() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.list_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getListSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.list_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.list_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.ListSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "mine": [ + { + "id": 15921, + "name": "AI Picks", + "type": "Regular", + "day_change": "-0.40", + "ytd_change": "6.64", + "subscribers": 500 + } + ], + "subscribed": [] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [list_sharelist_rsp](#list_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### list_sharelist_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| mine | object[] | true | Sharelists created by the user | +| subscribed | object[] | true | Sharelists subscribed by the user | +| ∟ id | int64 | true | Sharelist ID | +| ∟ name | string | true | Sharelist name | +| ∟ type | string | true | Type: `Regular`, `Official` | +| ∟ day_change | string | false | Day change percentage | +| ∟ ytd_change | string | false | Year-to-date change | +| ∟ subscribers | int32 | false | Subscriber count | diff --git a/docs/zh-HK/docs/account/sharelist/update_sharelist.md b/docs/zh-HK/docs/account/sharelist/update_sharelist.md new file mode 100644 index 00000000..93f9171d --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/update_sharelist.md @@ -0,0 +1,236 @@ +--- +slug: update-sharelist +title: 更新自選列表 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +在自選股列表中新增、移除或重排證券,或對列表重新命名。 + + +longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US +longbridge sharelist remove 15921 AAPL.US + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/community/sharelists/:id
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | YES | Sharelist ID (path parameter) | +| name | string | NO | New name. Omit to keep existing. | +| mode | string | NO | Operation mode for securities: `add`, `remove`, or `replace` | +| securities | string[] | NO | Security symbols affected by the operation | + +### Request Example + + + + + +longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US +longbridge sharelist remove 15921 AAPL.US + + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.update_sharelist(15921, mode="add", securities=["TSLA.US", "NVDA.US"]) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.update_sharelist(15921, mode="add", securities=["TSLA.US", "NVDA.US"]) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.update_sharelist() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.getUpdateSharelist().get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.update_sharelist().await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::sharelist; + +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); + SharelistContext ctx = SharelistContext::create(config); + ctx.update_sharelist([](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/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UpdateSharelist(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [update_sharelist_rsp](#update_sharelist_rsp) | +| 400 | Bad request | None | + +## Schemas + +### update_sharelist_rsp + + + +No response body fields. diff --git a/docs/zh-HK/docs/fundamental/_category_.json b/docs/zh-HK/docs/fundamental/_category_.json new file mode 100644 index 00000000..8aa51261 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/_category_.json @@ -0,0 +1 @@ +{ "position": 5, "label": "Fundamental", "collapsed": false } diff --git a/docs/zh-HK/docs/fundamental/calendar/_category_.json b/docs/zh-HK/docs/fundamental/calendar/_category_.json new file mode 100644 index 00000000..749c348f --- /dev/null +++ b/docs/zh-HK/docs/fundamental/calendar/_category_.json @@ -0,0 +1 @@ +{ "position": 3, "label": "Calendar", "collapsed": false } diff --git a/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md b/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md new file mode 100644 index 00000000..c7313c3b --- /dev/null +++ b/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md @@ -0,0 +1,254 @@ +--- +slug: dividend-calendar +title: 分紅日曆 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取即將到來和歷史分紅事件,包含除息日、派息日和分紅金額。 + + +longbridge finance-calendar dividend +longbridge finance-calendar dividend --filter positions + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/dividends
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar dividend +longbridge finance-calendar dividend --filter positions + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.dividend_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.dividend_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.dividend_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getDividendCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.dividend_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.dividend_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.DividendCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "name": "Apple Inc.", + "ex_date": "2026-05-09", + "pay_date": "2026-05-15", + "amount": "0.25", + "currency": "USD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dividend_calendar_rsp](#dividend_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dividend_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Dividend event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ ex_date | string | true | Ex-dividend date | +| ∟ pay_date | string | false | Payment date | +| ∟ amount | string | true | Dividend amount per share | +| ∟ currency | string | true | Currency | diff --git a/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md b/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md new file mode 100644 index 00000000..664df449 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md @@ -0,0 +1,254 @@ +--- +slug: earnings-calendar +title: 財報日曆 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +瀏覽即將發布的財報及近期業績,包含 EPS 和營收預期。 + + +longbridge finance-calendar report +longbridge finance-calendar report --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/earnings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar report +longbridge finance-calendar report --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.earnings_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.earnings_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.earnings_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getEarningsCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.earnings_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.earnings_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.EarningsCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "name": "Apple Inc.", + "report_date": "2026-04-30", + "eps_estimate": "1.62", + "eps_actual": null, + "revenue_estimate": "94500000000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [earnings_calendar_rsp](#earnings_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### earnings_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Earnings event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ report_date | string | true | Expected report date | +| ∟ eps_estimate | string | false | EPS estimate | +| ∟ eps_actual | string | false | Actual EPS (null if not yet reported) | +| ∟ revenue_estimate | string | false | Revenue estimate | diff --git a/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md b/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md new file mode 100644 index 00000000..a4d7871c --- /dev/null +++ b/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md @@ -0,0 +1,254 @@ +--- +slug: ipo-calendar +title: IPO 日曆 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取即將上市和近期 IPO 資訊,包含預計發行價和上市日期。 + + +longbridge finance-calendar ipo +longbridge finance-calendar ipo --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/ipos
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar ipo +longbridge finance-calendar ipo --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.ipo_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.ipo_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.ipo_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getIpoCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.ipo_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.ipo_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.IpoCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NEWCO.US", + "name": "New Company Inc.", + "listing_date": "2026-05-15", + "offer_price": "18.00", + "currency": "USD", + "market": "US" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ipo_calendar_rsp](#ipo_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ipo_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | IPO event list | +| ∟ symbol | string | false | Security symbol (assigned after listing) | +| ∟ name | string | true | Company name | +| ∟ listing_date | string | true | Expected listing date | +| ∟ offer_price | string | false | IPO offer price | +| ∟ currency | string | false | Currency | +| ∟ market | string | true | Market code | diff --git a/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md b/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md new file mode 100644 index 00000000..f35be62c --- /dev/null +++ b/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md @@ -0,0 +1,256 @@ +--- +slug: macro-calendar +title: 宏觀日曆 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取即將發布的宏觀經濟數據,如 CPI、GDP 和美聯儲會議等。 + + +longbridge finance-calendar macrodata +longbridge finance-calendar macrodata --market US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/macro
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| country | string | NO | Country code: `US`, `CN`, `EU`, `JP`. Omit for global. | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar macrodata +longbridge finance-calendar macrodata --market US + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.macro_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.macro_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.macro_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getMacroCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.macro_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.macro_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.MacroCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "event": "US CPI (YoY)", + "country": "US", + "release_date": "2026-05-13", + "actual": null, + "forecast": "2.4", + "previous": "2.4", + "importance": "High" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [macro_calendar_rsp](#macro_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### macro_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Macro event list | +| ∟ event | string | true | Event name | +| ∟ country | string | true | Country code | +| ∟ release_date | string | true | Release date | +| ∟ actual | string | false | Actual value (null if not yet released) | +| ∟ forecast | string | false | Consensus forecast | +| ∟ previous | string | false | Previous period value | +| ∟ importance | string | false | Importance level: `High`, `Medium`, `Low` | diff --git a/docs/zh-HK/docs/fundamental/calendar/split_calendar.md b/docs/zh-HK/docs/fundamental/calendar/split_calendar.md new file mode 100644 index 00000000..984fde78 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/calendar/split_calendar.md @@ -0,0 +1,252 @@ +--- +slug: split-calendar +title: 拆股日曆 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取即將到來和歷史拆股及合股事件。 + + +longbridge finance-calendar split +longbridge finance-calendar split --market HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/calendar/splits
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market filter | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge finance-calendar split +longbridge finance-calendar split --market HK + + + + + +```python +from longbridge.openapi import CalendarContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.split_calendar("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, 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 = AsyncCalendarContext.create(config) + + resp = await ctx.split_calendar("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, 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 = CalendarContext.new(config) + const resp = await ctx.split_calendar('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +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); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.getSplitCalendar("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::CalendarContext, 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 = CalendarContext::new(config); + let resp = ctx.split_calendar("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::calendar; + +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); + CalendarContext ctx = CalendarContext::create(config); + ctx.split_calendar("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/calendar" +) + +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 := calendar.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.SplitCalendar(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NVDA.US", + "name": "NVIDIA Corp", + "date": "2024-06-10", + "ratio": "10:1", + "type": "Split" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [split_calendar_rsp](#split_calendar_rsp) | +| 400 | Bad request | None | + +## Schemas + +### split_calendar_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Split event list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Company name | +| ∟ date | string | true | Effective date | +| ∟ ratio | string | true | Split ratio, e.g. `10:1` | +| ∟ type | string | true | `Split` or `ReverseSplit` | diff --git a/docs/zh-HK/docs/fundamental/fundamental/_category_.json b/docs/zh-HK/docs/fundamental/fundamental/_category_.json new file mode 100644 index 00000000..1e080d05 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/_category_.json @@ -0,0 +1 @@ +{ "position": 1, "label": "Fundamentals", "collapsed": false } diff --git a/docs/zh-HK/docs/fundamental/fundamental/company_profile.md b/docs/zh-HK/docs/fundamental/fundamental/company_profile.md new file mode 100644 index 00000000..115f7584 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/company_profile.md @@ -0,0 +1,249 @@ +--- +slug: company-profile +title: 公司概況 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取公司基本資料,包括成立年份、員工人數、總部地址和業務描述。 + + +longbridge company TSLA.US +longbridge company AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/company_profile
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge company TSLA.US +longbridge company AAPL.US + + + + + +```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.company_profile("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.company_profile("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.company_profile('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.getCompanyProfile("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.company_profile("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.company_profile("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.CompanyProfile(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "name": "Apple Inc.", + "symbol": "AAPL.US", + "founded": "1976", + "ceo": "Timothy D. Cook", + "employees": 166000, + "website": "www.apple.com", + "description": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide." + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [company_profile_rsp](#company_profile_rsp) | +| 400 | Bad request | None | + +## Schemas + +### company_profile_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| name | string | true | Company name | +| symbol | string | true | Security symbol | +| founded | string | false | Founding year | +| ceo | string | false | Current CEO | +| employees | int32 | false | Number of employees | +| website | string | false | Company website | +| description | string | false | Business description | diff --git a/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md b/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md new file mode 100644 index 00000000..519ff22d --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md @@ -0,0 +1,250 @@ +--- +slug: corporate-actions +title: 公司行動 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指定證券的公司行動歷史,包括拆股、合併、分拆和配股等。 + + +longbridge corp-action TSLA.US +longbridge corp-action AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/corporate_actions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge corp-action TSLA.US +longbridge corp-action AAPL.US + + + + + +```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.corporate_actions("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.corporate_actions("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.corporate_actions('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.getCorporateActions("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.corporate_actions("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.corporate_actions("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.CorporateActions(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "type": "Split", + "date": "2020-08-31", + "ratio": "4:1", + "description": "4-for-1 stock split" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [corporate_actions_rsp](#corporate_actions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### corporate_actions_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Corporate action list | +| ∟ type | string | true | Action type: `Split`, `Merger`, `Spinoff`, `Rights` | +| ∟ date | string | true | Effective date | +| ∟ ratio | string | false | Split/merge ratio | +| ∟ description | string | false | Action description | diff --git a/docs/zh-HK/docs/fundamental/fundamental/dividends.md b/docs/zh-HK/docs/fundamental/fundamental/dividends.md new file mode 100644 index 00000000..e559bb33 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/dividends.md @@ -0,0 +1,252 @@ +--- +slug: dividends +title: 分紅歷史 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指定證券的分紅歷史及即將公布的分紅資訊。 + + +longbridge dividend TSLA.US +longbridge dividend AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/dividends
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| start_date | string | NO | Start date in `YYYY-MM-DD` format | +| end_date | string | NO | End date in `YYYY-MM-DD` format | + +### Request Example + + + + + +longbridge dividend TSLA.US +longbridge dividend AAPL.US + + + + + +```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.dividends("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.dividends("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.dividends('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.getDividends("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.dividends("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.dividends("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.Dividends(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "ex_date": "2026-02-07", + "pay_date": "2026-02-13", + "amount": "0.25", + "currency": "USD", + "type": "Cash" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [dividends_rsp](#dividends_rsp) | +| 400 | Bad request | None | + +## Schemas + +### dividends_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Dividend records | +| ∟ ex_date | string | true | Ex-dividend date | +| ∟ pay_date | string | false | Payment date | +| ∟ amount | string | true | Dividend amount per share | +| ∟ currency | string | true | Currency | +| ∟ type | string | true | Dividend type, e.g. `Cash`, `Stock` | diff --git a/docs/zh-HK/docs/fundamental/fundamental/executives.md b/docs/zh-HK/docs/fundamental/fundamental/executives.md new file mode 100644 index 00000000..8221f35d --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/executives.md @@ -0,0 +1,248 @@ +--- +slug: executives +title: 高管團隊 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取公司關鍵高管列表(CEO、CFO 等)。 + + +longbridge executive TSLA.US +longbridge executive AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/executives
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge executive TSLA.US +longbridge executive AAPL.US + + + + + +```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.executives("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.executives("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.executives('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.getExecutives("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.executives("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.executives("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.Executives(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "name": "Timothy D. Cook", + "title": "Chief Executive Officer", + "age": 63, + "since": "2011" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [executives_rsp](#executives_rsp) | +| 400 | Bad request | None | + +## Schemas + +### executives_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Executive list | +| ∟ name | string | true | Executive name | +| ∟ title | string | true | Job title | +| ∟ age | int32 | false | Age | +| ∟ since | string | false | Year appointed | diff --git a/docs/zh-HK/docs/fundamental/fundamental/financial_report.md b/docs/zh-HK/docs/fundamental/fundamental/financial_report.md new file mode 100644 index 00000000..67581315 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/financial_report.md @@ -0,0 +1,254 @@ +--- +slug: financial-report +title: 財務報告 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取任意上市公司的利潤表、資產負債表和現金流量表。 + + +longbridge financial-report TSLA.US --kind IS +longbridge financial-report AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/financial_reports
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| kind | string | NO | Statement type: `IS` (income), `BS` (balance sheet), `CF` (cash flow), `ALL` (default) | +| report | string | NO | Reporting period: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | + +### Request Example + + + + + +longbridge financial-report TSLA.US --kind IS +longbridge financial-report AAPL.US + + + + + +```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("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.financial_report("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.financial_report('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.getFinancialReport("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.financial_report("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.financial_report("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.FinancialReport(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "type": "IS", + "period": "Q4 2025", + "eps": "0.24", + "revenue": "24900000000", + "net_income": "840000000", + "gross_margin": "0.2012" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [financial_report_rsp](#financial_report_rsp) | +| 400 | Bad request | None | + +## Schemas + +### financial_report_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of financial statement records | +| ∟ type | string | true | Statement type: `IS`, `BS`, `CF` | +| ∟ period | string | true | Reporting period label | +| ∟ eps | string | false | Earnings per share | +| ∟ revenue | string | false | Total revenue | +| ∟ net_income | string | false | Net income | +| ∟ gross_margin | string | false | Gross margin ratio | diff --git a/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md b/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md new file mode 100644 index 00000000..6be61d22 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md @@ -0,0 +1,248 @@ +--- +slug: fund-holdings +title: 基金持倉 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取持有指定證券的基金列表,含持股數量和持股比例。 + + +longbridge fund-holder TSLA.US +longbridge fund-holder AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/fund_holdings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge fund-holder TSLA.US +longbridge fund-holder AAPL.US + + + + + +```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.fund_holdings("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.fund_holdings("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.fund_holdings('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.getFundHoldings("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.fund_holdings("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.fund_holdings("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.FundHoldings(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "fund_name": "Vanguard Total Stock Market ETF", + "shares": "289000000", + "percentage": "1.88", + "date": "2026-03-31" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [fund_holdings_rsp](#fund_holdings_rsp) | +| 400 | Bad request | None | + +## Schemas + +### fund_holdings_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Fund holder list | +| ∟ fund_name | string | true | Fund name | +| ∟ shares | string | true | Number of shares held | +| ∟ percentage | string | true | Ownership percentage | +| ∟ date | string | false | Report date | diff --git a/docs/zh-HK/docs/fundamental/fundamental/ratings.md b/docs/zh-HK/docs/fundamental/fundamental/ratings.md new file mode 100644 index 00000000..42510fff --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/ratings.md @@ -0,0 +1,250 @@ +--- +slug: ratings +title: 分析師評級 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指定證券的機構分析師評級和一致預期數據。 + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/ratings
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + + +```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.ratings("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.ratings("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.ratings('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.getRatings("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.ratings("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.ratings("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.Ratings(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "broker_name": "Goldman Sachs", + "rating": "Buy", + "target_price": "230.00", + "currency": "USD", + "date": "2026-01-10" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ratings_rsp](#ratings_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ratings_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of analyst ratings | +| ∟ broker_name | string | true | Institution name | +| ∟ rating | string | true | Rating: `Buy`, `Hold`, `Sell` | +| ∟ target_price | string | false | Target price | +| ∟ currency | string | false | Currency | +| ∟ date | string | true | Rating date in `YYYY-MM-DD` format | diff --git a/docs/zh-HK/docs/fundamental/fundamental/shareholders.md b/docs/zh-HK/docs/fundamental/fundamental/shareholders.md new file mode 100644 index 00000000..de16a358 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/shareholders.md @@ -0,0 +1,248 @@ +--- +slug: shareholders +title: 主要股東 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取公司主要機構股東和個人股東信息。 + + +longbridge shareholder TSLA.US +longbridge shareholder AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/shareholders
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | + +### Request Example + + + + + +longbridge shareholder TSLA.US +longbridge shareholder AAPL.US + + + + + +```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.shareholders("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.shareholders("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.shareholders('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.getShareholders("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.shareholders("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.shareholders("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.Shareholders(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "name": "The Vanguard Group", + "shares": "1236787000", + "percentage": "8.04", + "type": "Institution" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [shareholders_rsp](#shareholders_rsp) | +| 400 | Bad request | None | + +## Schemas + +### shareholders_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Shareholder list | +| ∟ name | string | true | Shareholder name | +| ∟ shares | string | true | Number of shares held | +| ∟ percentage | string | true | Ownership percentage | +| ∟ type | string | false | `Institution` or `Individual` | diff --git a/docs/zh-HK/docs/fundamental/fundamental/valuations.md b/docs/zh-HK/docs/fundamental/fundamental/valuations.md new file mode 100644 index 00000000..0453fa76 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/valuations.md @@ -0,0 +1,246 @@ +--- +slug: valuations +title: 估值指標 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取當前估值指標(市盈率、市淨率、市銷率、股息率)及 5 年歷史區間數據。 + + +longbridge valuation TSLA.US --indicator pe +longbridge valuation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/valuations
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| indicator | string | NO | Indicator filter: `pe`, `pb`, `ps`, `dvd_yld` | + +### Request Example + + + + + +longbridge valuation TSLA.US --indicator pe +longbridge valuation AAPL.US + + + + + +```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.valuations("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.valuations("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.valuations('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.getValuations("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.valuations("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.valuations("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.Valuations(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "metrics": { + "pe": { "current": "29.5", "high": "35.2", "low": "18.0", "median": "26.0" }, + "pb": { "current": "45.1", "high": "50.0", "low": "30.0", "median": "42.0" } + } + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [valuations_rsp](#valuations_rsp) | +| 400 | Bad request | None | + +## Schemas + +### valuations_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| metrics | object | true | Valuation metrics map | +| ∟ pe | object | false | P/E ratio data | +| ∟∟ current | string | true | Current value | +| ∟∟ high | string | true | 5-year high | +| ∟∟ low | string | true | 5-year low | +| ∟∟ median | string | true | 5-year median | diff --git a/docs/zh-HK/docs/fundamental/market/_category_.json b/docs/zh-HK/docs/fundamental/market/_category_.json new file mode 100644 index 00000000..d98f6649 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/_category_.json @@ -0,0 +1 @@ +{ "position": 2, "label": "Market", "collapsed": false } diff --git a/docs/zh-HK/docs/fundamental/market/ah_premium.md b/docs/zh-HK/docs/fundamental/market/ah_premium.md new file mode 100644 index 00000000..d07ef63d --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/ah_premium.md @@ -0,0 +1,250 @@ +--- +slug: ah-premium +title: A/H 溢價 +sidebar_position: 3 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取 A+H 兩地上市股票的 A/H 溢價比率,對比 A 股和 H 股價格。 + + +longbridge ah-premium 939.HK +longbridge ah-premium 0939.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/ah_premium
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | H-share symbol of a dual-listed stock, e.g. `939.HK` | + +### Request Example + + + + + +longbridge ah-premium 939.HK +longbridge ah-premium 0939.HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.ah_premium("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.ah_premium("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.ah_premium('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getAhPremium("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.ah_premium("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.ah_premium("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.AhPremium(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "date": "2026-04-08", + "a_price": "9.28", + "h_price": "6.70", + "premium": "1.0847", + "fx_rate": "0.8947" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ah_premium_rsp](#ah_premium_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ah_premium_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | A/H premium records | +| ∟ date | string | true | Date in `YYYY-MM-DD` format | +| ∟ a_price | string | true | A-share price in CNY | +| ∟ h_price | string | true | H-share price in HKD | +| ∟ premium | string | true | A/H premium ratio | +| ∟ fx_rate | string | true | CNH/HKD exchange rate | diff --git a/docs/zh-HK/docs/fundamental/market/broker_positions.md b/docs/zh-HK/docs/fundamental/market/broker_positions.md new file mode 100644 index 00000000..6c21bb6b --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/broker_positions.md @@ -0,0 +1,252 @@ +--- +slug: broker-positions +title: 經紀商持倉 +sidebar_position: 2 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +查看港股券商持倉情況,包含主要買賣方和詳細持倉列表。 + + +longbridge broker-holding 700.HK +longbridge broker-holding 9988.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_positions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | HK security symbol, e.g. `700.HK` | + +### Request Example + + + + + +longbridge broker-holding 700.HK +longbridge broker-holding 9988.HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_positions("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_positions("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.broker_positions('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerPositions("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_positions("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.broker_positions("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerPositions(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "updated_at": "1774310400", + "participants": [ + { + "broker_id": 1234, + "broker_name": "HSBC Securities", + "buy_qty": "100000", + "sell_qty": "80000", + "net_qty": "20000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [broker_positions_rsp](#broker_positions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### broker_positions_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| updated_at | string | true | Last updated Unix timestamp | +| participants | object[] | true | Broker position list | +| ∟ broker_id | int32 | true | Broker ID | +| ∟ broker_name | string | true | Broker name | +| ∟ buy_qty | string | true | Buy quantity | +| ∟ sell_qty | string | true | Sell quantity | +| ∟ net_qty | string | true | Net quantity (buy - sell) | diff --git a/docs/zh-HK/docs/fundamental/market/index_components.md b/docs/zh-HK/docs/fundamental/market/index_components.md new file mode 100644 index 00000000..00bae998 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/index_components.md @@ -0,0 +1,256 @@ +--- +slug: index-components +title: 指數成分股 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指數或 ETF 的成分股列表,支持排序並顯示漲跌統計。 + + +longbridge constituent HSI.HK +longbridge constituent SPY.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/index_components
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Index or ETF symbol, e.g. `HSI.HK`, `SPY.US` | + +### Request Example + + + + + +longbridge constituent HSI.HK +longbridge constituent SPY.US + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.index_components("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.index_components("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.index_components('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getIndexComponents("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.index_components("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.index_components("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.IndexComponents(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "total": 90, + "rise": 45, + "fall": 42, + "flat": 3, + "components": [ + { + "symbol": "HSBC.HK", + "name": "HSBC Holdings", + "price": "68.40", + "change_pct": "0.88" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [index_components_rsp](#index_components_rsp) | +| 400 | Bad request | None | + +## Schemas + +### index_components_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| total | int32 | true | Total number of components | +| rise | int32 | true | Number of rising components | +| fall | int32 | true | Number of falling components | +| flat | int32 | true | Number of flat components | +| components | object[] | true | Component list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Security name | +| ∟ price | string | false | Current price | +| ∟ change_pct | string | false | Percentage change | diff --git a/docs/zh-HK/docs/fundamental/market/market_status.md b/docs/zh-HK/docs/fundamental/market/market_status.md new file mode 100644 index 00000000..5158ee1e --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/market_status.md @@ -0,0 +1,249 @@ +--- +slug: market-status +title: 市場狀態 +sidebar_position: 1 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取各交易所當前的開市/收市狀態。 + + +longbridge market-status + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/status
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | NO | Market code: `US`, `HK`, `SH`, `SZ`, `SG`. Omit for all markets. | + +### Request Example + + + + + +longbridge market-status + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.market_status("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.market_status("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.market_status('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getMarketStatus("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.market_status("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.market_status("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.MarketStatus(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "market": "US", + "status": "normal_trading", + "trade_session": "Regular" + }, + { + "market": "HK", + "status": "closed", + "trade_session": "Closed" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [market_status_rsp](#market_status_rsp) | +| 400 | Bad request | None | + +## Schemas + +### market_status_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Market status list | +| ∟ market | string | true | Market code | +| ∟ status | string | true | Status: `normal_trading`, `closed`, `pre_trading`, `after_trading` | +| ∟ trade_session | string | false | Current trading session | diff --git a/docs/zh-HK/docs/fundamental/market/trading_stats.md b/docs/zh-HK/docs/fundamental/market/trading_stats.md new file mode 100644 index 00000000..4b3b0c7a --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/trading_stats.md @@ -0,0 +1,252 @@ +--- +slug: trading-stats +title: 成交統計 +sidebar_position: 4 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取指定證券的成交統計數據,展示成交量的價格分佈。 + + +longbridge trade-stats 700.HK +longbridge trade-stats TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/trading_stats
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `700.HK` | + +### Request Example + + + + + +longbridge trade-stats 700.HK +longbridge trade-stats TSLA.US + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.trading_stats("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.trading_stats("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.trading_stats('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getTradingStats("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.trading_stats("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.trading_stats("AAPL.US", [](auto resp) { + if (resp) std::cout << "OK" << std::endl; + }); + }); + std::cin.get(); +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.TradingStats(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "prev_close": "504.500", + "avg_price": "491.63", + "trades": 32782, + "volume": "15200000", + "turnover": "7382000000", + "distribution": [ + { "price": "490.00", "volume": "1200000", "pct": "7.89" } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [trading_stats_rsp](#trading_stats_rsp) | +| 400 | Bad request | None | + +## Schemas + +### trading_stats_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| prev_close | string | true | Previous close price | +| avg_price | string | true | Average trading price | +| trades | int32 | true | Number of trades | +| volume | string | true | Total volume | +| turnover | string | true | Total turnover | +| distribution | object[] | true | Price-volume distribution | +| ∟ price | string | true | Price level | +| ∟ volume | string | true | Volume at this price | +| ∟ pct | string | true | Percentage of total volume | diff --git a/docs/zh-HK/docs/fundamental/market/unusual_items.md b/docs/zh-HK/docs/fundamental/market/unusual_items.md new file mode 100644 index 00000000..1907b18a --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/unusual_items.md @@ -0,0 +1,250 @@ +--- +slug: unusual-items +title: 異動行情 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +識別市場異動,包括價格異常波動、成交量激增等非正常交易行為。 + + +longbridge anomaly --market US +longbridge anomaly --market HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/unusual_items
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| market | string | YES | Market code: `US`, `HK`, `SH`, `SZ`, `SG` | + +### Request Example + + + + + +longbridge anomaly --market US +longbridge anomaly --market HK + + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.unusual_items("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.unusual_items("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.unusual_items('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getUnusualItems("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.unusual_items("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::market; + +int main() { + OAuthBuilder("your-client-id").build( + [](const std::string& url) { std::cout << "Open: " << url << std::endl; }, + [](auto res) { + if (!res) return; + Config config = Config::from_oauth(*res); + MarketContext ctx = MarketContext::create(config); + ctx.unusual_items("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/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.UnusualItems(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "NVDA.US", + "name": "NVIDIA Corp", + "alert": "Volume surge", + "emotion": "Bullish", + "time": "1774310400" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [unusual_items_rsp](#unusual_items_rsp) | +| 400 | Bad request | None | + +## Schemas + +### unusual_items_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | Unusual item list | +| ∟ symbol | string | true | Security symbol | +| ∟ name | string | true | Security name | +| ∟ alert | string | true | Alert description | +| ∟ emotion | string | false | Market sentiment: `Bullish`, `Bearish` | +| ∟ time | string | true | Alert time as Unix timestamp | diff --git a/docs/zh-HK/docs/quote/individual/update_pinned.md b/docs/zh-HK/docs/quote/individual/update_pinned.md new file mode 100644 index 00000000..bcce3af7 --- /dev/null +++ b/docs/zh-HK/docs/quote/individual/update_pinned.md @@ -0,0 +1,210 @@ +--- +slug: update-pinned +title: 更新置頂證券 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +在自選股分組中置頂或取消置頂指定證券,以控制顯示順序。 + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/watchlist/groups
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| --------- | ------ | -------- | -------------------------------------------------------- | +| id | string | YES | Watchlist group ID | +| symbol | string | YES | Security symbol to pin or unpin, e.g. `AAPL.US` | +| is_pinned | bool | YES | Set to `true` to pin the security, `false` to unpin it | + +### Request Example + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + await ctx.update_pinned(group_id="2630", symbol="AAPL.US", is_pinned=True) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + await ctx.updatePinned('2630', 'AAPL.US', true) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + ctx.updatePinned("2630", "AAPL.US", true).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + ctx.update_pinned("2630", "AAPL.US", true).await?; + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.update_pinned("2630", "AAPL.US", true, [](auto) {}); + }); + 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + if err := qctx.UpdatePinned(context.Background(), "2630", "AAPL.US", true); err != nil { + log.Fatal(err) + } + fmt.Println("OK") +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": {} +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | + +## Schemas + +No response schemas. The endpoint returns an empty `data` object on success. diff --git a/docs/zh-HK/docs/quote/pull/option_volume.md b/docs/zh-HK/docs/quote/pull/option_volume.md new file mode 100644 index 00000000..6c3dfdaf --- /dev/null +++ b/docs/zh-HK/docs/quote/pull/option_volume.md @@ -0,0 +1,249 @@ +--- +slug: option-volume +title: 期權成交量 +sidebar_position: 26 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取今日認購/認沽期權成交量快照,包含總量、未平倉量和認沽/認購比率。 + + +longbridge option volume AAPL.US +longbridge option volume TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/option_volume
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------ | -------- | ---------------------------------------------- | +| symbol | string | YES | US stock symbol, e.g. `AAPL.US`, `TSLA.US` | + +### Request Example + + + + + +longbridge option volume AAPL.US +longbridge option volume TSLA.US + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.option_volume("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.option_volume("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.optionVolume('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getOptionVolume("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.option_volume("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.option_volume("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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.OptionVolume(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "call_volume": 284512, + "put_volume": 195830, + "call_open_interest": 1824500, + "put_open_interest": 1532100, + "pc_vol": "0.6886", + "pc_oi": "0.8398" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [option_volume_rsp](#option_volume_rsp) | +| 400 | Bad request | None | + +## Schemas + +### option_volume_rsp + + + +| Name | Type | Required | Description | +| ------------------ | ------ | -------- | ---------------------------------------- | +| symbol | string | true | Security symbol | +| call_volume | int64 | true | Total call volume for today | +| put_volume | int64 | true | Total put volume for today | +| call_open_interest | int64 | true | Total call open interest | +| put_open_interest | int64 | true | Total put open interest | +| pc_vol | string | true | Put/call volume ratio | +| pc_oi | string | true | Put/call open interest ratio | diff --git a/docs/zh-HK/docs/quote/pull/option_volume_daily.md b/docs/zh-HK/docs/quote/pull/option_volume_daily.md new file mode 100644 index 00000000..ff5a71ff --- /dev/null +++ b/docs/zh-HK/docs/quote/pull/option_volume_daily.md @@ -0,0 +1,257 @@ +--- +slug: option-volume-daily +title: 期權歷史成交量 +sidebar_position: 27 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取美股期權的歷史每日認購/認沽成交量和未平倉量數據。 + + +longbridge option volume daily AAPL.US +longbridge option volume daily TSLA.US --count 60 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/option_volume_daily
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------- | -------- | -------------------------------------------------- | +| symbol | string | YES | US stock symbol, e.g. `AAPL.US`, `TSLA.US` | +| count | integer | NO | Number of trading days to return (default: 20) | + +### Request Example + + + + + +longbridge option volume daily AAPL.US +longbridge option volume daily TSLA.US --count 60 + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.option_volume_daily("AAPL.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.option_volume_daily("AAPL.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.optionVolumeDaily('AAPL.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getOptionVolumeDaily("AAPL.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.option_volume_daily("AAPL.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.option_volume_daily("AAPL.US", [](auto resp) { + if (resp) std::cout << resp->size() << 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.OptionVolumeDaily(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "date": "2026-05-07", + "call_volume": 284512, + "put_volume": 195830, + "call_open_interest": 1824500, + "put_open_interest": 1532100, + "pc_vol": "0.6886", + "pc_oi": "0.8398" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [option_volume_daily_rsp](#option_volume_daily_rsp) | +| 400 | Bad request | None | + +## Schemas + +### option_volume_daily_rsp + + + +| Name | Type | Required | Description | +| ------------------ | -------- | -------- | ---------------------------------------- | +| symbol | string | true | Security symbol | +| list | object[] | true | Daily volume records | +| ∟ date | string | true | Date in `YYYY-MM-DD` format | +| ∟ call_volume | int64 | true | Call volume on that day | +| ∟ put_volume | int64 | true | Put volume on that day | +| ∟ call_open_interest | int64 | true | Call open interest | +| ∟ put_open_interest | int64 | true | Put open interest | +| ∟ pc_vol | string | true | Put/call volume ratio | +| ∟ pc_oi | string | true | Put/call open interest ratio | diff --git a/docs/zh-HK/docs/quote/pull/short_positions.md b/docs/zh-HK/docs/quote/pull/short_positions.md new file mode 100644 index 00000000..a0486057 --- /dev/null +++ b/docs/zh-HK/docs/quote/pull/short_positions.md @@ -0,0 +1,253 @@ +--- +slug: short-positions +title: 做空數據 +sidebar_position: 25 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get US stock short selling data — short interest, short ratio, days to cover, and average daily volume. Records are updated bi-monthly by FINRA. Only US-listed stocks and ETFs are supported. + + +longbridge short-positions TSLA.US +longbridge short-positions AAPL.US --count 50 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/short_positions
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ------ | ------ | -------- | --------------------------------------------------- | +| symbol | string | YES | US security symbol, e.g. `TSLA.US`, `AAPL.US` | +| count | integer | NO | Number of records to return (1–100, default: 20) | + +### Request Example + + + + + +longbridge short-positions TSLA.US +longbridge short-positions AAPL.US --count 50 + + + + + +```python +from longbridge.openapi import QuoteContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = QuoteContext(config) + +resp = ctx.short_positions("TSLA.US") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config) + + resp = await ctx.short_positions("TSLA.US") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, QuoteContext, 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 = QuoteContext.new(config) + const resp = await ctx.shortPositions('TSLA.US') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.quote.*; + +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); + QuoteContext ctx = QuoteContext.create(config)) { + var resp = ctx.getShortPositions("TSLA.US").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config); + let resp = ctx.short_positions("TSLA.US").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```cpp +#include +#include + +using namespace longbridge; +using namespace longbridge::quote; + +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); + QuoteContext ctx = QuoteContext::create(config); + ctx.short_positions("TSLA.US", [](auto resp) { + if (resp) std::cout << resp->size() << 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/quote" +) + +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) + } + qctx, err := quote.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer qctx.Close() + resp, err := qctx.ShortPositions(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "date": "2026-03-31", + "rate": "0.0175", + "short_shares": "65598603", + "avg_daily_vol": "62121644", + "days_cover": "1.06", + "close": "371.750" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [short_positions_rsp](#short_positions_rsp) | +| 400 | Bad request | None | + +## Schemas + +### short_positions_rsp + + + +| Name | Type | Required | Description | +| ------------- | -------- | -------- | ------------------------------------------------ | +| list | object[] | true | Short position records | +| ∟ date | string | true | Settlement date in `YYYY-MM-DD` format | +| ∟ rate | string | true | Short ratio (short shares ÷ float) | +| ∟ short_shares | string | true | Number of short shares | +| ∟ avg_daily_vol | string | true | Average daily volume | +| ∟ days_cover | string | true | Days-to-cover ratio (short shares ÷ avg daily vol) | +| ∟ close | string | true | Closing price on that date | From 4609f73895b861b436b7dadd606b585ce41d0abf Mon Sep 17 00:00:00 2001 From: Endless Agent Date: Fri, 8 May 2026 06:58:35 +0000 Subject: [PATCH 02/18] feat(final): task #11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 任务:将 openapi commit 523035611 新增的 SDK 接口同步到 developers 文档站 你的任务是将 openapi 仓库 commit `523035611c81 🤖 Generated with Endless Co-authored-by: 老袁 Yuan Zhanghong --- docs/en/docs/account/_category_.json | 8 +++++++- docs/en/docs/account/alert/_category_.json | 8 +++++++- docs/en/docs/account/dca/_category_.json | 8 +++++++- docs/en/docs/account/portfolio/_category_.json | 8 +++++++- docs/en/docs/account/sharelist/_category_.json | 8 +++++++- docs/en/docs/fundamental/_category_.json | 8 +++++++- docs/en/docs/fundamental/calendar/_category_.json | 8 +++++++- docs/en/docs/fundamental/fundamental/_category_.json | 8 +++++++- docs/en/docs/fundamental/market/_category_.json | 8 +++++++- docs/zh-CN/docs/account/_category_.json | 8 +++++++- docs/zh-CN/docs/account/alert/_category_.json | 8 +++++++- docs/zh-CN/docs/account/dca/_category_.json | 8 +++++++- docs/zh-CN/docs/account/portfolio/_category_.json | 8 +++++++- docs/zh-CN/docs/account/sharelist/_category_.json | 8 +++++++- docs/zh-CN/docs/fundamental/_category_.json | 8 +++++++- docs/zh-CN/docs/fundamental/calendar/_category_.json | 8 +++++++- docs/zh-CN/docs/fundamental/fundamental/_category_.json | 8 +++++++- docs/zh-CN/docs/fundamental/market/_category_.json | 8 +++++++- docs/zh-HK/docs/account/_category_.json | 8 +++++++- docs/zh-HK/docs/account/alert/_category_.json | 8 +++++++- docs/zh-HK/docs/account/dca/_category_.json | 8 +++++++- docs/zh-HK/docs/account/portfolio/_category_.json | 8 +++++++- docs/zh-HK/docs/account/sharelist/_category_.json | 8 +++++++- docs/zh-HK/docs/fundamental/_category_.json | 8 +++++++- docs/zh-HK/docs/fundamental/calendar/_category_.json | 8 +++++++- docs/zh-HK/docs/fundamental/fundamental/_category_.json | 8 +++++++- docs/zh-HK/docs/fundamental/market/_category_.json | 8 +++++++- 27 files changed, 189 insertions(+), 27 deletions(-) diff --git a/docs/en/docs/account/_category_.json b/docs/en/docs/account/_category_.json index 02325a35..bf207e04 100644 --- a/docs/en/docs/account/_category_.json +++ b/docs/en/docs/account/_category_.json @@ -1 +1,7 @@ -{ "position": 6, "label": "Account", "collapsed": false } +{ + "position": 6, + "label": "Account", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/account/alert/_category_.json b/docs/en/docs/account/alert/_category_.json index 6722410e..52c74c85 100644 --- a/docs/en/docs/account/alert/_category_.json +++ b/docs/en/docs/account/alert/_category_.json @@ -1 +1,7 @@ -{ "position": 2, "label": "Alerts", "collapsed": false } +{ + "position": 2, + "label": "Alerts", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/account/dca/_category_.json b/docs/en/docs/account/dca/_category_.json index 3d43361f..fc867080 100644 --- a/docs/en/docs/account/dca/_category_.json +++ b/docs/en/docs/account/dca/_category_.json @@ -1 +1,7 @@ -{ "position": 3, "label": "DCA", "collapsed": false } +{ + "position": 3, + "label": "DCA", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/account/portfolio/_category_.json b/docs/en/docs/account/portfolio/_category_.json index 7cc2901d..535297bd 100644 --- a/docs/en/docs/account/portfolio/_category_.json +++ b/docs/en/docs/account/portfolio/_category_.json @@ -1 +1,7 @@ -{ "position": 1, "label": "Portfolio", "collapsed": false } +{ + "position": 1, + "label": "Portfolio", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/account/sharelist/_category_.json b/docs/en/docs/account/sharelist/_category_.json index 896f0ec1..d1743b0e 100644 --- a/docs/en/docs/account/sharelist/_category_.json +++ b/docs/en/docs/account/sharelist/_category_.json @@ -1 +1,7 @@ -{ "position": 4, "label": "Sharelist", "collapsed": false } +{ + "position": 4, + "label": "Sharelist", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/fundamental/_category_.json b/docs/en/docs/fundamental/_category_.json index 8aa51261..9bbf73f8 100644 --- a/docs/en/docs/fundamental/_category_.json +++ b/docs/en/docs/fundamental/_category_.json @@ -1 +1,7 @@ -{ "position": 5, "label": "Fundamental", "collapsed": false } +{ + "position": 5, + "label": "Fundamental", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/fundamental/calendar/_category_.json b/docs/en/docs/fundamental/calendar/_category_.json index 749c348f..d16b100a 100644 --- a/docs/en/docs/fundamental/calendar/_category_.json +++ b/docs/en/docs/fundamental/calendar/_category_.json @@ -1 +1,7 @@ -{ "position": 3, "label": "Calendar", "collapsed": false } +{ + "position": 3, + "label": "Calendar", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/fundamental/fundamental/_category_.json b/docs/en/docs/fundamental/fundamental/_category_.json index 1e080d05..32971e2a 100644 --- a/docs/en/docs/fundamental/fundamental/_category_.json +++ b/docs/en/docs/fundamental/fundamental/_category_.json @@ -1 +1,7 @@ -{ "position": 1, "label": "Fundamentals", "collapsed": false } +{ + "position": 1, + "label": "Fundamentals", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/en/docs/fundamental/market/_category_.json b/docs/en/docs/fundamental/market/_category_.json index d98f6649..84636e61 100644 --- a/docs/en/docs/fundamental/market/_category_.json +++ b/docs/en/docs/fundamental/market/_category_.json @@ -1 +1,7 @@ -{ "position": 2, "label": "Market", "collapsed": false } +{ + "position": 2, + "label": "Market", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/account/_category_.json b/docs/zh-CN/docs/account/_category_.json index 02325a35..26a866af 100644 --- a/docs/zh-CN/docs/account/_category_.json +++ b/docs/zh-CN/docs/account/_category_.json @@ -1 +1,7 @@ -{ "position": 6, "label": "Account", "collapsed": false } +{ + "position": 6, + "label": "账户", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/account/alert/_category_.json b/docs/zh-CN/docs/account/alert/_category_.json index 6722410e..cb05264d 100644 --- a/docs/zh-CN/docs/account/alert/_category_.json +++ b/docs/zh-CN/docs/account/alert/_category_.json @@ -1 +1,7 @@ -{ "position": 2, "label": "Alerts", "collapsed": false } +{ + "position": 2, + "label": "价格提醒", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/account/dca/_category_.json b/docs/zh-CN/docs/account/dca/_category_.json index 3d43361f..8c756ffd 100644 --- a/docs/zh-CN/docs/account/dca/_category_.json +++ b/docs/zh-CN/docs/account/dca/_category_.json @@ -1 +1,7 @@ -{ "position": 3, "label": "DCA", "collapsed": false } +{ + "position": 3, + "label": "定投计划", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/account/portfolio/_category_.json b/docs/zh-CN/docs/account/portfolio/_category_.json index 7cc2901d..a9617cb4 100644 --- a/docs/zh-CN/docs/account/portfolio/_category_.json +++ b/docs/zh-CN/docs/account/portfolio/_category_.json @@ -1 +1,7 @@ -{ "position": 1, "label": "Portfolio", "collapsed": false } +{ + "position": 1, + "label": "投资组合", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/account/sharelist/_category_.json b/docs/zh-CN/docs/account/sharelist/_category_.json index 896f0ec1..fc9f8184 100644 --- a/docs/zh-CN/docs/account/sharelist/_category_.json +++ b/docs/zh-CN/docs/account/sharelist/_category_.json @@ -1 +1,7 @@ -{ "position": 4, "label": "Sharelist", "collapsed": false } +{ + "position": 4, + "label": "自选股", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/fundamental/_category_.json b/docs/zh-CN/docs/fundamental/_category_.json index 8aa51261..ffe0f326 100644 --- a/docs/zh-CN/docs/fundamental/_category_.json +++ b/docs/zh-CN/docs/fundamental/_category_.json @@ -1 +1,7 @@ -{ "position": 5, "label": "Fundamental", "collapsed": false } +{ + "position": 5, + "label": "基本面", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/fundamental/calendar/_category_.json b/docs/zh-CN/docs/fundamental/calendar/_category_.json index 749c348f..912d5c6a 100644 --- a/docs/zh-CN/docs/fundamental/calendar/_category_.json +++ b/docs/zh-CN/docs/fundamental/calendar/_category_.json @@ -1 +1,7 @@ -{ "position": 3, "label": "Calendar", "collapsed": false } +{ + "position": 3, + "label": "日历", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/fundamental/fundamental/_category_.json b/docs/zh-CN/docs/fundamental/fundamental/_category_.json index 1e080d05..003cf33f 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/_category_.json +++ b/docs/zh-CN/docs/fundamental/fundamental/_category_.json @@ -1 +1,7 @@ -{ "position": 1, "label": "Fundamentals", "collapsed": false } +{ + "position": 1, + "label": "基本面数据", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-CN/docs/fundamental/market/_category_.json b/docs/zh-CN/docs/fundamental/market/_category_.json index d98f6649..f72654e3 100644 --- a/docs/zh-CN/docs/fundamental/market/_category_.json +++ b/docs/zh-CN/docs/fundamental/market/_category_.json @@ -1 +1,7 @@ -{ "position": 2, "label": "Market", "collapsed": false } +{ + "position": 2, + "label": "市场", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/account/_category_.json b/docs/zh-HK/docs/account/_category_.json index 02325a35..90e6e403 100644 --- a/docs/zh-HK/docs/account/_category_.json +++ b/docs/zh-HK/docs/account/_category_.json @@ -1 +1,7 @@ -{ "position": 6, "label": "Account", "collapsed": false } +{ + "position": 6, + "label": "帳戶", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/account/alert/_category_.json b/docs/zh-HK/docs/account/alert/_category_.json index 6722410e..2fd2b4b5 100644 --- a/docs/zh-HK/docs/account/alert/_category_.json +++ b/docs/zh-HK/docs/account/alert/_category_.json @@ -1 +1,7 @@ -{ "position": 2, "label": "Alerts", "collapsed": false } +{ + "position": 2, + "label": "價格提醒", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/account/dca/_category_.json b/docs/zh-HK/docs/account/dca/_category_.json index 3d43361f..77374e67 100644 --- a/docs/zh-HK/docs/account/dca/_category_.json +++ b/docs/zh-HK/docs/account/dca/_category_.json @@ -1 +1,7 @@ -{ "position": 3, "label": "DCA", "collapsed": false } +{ + "position": 3, + "label": "定期投資", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/account/portfolio/_category_.json b/docs/zh-HK/docs/account/portfolio/_category_.json index 7cc2901d..c9a54593 100644 --- a/docs/zh-HK/docs/account/portfolio/_category_.json +++ b/docs/zh-HK/docs/account/portfolio/_category_.json @@ -1 +1,7 @@ -{ "position": 1, "label": "Portfolio", "collapsed": false } +{ + "position": 1, + "label": "投資組合", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/account/sharelist/_category_.json b/docs/zh-HK/docs/account/sharelist/_category_.json index 896f0ec1..50b9e927 100644 --- a/docs/zh-HK/docs/account/sharelist/_category_.json +++ b/docs/zh-HK/docs/account/sharelist/_category_.json @@ -1 +1,7 @@ -{ "position": 4, "label": "Sharelist", "collapsed": false } +{ + "position": 4, + "label": "自選股", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/fundamental/_category_.json b/docs/zh-HK/docs/fundamental/_category_.json index 8aa51261..ffe0f326 100644 --- a/docs/zh-HK/docs/fundamental/_category_.json +++ b/docs/zh-HK/docs/fundamental/_category_.json @@ -1 +1,7 @@ -{ "position": 5, "label": "Fundamental", "collapsed": false } +{ + "position": 5, + "label": "基本面", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/fundamental/calendar/_category_.json b/docs/zh-HK/docs/fundamental/calendar/_category_.json index 749c348f..6347b088 100644 --- a/docs/zh-HK/docs/fundamental/calendar/_category_.json +++ b/docs/zh-HK/docs/fundamental/calendar/_category_.json @@ -1 +1,7 @@ -{ "position": 3, "label": "Calendar", "collapsed": false } +{ + "position": 3, + "label": "日曆", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/fundamental/fundamental/_category_.json b/docs/zh-HK/docs/fundamental/fundamental/_category_.json index 1e080d05..616f59cd 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/_category_.json +++ b/docs/zh-HK/docs/fundamental/fundamental/_category_.json @@ -1 +1,7 @@ -{ "position": 1, "label": "Fundamentals", "collapsed": false } +{ + "position": 1, + "label": "基本面數據", + "collapsible": true, + "collapsed": false, + "link": null +} diff --git a/docs/zh-HK/docs/fundamental/market/_category_.json b/docs/zh-HK/docs/fundamental/market/_category_.json index d98f6649..3a419436 100644 --- a/docs/zh-HK/docs/fundamental/market/_category_.json +++ b/docs/zh-HK/docs/fundamental/market/_category_.json @@ -1 +1,7 @@ -{ "position": 2, "label": "Market", "collapsed": false } +{ + "position": 2, + "label": "市場", + "collapsible": true, + "collapsed": false, + "link": null +} From a7c6d089a6543ddec25562d7aab9b1fc9943f68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sat, 9 May 2026 12:36:01 +0800 Subject: [PATCH 03/18] feat(sdk-docs): sync docs with openapi commit d7c2f6e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix CalendarContext: unify 5 calendar pages to use finance_calendar SDK method with CalendarCategory enum; fix HTTP URL to /v1/quote/finance_calendar - Add Meeting and Merge calendar pages - Fix PortfolioContext: rename capital_flow → profit_analysis_flows - Add 11 missing FundamentalContext methods (institution_rating, institution_rating_detail, dividend_detail, forecast_eps, consensus, valuation_history, industry_valuation, industry_valuation_dist, invest_relation, operating, buyback) - Add 3 missing MarketContext methods (broker_holding_detail, broker_holding_daily, ah_premium_intraday) - Add 2 missing AlertContext methods (enable, disable) - Add 7 missing DCAContext methods (pause, resume, stop, stats, check_support, calc_date, set_reminder) - Add 5 missing SharelistContext methods (detail, popular, add_securities, remove_securities, sort_securities) - Add icons and collapse subdirectories for Fundamental and Account sections - Add Overview pages for Fundamental and Account sections - Translate zh-CN/zh-HK SDK docs; remove duplicate CLI tabs Co-Authored-By: Claude Sonnet 4.6 (1M context) --- docs/.vitepress/.temp/assets/ai.svg | 121 +++++++++ docs/.vitepress/.temp/assets/bar.svg | 15 ++ docs/.vitepress/.temp/assets/code.svg | 112 ++++++++ docs/.vitepress/.temp/assets/icon-cloud.svg | 10 + docs/.vitepress/.temp/assets/icon-code.svg | 27 ++ docs/.vitepress/.temp/assets/icon-lanuch.svg | 10 + docs/.vitepress/.temp/assets/quote.svg | 52 ++++ docs/.vitepress/.temp/assets/sdk.svg | 97 +++++++ docs/.vitepress/.temp/assets/trade.svg | 56 ++++ .../.temp/longbridge-terminal/install | 67 +++++ .../.temp/longbridge-terminal/install.ps1 | 78 ++++++ docs/en/docs/account/_category_.json | 5 +- docs/en/docs/account/alert/_category_.json | 4 +- docs/en/docs/account/alert/create_alert.md | 8 - docs/en/docs/account/alert/delete_alert.md | 8 - docs/en/docs/account/alert/disable_alert.md | 183 +++++++++++++ docs/en/docs/account/alert/enable_alert.md | 183 +++++++++++++ docs/en/docs/account/alert/list_alerts.md | 8 - docs/en/docs/account/alert/update_alert.md | 8 - docs/en/docs/account/dca/_category_.json | 4 +- docs/en/docs/account/dca/calc_date.md | 211 +++++++++++++++ docs/en/docs/account/dca/check_support.md | 212 +++++++++++++++ docs/en/docs/account/dca/create_dca.md | 8 - docs/en/docs/account/dca/dca_history.md | 7 - docs/en/docs/account/dca/dca_stats.md | 205 ++++++++++++++ docs/en/docs/account/dca/delete_dca.md | 7 - docs/en/docs/account/dca/list_dca.md | 8 - docs/en/docs/account/dca/pause_dca.md | 181 +++++++++++++ docs/en/docs/account/dca/resume_dca.md | 181 +++++++++++++ docs/en/docs/account/dca/set_reminder.md | 183 +++++++++++++ docs/en/docs/account/dca/stop_dca.md | 181 +++++++++++++ docs/en/docs/account/dca/update_dca.md | 8 - docs/en/docs/account/overview.md | 55 ++++ .../en/docs/account/portfolio/_category_.json | 4 +- .../docs/account/portfolio/exchange_rates.md | 7 - .../portfolio/profit_analysis_by_market.md | 8 - .../portfolio/profit_analysis_detail.md | 8 - ...pital_flow.md => profit_analysis_flows.md} | 46 ++-- .../portfolio/profit_analysis_summary.md | 8 - .../en/docs/account/sharelist/_category_.json | 4 +- .../docs/account/sharelist/add_securities.md | 185 +++++++++++++ .../account/sharelist/create_sharelist.md | 7 - .../account/sharelist/delete_sharelist.md | 7 - .../docs/account/sharelist/list_sharelist.md | 8 - .../account/sharelist/popular_sharelist.md | 212 +++++++++++++++ .../account/sharelist/remove_securities.md | 185 +++++++++++++ .../account/sharelist/sharelist_detail.md | 207 +++++++++++++++ .../docs/account/sharelist/sort_securities.md | 185 +++++++++++++ .../account/sharelist/update_sharelist.md | 8 - docs/en/docs/fundamental/_category_.json | 5 +- .../docs/fundamental/calendar/_category_.json | 4 +- .../fundamental/calendar/dividend_calendar.md | 18 +- .../fundamental/calendar/earnings_calendar.md | 16 +- .../docs/fundamental/calendar/ipo_calendar.md | 18 +- .../fundamental/calendar/macro_calendar.md | 18 +- .../fundamental/calendar/meeting_calendar.md | 165 ++++++++++++ .../fundamental/calendar/merge_calendar.md | 165 ++++++++++++ .../fundamental/calendar/split_calendar.md | 18 +- .../fundamental/fundamental/_category_.json | 4 +- .../docs/fundamental/fundamental/buyback.md | 239 +++++++++++++++++ .../fundamental/company_profile.md | 8 - .../docs/fundamental/fundamental/consensus.md | 244 +++++++++++++++++ .../fundamental/corporate_actions.md | 8 - .../fundamental/dividend_detail.md | 243 +++++++++++++++++ .../docs/fundamental/fundamental/dividends.md | 8 - .../fundamental/fundamental/executives.md | 8 - .../fundamental/financial_report.md | 8 - .../fundamental/fundamental/forecast_eps.md | 244 +++++++++++++++++ .../fundamental/fundamental/fund_holdings.md | 8 - .../fundamental/industry_valuation.md | 248 +++++++++++++++++ .../fundamental/industry_valuation_dist.md | 238 +++++++++++++++++ .../fundamental/institution_rating.md | 243 +++++++++++++++++ .../fundamental/institution_rating_detail.md | 244 +++++++++++++++++ .../fundamental/invest_relation.md | 250 +++++++++++++++++ .../docs/fundamental/fundamental/operating.md | 251 ++++++++++++++++++ .../docs/fundamental/fundamental/ratings.md | 8 - .../fundamental/fundamental/shareholders.md | 8 - .../fundamental/valuation_history.md | 239 +++++++++++++++++ .../fundamental/fundamental/valuations.md | 8 - .../docs/fundamental/market/_category_.json | 4 +- docs/en/docs/fundamental/market/ah_premium.md | 8 - .../fundamental/market/ah_premium_intraday.md | 212 +++++++++++++++ .../market/broker_holding_daily.md | 217 +++++++++++++++ .../market/broker_holding_detail.md | 216 +++++++++++++++ .../fundamental/market/broker_positions.md | 8 - .../fundamental/market/index_components.md | 8 - .../docs/fundamental/market/market_status.md | 7 - .../docs/fundamental/market/trading_stats.md | 8 - .../docs/fundamental/market/unusual_items.md | 8 - docs/en/docs/fundamental/overview.md | 51 ++++ docs/zh-CN/docs/account/_category_.json | 5 +- docs/zh-CN/docs/account/alert/_category_.json | 4 +- docs/zh-CN/docs/account/alert/create_alert.md | 22 +- docs/zh-CN/docs/account/alert/delete_alert.md | 16 +- .../zh-CN/docs/account/alert/disable_alert.md | 183 +++++++++++++ docs/zh-CN/docs/account/alert/enable_alert.md | 183 +++++++++++++ docs/zh-CN/docs/account/alert/list_alerts.md | 28 +- docs/zh-CN/docs/account/alert/update_alert.md | 18 +- docs/zh-CN/docs/account/dca/_category_.json | 4 +- docs/zh-CN/docs/account/dca/calc_date.md | 211 +++++++++++++++ docs/zh-CN/docs/account/dca/check_support.md | 212 +++++++++++++++ docs/zh-CN/docs/account/dca/create_dca.md | 24 +- docs/zh-CN/docs/account/dca/dca_history.md | 31 +-- docs/zh-CN/docs/account/dca/dca_stats.md | 205 ++++++++++++++ docs/zh-CN/docs/account/dca/delete_dca.md | 15 +- docs/zh-CN/docs/account/dca/list_dca.md | 32 +-- docs/zh-CN/docs/account/dca/pause_dca.md | 181 +++++++++++++ docs/zh-CN/docs/account/dca/resume_dca.md | 181 +++++++++++++ docs/zh-CN/docs/account/dca/set_reminder.md | 183 +++++++++++++ docs/zh-CN/docs/account/dca/stop_dca.md | 181 +++++++++++++ docs/zh-CN/docs/account/dca/update_dca.md | 18 +- docs/zh-CN/docs/account/overview.md | 55 ++++ .../docs/account/portfolio/_category_.json | 4 +- .../docs/account/portfolio/exchange_rates.md | 23 +- .../portfolio/profit_analysis_by_market.md | 28 +- .../portfolio/profit_analysis_detail.md | 32 +-- ...pital_flow.md => profit_analysis_flows.md} | 64 ++--- .../portfolio/profit_analysis_summary.md | 34 +-- .../docs/account/sharelist/_category_.json | 4 +- .../docs/account/sharelist/add_securities.md | 185 +++++++++++++ .../account/sharelist/create_sharelist.md | 19 +- .../account/sharelist/delete_sharelist.md | 15 +- .../docs/account/sharelist/list_sharelist.md | 30 +-- .../account/sharelist/popular_sharelist.md | 212 +++++++++++++++ .../account/sharelist/remove_securities.md | 185 +++++++++++++ .../account/sharelist/sharelist_detail.md | 207 +++++++++++++++ .../docs/account/sharelist/sort_securities.md | 185 +++++++++++++ .../account/sharelist/update_sharelist.md | 22 +- docs/zh-CN/docs/fundamental/_category_.json | 5 +- .../docs/fundamental/calendar/_category_.json | 4 +- .../fundamental/calendar/dividend_calendar.md | 36 +-- .../fundamental/calendar/earnings_calendar.md | 36 +-- .../docs/fundamental/calendar/ipo_calendar.md | 36 +-- .../fundamental/calendar/macro_calendar.md | 38 ++- .../fundamental/calendar/split_calendar.md | 34 +-- .../fundamental/fundamental/_category_.json | 4 +- .../docs/fundamental/fundamental/buyback.md | 239 +++++++++++++++++ .../fundamental/company_profile.md | 28 +- .../docs/fundamental/fundamental/consensus.md | 244 +++++++++++++++++ .../fundamental/corporate_actions.md | 28 +- .../fundamental/dividend_detail.md | 243 +++++++++++++++++ .../docs/fundamental/fundamental/dividends.md | 30 +-- .../fundamental/fundamental/executives.md | 24 +- .../fundamental/financial_report.md | 32 +-- .../fundamental/fundamental/forecast_eps.md | 244 +++++++++++++++++ .../fundamental/fundamental/fund_holdings.md | 24 +- .../fundamental/industry_valuation.md | 248 +++++++++++++++++ .../fundamental/industry_valuation_dist.md | 238 +++++++++++++++++ .../fundamental/institution_rating.md | 243 +++++++++++++++++ .../fundamental/institution_rating_detail.md | 244 +++++++++++++++++ .../fundamental/invest_relation.md | 250 +++++++++++++++++ .../docs/fundamental/fundamental/operating.md | 251 ++++++++++++++++++ .../docs/fundamental/fundamental/ratings.md | 26 +- .../fundamental/fundamental/shareholders.md | 24 +- .../fundamental/valuation_history.md | 239 +++++++++++++++++ .../fundamental/fundamental/valuations.md | 28 +- .../docs/fundamental/market/_category_.json | 4 +- .../docs/fundamental/market/ah_premium.md | 26 +- .../fundamental/market/ah_premium_intraday.md | 212 +++++++++++++++ .../market/broker_holding_daily.md | 217 +++++++++++++++ .../market/broker_holding_detail.md | 216 +++++++++++++++ .../fundamental/market/broker_positions.md | 28 +- .../fundamental/market/index_components.md | 32 +-- .../docs/fundamental/market/market_status.md | 21 +- .../docs/fundamental/market/trading_stats.md | 32 +-- .../docs/fundamental/market/unusual_items.md | 26 +- docs/zh-CN/docs/fundamental/overview.md | 51 ++++ docs/zh-HK/docs/account/_category_.json | 5 +- docs/zh-HK/docs/account/alert/_category_.json | 4 +- docs/zh-HK/docs/account/alert/create_alert.md | 26 +- docs/zh-HK/docs/account/alert/delete_alert.md | 16 +- .../zh-HK/docs/account/alert/disable_alert.md | 183 +++++++++++++ docs/zh-HK/docs/account/alert/enable_alert.md | 183 +++++++++++++ docs/zh-HK/docs/account/alert/list_alerts.md | 28 +- docs/zh-HK/docs/account/alert/update_alert.md | 20 +- docs/zh-HK/docs/account/dca/_category_.json | 4 +- docs/zh-HK/docs/account/dca/calc_date.md | 211 +++++++++++++++ docs/zh-HK/docs/account/dca/check_support.md | 212 +++++++++++++++ docs/zh-HK/docs/account/dca/create_dca.md | 28 +- docs/zh-HK/docs/account/dca/dca_history.md | 31 +-- docs/zh-HK/docs/account/dca/dca_stats.md | 205 ++++++++++++++ docs/zh-HK/docs/account/dca/delete_dca.md | 15 +- docs/zh-HK/docs/account/dca/list_dca.md | 32 +-- docs/zh-HK/docs/account/dca/pause_dca.md | 181 +++++++++++++ docs/zh-HK/docs/account/dca/resume_dca.md | 181 +++++++++++++ docs/zh-HK/docs/account/dca/set_reminder.md | 183 +++++++++++++ docs/zh-HK/docs/account/dca/stop_dca.md | 181 +++++++++++++ docs/zh-HK/docs/account/dca/update_dca.md | 18 +- docs/zh-HK/docs/account/overview.md | 55 ++++ .../docs/account/portfolio/_category_.json | 4 +- .../docs/account/portfolio/exchange_rates.md | 23 +- .../portfolio/profit_analysis_by_market.md | 28 +- .../portfolio/profit_analysis_detail.md | 32 +-- ...pital_flow.md => profit_analysis_flows.md} | 66 ++--- .../portfolio/profit_analysis_summary.md | 34 +-- .../docs/account/sharelist/_category_.json | 4 +- .../docs/account/sharelist/add_securities.md | 185 +++++++++++++ .../account/sharelist/create_sharelist.md | 23 +- .../account/sharelist/delete_sharelist.md | 17 +- .../docs/account/sharelist/list_sharelist.md | 32 +-- .../account/sharelist/popular_sharelist.md | 212 +++++++++++++++ .../account/sharelist/remove_securities.md | 185 +++++++++++++ .../account/sharelist/sharelist_detail.md | 207 +++++++++++++++ .../docs/account/sharelist/sort_securities.md | 185 +++++++++++++ .../account/sharelist/update_sharelist.md | 24 +- docs/zh-HK/docs/fundamental/_category_.json | 5 +- .../docs/fundamental/calendar/_category_.json | 4 +- .../fundamental/calendar/dividend_calendar.md | 40 ++- .../fundamental/calendar/earnings_calendar.md | 36 +-- .../docs/fundamental/calendar/ipo_calendar.md | 38 ++- .../fundamental/calendar/macro_calendar.md | 38 ++- .../fundamental/calendar/split_calendar.md | 34 +-- .../fundamental/fundamental/_category_.json | 4 +- .../docs/fundamental/fundamental/buyback.md | 239 +++++++++++++++++ .../fundamental/company_profile.md | 28 +- .../docs/fundamental/fundamental/consensus.md | 244 +++++++++++++++++ .../fundamental/corporate_actions.md | 30 +-- .../fundamental/dividend_detail.md | 243 +++++++++++++++++ .../docs/fundamental/fundamental/dividends.md | 34 +-- .../fundamental/fundamental/executives.md | 24 +- .../fundamental/financial_report.md | 32 +-- .../fundamental/fundamental/forecast_eps.md | 244 +++++++++++++++++ .../fundamental/fundamental/fund_holdings.md | 24 +- .../fundamental/industry_valuation.md | 248 +++++++++++++++++ .../fundamental/industry_valuation_dist.md | 238 +++++++++++++++++ .../fundamental/institution_rating.md | 243 +++++++++++++++++ .../fundamental/institution_rating_detail.md | 244 +++++++++++++++++ .../fundamental/invest_relation.md | 250 +++++++++++++++++ .../docs/fundamental/fundamental/operating.md | 251 ++++++++++++++++++ .../docs/fundamental/fundamental/ratings.md | 26 +- .../fundamental/fundamental/shareholders.md | 24 +- .../fundamental/valuation_history.md | 239 +++++++++++++++++ .../fundamental/fundamental/valuations.md | 30 +-- .../docs/fundamental/market/_category_.json | 4 +- .../docs/fundamental/market/ah_premium.md | 26 +- .../fundamental/market/ah_premium_intraday.md | 212 +++++++++++++++ .../market/broker_holding_daily.md | 217 +++++++++++++++ .../market/broker_holding_detail.md | 216 +++++++++++++++ .../fundamental/market/broker_positions.md | 28 +- .../fundamental/market/index_components.md | 32 +-- .../docs/fundamental/market/market_status.md | 23 +- .../docs/fundamental/market/trading_stats.md | 34 +-- .../docs/fundamental/market/unusual_items.md | 26 +- docs/zh-HK/docs/fundamental/overview.md | 51 ++++ 244 files changed, 20241 insertions(+), 1776 deletions(-) create mode 100644 docs/.vitepress/.temp/assets/ai.svg create mode 100644 docs/.vitepress/.temp/assets/bar.svg create mode 100644 docs/.vitepress/.temp/assets/code.svg create mode 100644 docs/.vitepress/.temp/assets/icon-cloud.svg create mode 100644 docs/.vitepress/.temp/assets/icon-code.svg create mode 100644 docs/.vitepress/.temp/assets/icon-lanuch.svg create mode 100644 docs/.vitepress/.temp/assets/quote.svg create mode 100644 docs/.vitepress/.temp/assets/sdk.svg create mode 100644 docs/.vitepress/.temp/assets/trade.svg create mode 100755 docs/.vitepress/.temp/longbridge-terminal/install create mode 100644 docs/.vitepress/.temp/longbridge-terminal/install.ps1 create mode 100644 docs/en/docs/account/alert/disable_alert.md create mode 100644 docs/en/docs/account/alert/enable_alert.md create mode 100644 docs/en/docs/account/dca/calc_date.md create mode 100644 docs/en/docs/account/dca/check_support.md create mode 100644 docs/en/docs/account/dca/dca_stats.md create mode 100644 docs/en/docs/account/dca/pause_dca.md create mode 100644 docs/en/docs/account/dca/resume_dca.md create mode 100644 docs/en/docs/account/dca/set_reminder.md create mode 100644 docs/en/docs/account/dca/stop_dca.md create mode 100644 docs/en/docs/account/overview.md rename docs/en/docs/account/portfolio/{capital_flow.md => profit_analysis_flows.md} (83%) create mode 100644 docs/en/docs/account/sharelist/add_securities.md create mode 100644 docs/en/docs/account/sharelist/popular_sharelist.md create mode 100644 docs/en/docs/account/sharelist/remove_securities.md create mode 100644 docs/en/docs/account/sharelist/sharelist_detail.md create mode 100644 docs/en/docs/account/sharelist/sort_securities.md create mode 100644 docs/en/docs/fundamental/calendar/meeting_calendar.md create mode 100644 docs/en/docs/fundamental/calendar/merge_calendar.md create mode 100644 docs/en/docs/fundamental/fundamental/buyback.md create mode 100644 docs/en/docs/fundamental/fundamental/consensus.md create mode 100644 docs/en/docs/fundamental/fundamental/dividend_detail.md create mode 100644 docs/en/docs/fundamental/fundamental/forecast_eps.md create mode 100644 docs/en/docs/fundamental/fundamental/industry_valuation.md create mode 100644 docs/en/docs/fundamental/fundamental/industry_valuation_dist.md create mode 100644 docs/en/docs/fundamental/fundamental/institution_rating.md create mode 100644 docs/en/docs/fundamental/fundamental/institution_rating_detail.md create mode 100644 docs/en/docs/fundamental/fundamental/invest_relation.md create mode 100644 docs/en/docs/fundamental/fundamental/operating.md create mode 100644 docs/en/docs/fundamental/fundamental/valuation_history.md create mode 100644 docs/en/docs/fundamental/market/ah_premium_intraday.md create mode 100644 docs/en/docs/fundamental/market/broker_holding_daily.md create mode 100644 docs/en/docs/fundamental/market/broker_holding_detail.md create mode 100644 docs/en/docs/fundamental/overview.md create mode 100644 docs/zh-CN/docs/account/alert/disable_alert.md create mode 100644 docs/zh-CN/docs/account/alert/enable_alert.md create mode 100644 docs/zh-CN/docs/account/dca/calc_date.md create mode 100644 docs/zh-CN/docs/account/dca/check_support.md create mode 100644 docs/zh-CN/docs/account/dca/dca_stats.md create mode 100644 docs/zh-CN/docs/account/dca/pause_dca.md create mode 100644 docs/zh-CN/docs/account/dca/resume_dca.md create mode 100644 docs/zh-CN/docs/account/dca/set_reminder.md create mode 100644 docs/zh-CN/docs/account/dca/stop_dca.md create mode 100644 docs/zh-CN/docs/account/overview.md rename docs/zh-CN/docs/account/portfolio/{capital_flow.md => profit_analysis_flows.md} (75%) create mode 100644 docs/zh-CN/docs/account/sharelist/add_securities.md create mode 100644 docs/zh-CN/docs/account/sharelist/popular_sharelist.md create mode 100644 docs/zh-CN/docs/account/sharelist/remove_securities.md create mode 100644 docs/zh-CN/docs/account/sharelist/sharelist_detail.md create mode 100644 docs/zh-CN/docs/account/sharelist/sort_securities.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/buyback.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/consensus.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/dividend_detail.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/forecast_eps.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/industry_valuation.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/industry_valuation_dist.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/institution_rating.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/institution_rating_detail.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/invest_relation.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/operating.md create mode 100644 docs/zh-CN/docs/fundamental/fundamental/valuation_history.md create mode 100644 docs/zh-CN/docs/fundamental/market/ah_premium_intraday.md create mode 100644 docs/zh-CN/docs/fundamental/market/broker_holding_daily.md create mode 100644 docs/zh-CN/docs/fundamental/market/broker_holding_detail.md create mode 100644 docs/zh-CN/docs/fundamental/overview.md create mode 100644 docs/zh-HK/docs/account/alert/disable_alert.md create mode 100644 docs/zh-HK/docs/account/alert/enable_alert.md create mode 100644 docs/zh-HK/docs/account/dca/calc_date.md create mode 100644 docs/zh-HK/docs/account/dca/check_support.md create mode 100644 docs/zh-HK/docs/account/dca/dca_stats.md create mode 100644 docs/zh-HK/docs/account/dca/pause_dca.md create mode 100644 docs/zh-HK/docs/account/dca/resume_dca.md create mode 100644 docs/zh-HK/docs/account/dca/set_reminder.md create mode 100644 docs/zh-HK/docs/account/dca/stop_dca.md create mode 100644 docs/zh-HK/docs/account/overview.md rename docs/zh-HK/docs/account/portfolio/{capital_flow.md => profit_analysis_flows.md} (74%) create mode 100644 docs/zh-HK/docs/account/sharelist/add_securities.md create mode 100644 docs/zh-HK/docs/account/sharelist/popular_sharelist.md create mode 100644 docs/zh-HK/docs/account/sharelist/remove_securities.md create mode 100644 docs/zh-HK/docs/account/sharelist/sharelist_detail.md create mode 100644 docs/zh-HK/docs/account/sharelist/sort_securities.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/buyback.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/consensus.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/dividend_detail.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/forecast_eps.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/industry_valuation.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/industry_valuation_dist.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/institution_rating.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/institution_rating_detail.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/invest_relation.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/operating.md create mode 100644 docs/zh-HK/docs/fundamental/fundamental/valuation_history.md create mode 100644 docs/zh-HK/docs/fundamental/market/ah_premium_intraday.md create mode 100644 docs/zh-HK/docs/fundamental/market/broker_holding_daily.md create mode 100644 docs/zh-HK/docs/fundamental/market/broker_holding_detail.md create mode 100644 docs/zh-HK/docs/fundamental/overview.md diff --git a/docs/.vitepress/.temp/assets/ai.svg b/docs/.vitepress/.temp/assets/ai.svg new file mode 100644 index 00000000..9934fda1 --- /dev/null +++ b/docs/.vitepress/.temp/assets/ai.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/bar.svg b/docs/.vitepress/.temp/assets/bar.svg new file mode 100644 index 00000000..8aefcabc --- /dev/null +++ b/docs/.vitepress/.temp/assets/bar.svg @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/code.svg b/docs/.vitepress/.temp/assets/code.svg new file mode 100644 index 00000000..f665ee45 --- /dev/null +++ b/docs/.vitepress/.temp/assets/code.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/icon-cloud.svg b/docs/.vitepress/.temp/assets/icon-cloud.svg new file mode 100644 index 00000000..f5c2e0bd --- /dev/null +++ b/docs/.vitepress/.temp/assets/icon-cloud.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/icon-code.svg b/docs/.vitepress/.temp/assets/icon-code.svg new file mode 100644 index 00000000..1d1a78e3 --- /dev/null +++ b/docs/.vitepress/.temp/assets/icon-code.svg @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/icon-lanuch.svg b/docs/.vitepress/.temp/assets/icon-lanuch.svg new file mode 100644 index 00000000..6523d152 --- /dev/null +++ b/docs/.vitepress/.temp/assets/icon-lanuch.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/quote.svg b/docs/.vitepress/.temp/assets/quote.svg new file mode 100644 index 00000000..d548172e --- /dev/null +++ b/docs/.vitepress/.temp/assets/quote.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/sdk.svg b/docs/.vitepress/.temp/assets/sdk.svg new file mode 100644 index 00000000..cc8d1abc --- /dev/null +++ b/docs/.vitepress/.temp/assets/sdk.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/.vitepress/.temp/assets/trade.svg b/docs/.vitepress/.temp/assets/trade.svg new file mode 100644 index 00000000..9b1c3a1f --- /dev/null +++ b/docs/.vitepress/.temp/assets/trade.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/.vitepress/.temp/longbridge-terminal/install b/docs/.vitepress/.temp/longbridge-terminal/install new file mode 100755 index 00000000..2d8eec88 --- /dev/null +++ b/docs/.vitepress/.temp/longbridge-terminal/install @@ -0,0 +1,67 @@ +#!/usr/bin/env sh +set -eu +type curl > /dev/null || { echo "curl: not found"; exit 1; } + +repo='longbridge/longbridge-terminal' + +get_latest_release() { + tag=$(curl --silent "https://open.longbridge.cn/$repo/releases/latest") + if [ -z "$tag" ]; then + echo "Failed to fetch the latest release." >&2 + return 1 + fi + echo "$tag" +} + +version=$(get_latest_release) || exit 1 + +echo "Latest release: $version" + +bin_name='longbridge' +package_name='longbridge-terminal' + + +platform="$(uname | tr "[A-Z]" "[a-z]")" # Linux => linux +arch="$(uname -m)" # x86_64, arm64, aarch64, etc. + +# Normalize architecture names +case "$arch" in + x86_64) + arch="amd64" + ;; + aarch64) + arch="arm64" + ;; + arm64) + arch="arm64" + ;; +esac + +echo "Downloading $package_name@$version ..." + +# Always use the musl build on Linux – it is statically linked and works on any +# Linux system regardless of the glibc version (avoids segfaults on glibc +# systems where the binary was compiled against a different glibc version). +libc='' +if [ "$platform" = "linux" ]; then + libc='-musl' +fi + +download_url=https://open.longbridge.com/github/release/longbridge-terminal/$version/$package_name-$platform$libc-$arch.tar.gz +echo $download_url + +tmp_dir=$(mktemp -d) +trap 'rm -rf "$tmp_dir"' EXIT + +curl -Lo "$tmp_dir/$bin_name.tar.gz" $download_url +tar zxf "$tmp_dir/$bin_name.tar.gz" -C "$tmp_dir" + +if test $(id -u) -eq 0; then + mv "$tmp_dir/$bin_name" /usr/local/bin/$bin_name +else + sudo mv "$tmp_dir/$bin_name" /usr/local/bin/$bin_name +fi +echo "Longbridge CLI $version has installed successfully." +echo "" +echo "You can use \`longbridge -h\` to get help." +echo "" diff --git a/docs/.vitepress/.temp/longbridge-terminal/install.ps1 b/docs/.vitepress/.temp/longbridge-terminal/install.ps1 new file mode 100644 index 00000000..60529804 --- /dev/null +++ b/docs/.vitepress/.temp/longbridge-terminal/install.ps1 @@ -0,0 +1,78 @@ +#!/usr/bin/env pwsh +# Longbridge Terminal CLI installer for Windows +# Usage: iwr https://open.longbridge.com/longbridge/longbridge-terminal/install.ps1 | iex + +$ErrorActionPreference = 'Stop' + +$repo = 'longbridge/longbridge-terminal' +$binName = 'longbridge' +$packageName = 'longbridge-terminal' +$installDir = Join-Path $env:LOCALAPPDATA 'Programs\longbridge' + +# ── Resolve latest release version ─────────────────────────────────────────── + +Write-Host "Fetching latest release..." + +try { + $version = (Invoke-WebRequest -Uri "https://open.longbridge.com/$repo/releases/latest" -UseBasicParsing -TimeoutSec 15).Content.Trim() + if (-not $version) { + throw "Failed to fetch the latest release." + } +} catch { + throw "Failed to fetch the latest release: $_" +} + +Write-Host "Latest release: $version" + +# ── Download ────────────────────────────────────────────────────────────────── + +$downloadUrl = "https://open.longbridge.com/github/release/longbridge-terminal/$version/$packageName-windows-amd64.zip" + +Write-Host "Downloading $packageName@$version ..." +Write-Host $downloadUrl + +$tmpDir = Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName()) +$zipPath = Join-Path $tmpDir "$binName.zip" + +New-Item -ItemType Directory -Path $tmpDir | Out-Null + +try { + $wc = New-Object System.Net.WebClient + $wc.DownloadFile($downloadUrl, $zipPath) + $wc.Dispose() + + # ── Extract ─────────────────────────────────────────────────────────────── + + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $tmpDir) + + # ── Install ─────────────────────────────────────────────────────────────── + + if (-not (Test-Path $installDir)) { + New-Item -ItemType Directory -Path $installDir | Out-Null + } + + $srcExe = Join-Path $tmpDir "$binName.exe" + $destExe = Join-Path $installDir "$binName.exe" + Move-Item -Path $srcExe -Destination $destExe -Force + +} finally { + Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue +} + +# ── Add to user PATH if needed ──────────────────────────────────────────────── + +$userPath = [Environment]::GetEnvironmentVariable('PATH', 'User') +if ($userPath -notlike "*$installDir*") { + $newPath = ($userPath.TrimEnd(';') + ";$installDir").TrimStart(';') + [Environment]::SetEnvironmentVariable('PATH', $newPath, 'User') + Write-Host "" + Write-Host "Added $installDir to your PATH." + Write-Host "Restart your terminal for the PATH change to take effect." +} + +Write-Host "" +Write-Host "Longbridge CLI $version has been installed successfully." +Write-Host "" +Write-Host "Run 'longbridge auth login' to authenticate, then 'longbridge -h' for help." +Write-Host "" diff --git a/docs/en/docs/account/_category_.json b/docs/en/docs/account/_category_.json index bf207e04..4dd0d8c9 100644 --- a/docs/en/docs/account/_category_.json +++ b/docs/en/docs/account/_category_.json @@ -2,6 +2,7 @@ "position": 6, "label": "Account", "collapsible": true, - "collapsed": false, - "link": null + "collapsed": true, + "link": null, + "icon": "briefcase" } diff --git a/docs/en/docs/account/alert/_category_.json b/docs/en/docs/account/alert/_category_.json index 52c74c85..c477a9b6 100644 --- a/docs/en/docs/account/alert/_category_.json +++ b/docs/en/docs/account/alert/_category_.json @@ -2,6 +2,6 @@ "position": 2, "label": "Alerts", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/account/alert/create_alert.md b/docs/en/docs/account/alert/create_alert.md index f369dee3..9303691e 100644 --- a/docs/en/docs/account/alert/create_alert.md +++ b/docs/en/docs/account/alert/create_alert.md @@ -42,14 +42,6 @@ longbridge alert add AAPL.US --price 150 --direction fall ### Request Example - - - -longbridge alert add TSLA.US --price 300 --direction rise -longbridge alert add AAPL.US --price 150 --direction fall - - - ```python diff --git a/docs/en/docs/account/alert/delete_alert.md b/docs/en/docs/account/alert/delete_alert.md index 3d0828e8..eb707246 100644 --- a/docs/en/docs/account/alert/delete_alert.md +++ b/docs/en/docs/account/alert/delete_alert.md @@ -39,14 +39,6 @@ longbridge alert delete 112326 ### Request Example - - - -longbridge alert delete 486469 -longbridge alert delete 112326 - - - ```python diff --git a/docs/en/docs/account/alert/disable_alert.md b/docs/en/docs/account/alert/disable_alert.md new file mode 100644 index 00000000..3b43dd50 --- /dev/null +++ b/docs/en/docs/account/alert/disable_alert.md @@ -0,0 +1,183 @@ +--- +slug: disable-alert +title: Disable Alert +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Temporarily disable a price alert without deleting it. + + +longbridge alert disable 486469 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/{alert_id}/disable
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| alert_id | string | YES | Alert ID to disable | + +### Request Example + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +ctx.disable("486469") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + await ctx.disable("486469") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + await ctx.disable('486469') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + ctx.disable("486469").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + ctx.disable("486469").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Disable(context.Background(), "486469"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/alert/enable_alert.md b/docs/en/docs/account/alert/enable_alert.md new file mode 100644 index 00000000..034774f6 --- /dev/null +++ b/docs/en/docs/account/alert/enable_alert.md @@ -0,0 +1,183 @@ +--- +slug: enable-alert +title: Enable Alert +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Re-enable a previously disabled price alert. + + +longbridge alert enable 486469 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/{alert_id}/enable
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| alert_id | string | YES | Alert ID to enable | + +### Request Example + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +ctx.enable("486469") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + await ctx.enable("486469") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + await ctx.enable('486469') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + ctx.enable("486469").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + ctx.enable("486469").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Enable(context.Background(), "486469"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/alert/list_alerts.md b/docs/en/docs/account/alert/list_alerts.md index 3ebdc4d1..9fabc834 100644 --- a/docs/en/docs/account/alert/list_alerts.md +++ b/docs/en/docs/account/alert/list_alerts.md @@ -39,14 +39,6 @@ longbridge alert TSLA.US ### Request Example - - - -longbridge alert -longbridge alert TSLA.US - - - ```python diff --git a/docs/en/docs/account/alert/update_alert.md b/docs/en/docs/account/alert/update_alert.md index edcc0642..09d216e8 100644 --- a/docs/en/docs/account/alert/update_alert.md +++ b/docs/en/docs/account/alert/update_alert.md @@ -40,14 +40,6 @@ longbridge alert disable 112326 ### Request Example - - - -longbridge alert enable 112326 -longbridge alert disable 112326 - - - ```python diff --git a/docs/en/docs/account/dca/_category_.json b/docs/en/docs/account/dca/_category_.json index fc867080..31dbd0e5 100644 --- a/docs/en/docs/account/dca/_category_.json +++ b/docs/en/docs/account/dca/_category_.json @@ -2,6 +2,6 @@ "position": 3, "label": "DCA", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/account/dca/calc_date.md b/docs/en/docs/account/dca/calc_date.md new file mode 100644 index 00000000..552d1ffa --- /dev/null +++ b/docs/en/docs/account/dca/calc_date.md @@ -0,0 +1,211 @@ +--- +slug: calc-date +title: Calculate DCA Date +sidebar_position: 10 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Calculate the next projected trade date for given DCA plan parameters. + + +longbridge dca calc-date AAPL.US --frequency monthly --day-of-month 15 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/calc_date
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol | +| frequency | string | YES | DCA frequency: `daily`, `weekly`, `fortnightly`, `monthly` | +| day_of_week | string | NO | Day of week for weekly plans: `mon`–`fri` | +| day_of_month | integer | NO | Day of month for monthly/fortnightly plans: 1–28 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder, DCAFrequency + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.calc_date("AAPL.US", DCAFrequency.Monthly, day_of_month=15) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, Config, OAuthBuilder, DCAFrequency + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncDCAContext.create(config) + + resp = await ctx.calc_date("AAPL.US", DCAFrequency.Monthly, day_of_month=15) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, OAuth, DCAFrequency } = 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 = DCAContext.new(config) + const resp = await ctx.calcDate('AAPL.US', DCAFrequency.Monthly, undefined, 15) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var opts = new CalcDateOptions("AAPL.US", DCAFrequency.MONTHLY).dayOfMonth(15); + var resp = ctx.calcDate(opts).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, dca::DCAFrequency, 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 = DCAContext::new(config); + let resp = ctx.calc_date("AAPL.US", DCAFrequency::Monthly, None, Some(15)).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + dayOfMonth := 15 + opts := &dca.CalcDateOptions{ + Symbol: "AAPL.US", + Frequency: dca.FrequencyMonthly, + DayOfMonth: &dayOfMonth, + } + resp, err := c.CalcDate(context.Background(), opts) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "trade_date": "2024-02-15" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [DcaCalcDateResult](#DcaCalcDateResult) | +| 400 | Bad request | None | + +## Schemas + +### DcaCalcDateResult + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| trade_date | string | true | Next projected trade date (YYYY-MM-DD) | diff --git a/docs/en/docs/account/dca/check_support.md b/docs/en/docs/account/dca/check_support.md new file mode 100644 index 00000000..bc652d77 --- /dev/null +++ b/docs/en/docs/account/dca/check_support.md @@ -0,0 +1,212 @@ +--- +slug: check-support +title: Check DCA Support +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Check whether the given securities support DCA recurring investment. + + +longbridge dca check AAPL.US 700.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/support
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbols | string[] | YES | List of security symbols to check | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.check_support(["AAPL.US", "700.HK"]) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.check_support(["AAPL.US", "700.HK"]) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.checkSupport(['AAPL.US', '700.HK']) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; +import java.util.Arrays; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.checkSupport(Arrays.asList("AAPL.US", "700.HK")).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.check_support(vec!["AAPL.US".into(), "700.HK".into()]).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CheckSupport(context.Background(), []string{"AAPL.US", "700.HK"}) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { "symbol": "AAPL.US", "support": true }, + { "symbol": "700.HK", "support": true } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [DcaSupportList](#DcaSupportList) | +| 400 | Bad request | None | + +## Schemas + +### DcaSupportList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | DcaSupportItem[] | true | Support check results | + +### DcaSupportItem + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| support | boolean | true | Whether DCA is supported | diff --git a/docs/en/docs/account/dca/create_dca.md b/docs/en/docs/account/dca/create_dca.md index c3421c40..e725b4f6 100644 --- a/docs/en/docs/account/dca/create_dca.md +++ b/docs/en/docs/account/dca/create_dca.md @@ -43,14 +43,6 @@ longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon ### Request Example - - - -longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 -longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon - - - ```python diff --git a/docs/en/docs/account/dca/dca_history.md b/docs/en/docs/account/dca/dca_history.md index c2c9921b..4e613a37 100644 --- a/docs/en/docs/account/dca/dca_history.md +++ b/docs/en/docs/account/dca/dca_history.md @@ -40,13 +40,6 @@ longbridge dca history 1225781523156889600 ### Request Example - - - -longbridge dca history 1225781523156889600 - - - ```python diff --git a/docs/en/docs/account/dca/dca_stats.md b/docs/en/docs/account/dca/dca_stats.md new file mode 100644 index 00000000..dcf0d7a1 --- /dev/null +++ b/docs/en/docs/account/dca/dca_stats.md @@ -0,0 +1,205 @@ +--- +slug: dca-stats +title: DCA Statistics +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get DCA statistics summary including total invested amount and profit/loss. + + +longbridge dca stats + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/stats
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | NO | Filter by symbol | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.stats() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.stats() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.stats() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.stats(null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.stats(None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Stats(context.Background(), nil) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "total_invested": "10000.00", + "total_profit_loss": "1500.00", + "total_profit_loss_rate": "0.15" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [DcaStats](#DcaStats) | +| 400 | Bad request | None | + +## Schemas + +### DcaStats + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| total_invested | string | true | Total invested amount | +| total_profit_loss | string | true | Total profit/loss amount | +| total_profit_loss_rate | string | true | Total profit/loss rate | diff --git a/docs/en/docs/account/dca/delete_dca.md b/docs/en/docs/account/dca/delete_dca.md index 168ddb0e..edaf2504 100644 --- a/docs/en/docs/account/dca/delete_dca.md +++ b/docs/en/docs/account/dca/delete_dca.md @@ -38,13 +38,6 @@ longbridge dca stop 1225781523156889600 ### Request Example - - - -longbridge dca stop 1225781523156889600 - - - ```python diff --git a/docs/en/docs/account/dca/list_dca.md b/docs/en/docs/account/dca/list_dca.md index 8228a431..d67f7ad2 100644 --- a/docs/en/docs/account/dca/list_dca.md +++ b/docs/en/docs/account/dca/list_dca.md @@ -40,14 +40,6 @@ longbridge dca --status Active ### Request Example - - - -longbridge dca -longbridge dca --status Active - - - ```python diff --git a/docs/en/docs/account/dca/pause_dca.md b/docs/en/docs/account/dca/pause_dca.md new file mode 100644 index 00000000..7f5f8877 --- /dev/null +++ b/docs/en/docs/account/dca/pause_dca.md @@ -0,0 +1,181 @@ +--- +slug: pause-dca +title: Pause DCA Plan +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Temporarily pause a DCA plan. The plan can be resumed later. + + +longbridge dca pause 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/pause
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | YES | DCA plan ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.pause("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.pause("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.pause('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.pause("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.pause("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Pause(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/dca/resume_dca.md b/docs/en/docs/account/dca/resume_dca.md new file mode 100644 index 00000000..bd758b84 --- /dev/null +++ b/docs/en/docs/account/dca/resume_dca.md @@ -0,0 +1,181 @@ +--- +slug: resume-dca +title: Resume DCA Plan +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Resume a previously paused DCA plan. + + +longbridge dca resume 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/resume
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | YES | DCA plan ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.resume("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.resume("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.resume('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.resume("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.resume("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Resume(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/dca/set_reminder.md b/docs/en/docs/account/dca/set_reminder.md new file mode 100644 index 00000000..dfd1ae38 --- /dev/null +++ b/docs/en/docs/account/dca/set_reminder.md @@ -0,0 +1,183 @@ +--- +slug: set-reminder +title: Set DCA Reminder +sidebar_position: 11 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Set the advance reminder time for DCA plans. Supported values: `1`, `6`, or `12` hours. + + +longbridge dca set-reminder 12 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/reminder
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| hours | string | YES | Reminder advance hours: `1`, `6`, or `12` | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.set_reminder("12") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.set_reminder("12") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.setReminder('12') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.setReminder("12").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.set_reminder("12").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.SetReminder(context.Background(), "12"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/dca/stop_dca.md b/docs/en/docs/account/dca/stop_dca.md new file mode 100644 index 00000000..c6c1558f --- /dev/null +++ b/docs/en/docs/account/dca/stop_dca.md @@ -0,0 +1,181 @@ +--- +slug: stop-dca +title: Stop DCA Plan +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Permanently stop a DCA plan. This action cannot be undone. + + +longbridge dca stop 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/stop
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | YES | DCA plan ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.stop("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.stop("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.stop('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.stop("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.stop("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Stop(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/dca/update_dca.md b/docs/en/docs/account/dca/update_dca.md index 386c00fe..09bb68d9 100644 --- a/docs/en/docs/account/dca/update_dca.md +++ b/docs/en/docs/account/dca/update_dca.md @@ -40,14 +40,6 @@ longbridge dca resume 1225781523156889600 ### Request Example - - - -longbridge dca pause 1225781523156889600 -longbridge dca resume 1225781523156889600 - - - ```python diff --git a/docs/en/docs/account/overview.md b/docs/en/docs/account/overview.md new file mode 100644 index 00000000..cc0d61b8 --- /dev/null +++ b/docs/en/docs/account/overview.md @@ -0,0 +1,55 @@ +--- +sidebar_position: 0 +id: account_overview +title: Overview +slug: overview +--- + +# Account API Overview + +Account management APIs covering portfolio analysis, price alerts, recurring investment plans, and share lists. Most methods require Trade-level authentication. + +## PortfolioContext + +Portfolio profit/loss analysis and currency exchange rates. + +| Method | Description | +|---|---| +| [profit_analysis_summary](./portfolio/profit-analysis-summary) | Overall portfolio P&L summary | +| [profit_analysis_detail](./portfolio/profit-analysis-detail) | Per-position P&L breakdown | +| [profit_analysis_by_market](./portfolio/profit-analysis-by-market) | P&L grouped by market | +| [capital_flow](./portfolio/capital-flow) | Account capital flow history | +| [exchange_rates](./portfolio/exchange-rates) | Current exchange rates for supported currencies | + +## AlertContext + +Create and manage price alerts for securities. + +| Method | Description | +|---|---| +| [list_alerts](./alert/list-alerts) | List all active price alerts | +| [create_alert](./alert/create-alert) | Create a new price alert | +| [update_alert](./alert/update-alert) | Update an existing alert | +| [delete_alert](./alert/delete-alert) | Delete a price alert | + +## DCAContext + +Manage dollar-cost averaging (recurring investment) plans. + +| Method | Description | +|---|---| +| [list_dca](./dca/list-dca) | List all DCA plans | +| [create_dca](./dca/create-dca) | Create a new DCA plan | +| [dca_history](./dca/dca-history) | View execution history for a DCA plan | +| [delete_dca](./dca/delete-dca) | Cancel a DCA plan | + +## SharelistContext + +Create and manage community share lists (watchlists shared with others). + +| Method | Description | +|---|---| +| [list_sharelist](./sharelist/list-sharelist) | List all share lists | +| [create_sharelist](./sharelist/create-sharelist) | Create a new share list | +| [update_sharelist](./sharelist/update-sharelist) | Update a share list | +| [delete_sharelist](./sharelist/delete-sharelist) | Delete a share list | diff --git a/docs/en/docs/account/portfolio/_category_.json b/docs/en/docs/account/portfolio/_category_.json index 535297bd..cf19536c 100644 --- a/docs/en/docs/account/portfolio/_category_.json +++ b/docs/en/docs/account/portfolio/_category_.json @@ -2,6 +2,6 @@ "position": 1, "label": "Portfolio", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/account/portfolio/exchange_rates.md b/docs/en/docs/account/portfolio/exchange_rates.md index 1f194c73..b3e802c9 100644 --- a/docs/en/docs/account/portfolio/exchange_rates.md +++ b/docs/en/docs/account/portfolio/exchange_rates.md @@ -38,13 +38,6 @@ longbridge exchange-rate ### Request Example - - - -longbridge exchange-rate - - - ```python diff --git a/docs/en/docs/account/portfolio/profit_analysis_by_market.md b/docs/en/docs/account/portfolio/profit_analysis_by_market.md index 8932c71b..53c6aea4 100644 --- a/docs/en/docs/account/portfolio/profit_analysis_by_market.md +++ b/docs/en/docs/account/portfolio/profit_analysis_by_market.md @@ -40,14 +40,6 @@ longbridge profit-analysis --start 2026-01-01 ### Request Example - - - -longbridge profit-analysis --format json -longbridge profit-analysis --start 2026-01-01 - - - ```python diff --git a/docs/en/docs/account/portfolio/profit_analysis_detail.md b/docs/en/docs/account/portfolio/profit_analysis_detail.md index d0e3b49f..df1f1751 100644 --- a/docs/en/docs/account/portfolio/profit_analysis_detail.md +++ b/docs/en/docs/account/portfolio/profit_analysis_detail.md @@ -41,14 +41,6 @@ longbridge profit-analysis detail AAPL.US ### Request Example - - - -longbridge profit-analysis detail TSLA.US -longbridge profit-analysis detail AAPL.US - - - ```python diff --git a/docs/en/docs/account/portfolio/capital_flow.md b/docs/en/docs/account/portfolio/profit_analysis_flows.md similarity index 83% rename from docs/en/docs/account/portfolio/capital_flow.md rename to docs/en/docs/account/portfolio/profit_analysis_flows.md index 95d7d5f5..2c3e3103 100644 --- a/docs/en/docs/account/portfolio/capital_flow.md +++ b/docs/en/docs/account/portfolio/profit_analysis_flows.md @@ -1,6 +1,6 @@ --- -slug: capital-flow -title: Capital Flow +slug: profit-analysis-flows +title: Profit Analysis Flows sidebar_position: 5 language_tabs: false toc_footers: [] @@ -17,14 +17,14 @@ longbridge cash-flow longbridge cash-flow --format json - + ## Request - +
HTTP MethodGET
HTTP URL/v1/account/capital_flow
HTTP URL/v1/account/profit_analysis/flows
@@ -34,24 +34,14 @@ longbridge cash-flow --format json | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_time | integer | NO | Start time as Unix timestamp (seconds) | -| end_time | integer | NO | End time as Unix timestamp (seconds) | -| business_type | integer | NO | Business type filter. Omit for all types. | -| symbol | string | NO | Filter by security symbol | -| page | integer | NO | Page number (1-based, default: 1) | -| size | integer | NO | Records per page (default: 20) | +| symbol | string | YES | Security symbol | +| page | integer | NO | Page number (default: 1) | +| size | integer | NO | Page size (default: 20) | +| derivative | boolean | NO | Include derivative positions | ### Request Example - - - -longbridge cash-flow -longbridge cash-flow --format json - - - ```python @@ -61,7 +51,7 @@ oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) config = Config.from_oauth(oauth) ctx = PortfolioContext(config) -resp = ctx.capital_flow() +resp = ctx.profit_analysis_flows() print(resp) ``` @@ -77,7 +67,7 @@ async def main() -> None: config = Config.from_oauth(oauth) ctx = AsyncPortfolioContext.create(config) - resp = await ctx.capital_flow() + resp = await ctx.profit_analysis_flows() print(resp) if __name__ == "__main__": @@ -96,7 +86,7 @@ async function main() { }) const config = Config.fromOAuth(oauth) const ctx = PortfolioContext.new(config) - const resp = await ctx.capital_flow() + const resp = await ctx.profit_analysis_flows() console.log(resp) } main().catch(console.error) @@ -114,7 +104,7 @@ class Main { try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); Config config = Config.fromOAuth(oauth); PortfolioContext ctx = PortfolioContext.create(config)) { - var resp = ctx.getCapitalFlow().get(); + var resp = ctx.getProfitAnalysisFlows().get(); System.out.println(resp); } } @@ -133,7 +123,7 @@ 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 = PortfolioContext::new(config); - let resp = ctx.capital_flow().await?; + let resp = ctx.profit_analysis_flows().await?; println!("{:?}", resp); Ok(()) } @@ -156,7 +146,7 @@ int main() { if (!res) return; Config config = Config::from_oauth(*res); PortfolioContext ctx = PortfolioContext::create(config); - ctx.capital_flow([](auto resp) { + ctx.profit_analysis_flows([](auto resp) { if (resp) std::cout << "OK" << std::endl; }); }); @@ -195,7 +185,7 @@ func main() { log.Fatal(err) } defer c.Close() - resp, err := c.CapitalFlow(context.Background()) + resp, err := c.ProfitAnalysisFlows(context.Background()) if err != nil { log.Fatal(err) } @@ -238,14 +228,14 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [capital_flow_rsp](#capital_flow_rsp) | +| 200 | Success | [profit_analysis_flows_rsp](#profit_analysis_flows_rsp) | | 400 | Bad request | None | ## Schemas -### capital_flow_rsp +### profit_analysis_flows_rsp - + | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | diff --git a/docs/en/docs/account/portfolio/profit_analysis_summary.md b/docs/en/docs/account/portfolio/profit_analysis_summary.md index 862562b2..d7b53a7d 100644 --- a/docs/en/docs/account/portfolio/profit_analysis_summary.md +++ b/docs/en/docs/account/portfolio/profit_analysis_summary.md @@ -40,14 +40,6 @@ longbridge profit-analysis --start 2026-01-01 ### Request Example - - - -longbridge profit-analysis -longbridge profit-analysis --start 2026-01-01 - - - ```python diff --git a/docs/en/docs/account/sharelist/_category_.json b/docs/en/docs/account/sharelist/_category_.json index d1743b0e..35cad030 100644 --- a/docs/en/docs/account/sharelist/_category_.json +++ b/docs/en/docs/account/sharelist/_category_.json @@ -2,6 +2,6 @@ "position": 4, "label": "Sharelist", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/account/sharelist/add_securities.md b/docs/en/docs/account/sharelist/add_securities.md new file mode 100644 index 00000000..8b31f7a5 --- /dev/null +++ b/docs/en/docs/account/sharelist/add_securities.md @@ -0,0 +1,185 @@ +--- +slug: add-securities +title: Add Securities to Sharelist +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Add one or more securities to a sharelist. + + +longbridge sharelist add 123 TSLA.US AAPL.US + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/sharelist/{id}/securities
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | YES | Sharelist ID | +| symbols | string[] | YES | Security symbols to add | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.add_securities(123, ["TSLA.US", "AAPL.US"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.add_securities(123, ["TSLA.US", "AAPL.US"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.addSecurities(123, ['TSLA.US', 'AAPL.US']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.addSecurities(123, Arrays.asList("TSLA.US", "AAPL.US")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.add_securities(123, vec!["TSLA.US".into(), "AAPL.US".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.AddSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/sharelist/create_sharelist.md b/docs/en/docs/account/sharelist/create_sharelist.md index 96546239..d8b62e71 100644 --- a/docs/en/docs/account/sharelist/create_sharelist.md +++ b/docs/en/docs/account/sharelist/create_sharelist.md @@ -40,13 +40,6 @@ longbridge sharelist create --name "AI Picks" --description "Top AI infrastructu ### Request Example - - - -longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" - - - ```python diff --git a/docs/en/docs/account/sharelist/delete_sharelist.md b/docs/en/docs/account/sharelist/delete_sharelist.md index ee3f64d7..5e752ff2 100644 --- a/docs/en/docs/account/sharelist/delete_sharelist.md +++ b/docs/en/docs/account/sharelist/delete_sharelist.md @@ -38,13 +38,6 @@ longbridge sharelist delete 15921 ### Request Example - - - -longbridge sharelist delete 15921 - - - ```python diff --git a/docs/en/docs/account/sharelist/list_sharelist.md b/docs/en/docs/account/sharelist/list_sharelist.md index 6533f07a..f1f51d6b 100644 --- a/docs/en/docs/account/sharelist/list_sharelist.md +++ b/docs/en/docs/account/sharelist/list_sharelist.md @@ -39,14 +39,6 @@ longbridge sharelist --format json ### Request Example - - - -longbridge sharelist -longbridge sharelist --format json - - - ```python diff --git a/docs/en/docs/account/sharelist/popular_sharelist.md b/docs/en/docs/account/sharelist/popular_sharelist.md new file mode 100644 index 00000000..661f76ae --- /dev/null +++ b/docs/en/docs/account/sharelist/popular_sharelist.md @@ -0,0 +1,212 @@ +--- +slug: popular-sharelist +title: Popular Sharelists +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get popular/trending sharelists from the community. + + +longbridge sharelist popular --count 10 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/sharelist/popular
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| count | integer | NO | Maximum number of results, default 20 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.popular(10) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.popular(10) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.popular(10) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.popular(10).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.popular(10).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Popular(context.Background(), 10) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { "id": 123, "name": "AI Picks", "description": "Top AI infrastructure stocks" }, + { "id": 456, "name": "EV Leaders", "description": "Electric vehicle sector leaders" } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [SharelistList](#SharelistList) | +| 400 | Bad request | None | + +## Schemas + +### SharelistList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | SharelistItem[] | true | List of sharelists | + +### SharelistItem + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | Sharelist ID | +| name | string | true | Sharelist name | +| description | string | false | Description | diff --git a/docs/en/docs/account/sharelist/remove_securities.md b/docs/en/docs/account/sharelist/remove_securities.md new file mode 100644 index 00000000..ba1661d4 --- /dev/null +++ b/docs/en/docs/account/sharelist/remove_securities.md @@ -0,0 +1,185 @@ +--- +slug: remove-securities +title: Remove Securities from Sharelist +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Remove one or more securities from a sharelist. + + +longbridge sharelist remove 123 TSLA.US + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/sharelist/{id}/securities
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | YES | Sharelist ID | +| symbols | string[] | YES | Security symbols to remove | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.remove_securities(123, ["TSLA.US"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.remove_securities(123, ["TSLA.US"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.removeSecurities(123, ['TSLA.US']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.removeSecurities(123, Arrays.asList("TSLA.US")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.remove_securities(123, vec!["TSLA.US".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.RemoveSecurities(context.Background(), 123, []string{"TSLA.US"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/sharelist/sharelist_detail.md b/docs/en/docs/account/sharelist/sharelist_detail.md new file mode 100644 index 00000000..6866738c --- /dev/null +++ b/docs/en/docs/account/sharelist/sharelist_detail.md @@ -0,0 +1,207 @@ +--- +slug: sharelist-detail +title: Sharelist Detail +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get sharelist detail including name, description, and constituent stocks. + + +longbridge sharelist detail 123 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/sharelist/{id}
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | YES | Sharelist ID | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.detail(123) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.detail(123) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.detail(123) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.detail(123).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.detail(123).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Detail(context.Background(), 123) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 123, + "name": "AI Picks", + "description": "Top AI infrastructure stocks", + "securities": ["AAPL.US", "NVDA.US"] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [SharelistDetail](#SharelistDetail) | +| 400 | Bad request | None | + +## Schemas + +### SharelistDetail + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | Sharelist ID | +| name | string | true | Sharelist name | +| description | string | false | Description | +| securities | string[] | true | List of security symbols | diff --git a/docs/en/docs/account/sharelist/sort_securities.md b/docs/en/docs/account/sharelist/sort_securities.md new file mode 100644 index 00000000..e5bea7d6 --- /dev/null +++ b/docs/en/docs/account/sharelist/sort_securities.md @@ -0,0 +1,185 @@ +--- +slug: sort-securities +title: Sort Securities in Sharelist +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Reorder the securities in a sharelist. The symbols list defines the new order. + + +longbridge sharelist sort 123 TSLA.US AAPL.US 700.HK + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/sharelist/{id}/securities/sort
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | YES | Sharelist ID | +| symbols | string[] | YES | Security symbols in the desired order | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.sort_securities(123, ["TSLA.US", "AAPL.US", "700.HK"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.sort_securities(123, ["TSLA.US", "AAPL.US", "700.HK"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.sortSecurities(123, ['TSLA.US', 'AAPL.US', '700.HK']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.sortSecurities(123, Arrays.asList("TSLA.US", "AAPL.US", "700.HK")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.sort_securities(123, vec!["TSLA.US".into(), "AAPL.US".into(), "700.HK".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.SortSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US", "700.HK"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | None | +| 400 | Bad request | None | diff --git a/docs/en/docs/account/sharelist/update_sharelist.md b/docs/en/docs/account/sharelist/update_sharelist.md index 70899d74..4e654a51 100644 --- a/docs/en/docs/account/sharelist/update_sharelist.md +++ b/docs/en/docs/account/sharelist/update_sharelist.md @@ -42,14 +42,6 @@ longbridge sharelist remove 15921 AAPL.US ### Request Example - - - -longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US -longbridge sharelist remove 15921 AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/_category_.json b/docs/en/docs/fundamental/_category_.json index 9bbf73f8..3d6bf6ac 100644 --- a/docs/en/docs/fundamental/_category_.json +++ b/docs/en/docs/fundamental/_category_.json @@ -2,6 +2,7 @@ "position": 5, "label": "Fundamental", "collapsible": true, - "collapsed": false, - "link": null + "collapsed": true, + "link": null, + "icon": "book-open" } diff --git a/docs/en/docs/fundamental/calendar/_category_.json b/docs/en/docs/fundamental/calendar/_category_.json index d16b100a..3e4ff7cc 100644 --- a/docs/en/docs/fundamental/calendar/_category_.json +++ b/docs/en/docs/fundamental/calendar/_category_.json @@ -2,6 +2,6 @@ "position": 3, "label": "Calendar", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/fundamental/calendar/dividend_calendar.md b/docs/en/docs/fundamental/calendar/dividend_calendar.md index d674e146..27d3c605 100644 --- a/docs/en/docs/fundamental/calendar/dividend_calendar.md +++ b/docs/en/docs/fundamental/calendar/dividend_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar dividend longbridge finance-calendar dividend --filter positions - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/dividends
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar dividend --filter positions | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | ### Request Example - - - -longbridge finance-calendar dividend -longbridge finance-calendar dividend --filter positions - - - ```python diff --git a/docs/en/docs/fundamental/calendar/earnings_calendar.md b/docs/en/docs/fundamental/calendar/earnings_calendar.md index cf414f85..77ab3a5e 100644 --- a/docs/en/docs/fundamental/calendar/earnings_calendar.md +++ b/docs/en/docs/fundamental/calendar/earnings_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar report longbridge finance-calendar report --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/earnings
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar report --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | | market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | ### Request Example - - - -longbridge finance-calendar report -longbridge finance-calendar report --market US - - - ```python diff --git a/docs/en/docs/fundamental/calendar/ipo_calendar.md b/docs/en/docs/fundamental/calendar/ipo_calendar.md index 9d7a603b..4a1329e4 100644 --- a/docs/en/docs/fundamental/calendar/ipo_calendar.md +++ b/docs/en/docs/fundamental/calendar/ipo_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar ipo longbridge finance-calendar ipo --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/ipos
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar ipo --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | ### Request Example - - - -longbridge finance-calendar ipo -longbridge finance-calendar ipo --market US - - - ```python diff --git a/docs/en/docs/fundamental/calendar/macro_calendar.md b/docs/en/docs/fundamental/calendar/macro_calendar.md index 2050d7ae..8d2025a5 100644 --- a/docs/en/docs/fundamental/calendar/macro_calendar.md +++ b/docs/en/docs/fundamental/calendar/macro_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar macrodata longbridge finance-calendar macrodata --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/macro
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar macrodata --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| country | string | NO | Country code: `US`, `CN`, `EU`, `JP`. Omit for global. | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | ### Request Example - - - -longbridge finance-calendar macrodata -longbridge finance-calendar macrodata --market US - - - ```python diff --git a/docs/en/docs/fundamental/calendar/meeting_calendar.md b/docs/en/docs/fundamental/calendar/meeting_calendar.md new file mode 100644 index 00000000..21cd846d --- /dev/null +++ b/docs/en/docs/fundamental/calendar/meeting_calendar.md @@ -0,0 +1,165 @@ +--- +slug: meeting-calendar +title: Meeting Calendar +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Browse upcoming shareholder meetings and company events. + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/finance_calendar
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | + +### Request Example + + + + +```python +from longbridge.openapi import CalendarContext, CalendarCategory, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.finance_calendar(CalendarCategory.Meeting, "2024-01-01", "2024-03-31") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, CalendarCategory, 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 = AsyncCalendarContext.create(config) + resp = await ctx.finance_calendar(CalendarCategory.Meeting, "2024-01-01", "2024-03-31") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, CalendarCategory, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Open:', url)) + const config = Config.fromOAuth(oauth) + const ctx = CalendarContext.new(config) + const resp = await ctx.financeCalendar(CalendarCategory.Meeting, '2024-01-01', '2024-03-31') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open: " + url)).get(); + Config config = Config.fromOAuth(oauth); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.financeCalendar(CalendarCategory.Meeting, "2024-01-01", "2024-03-31", null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::{CalendarContext, CalendarCategory}, 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 = CalendarContext::new(config); + let resp = ctx.finance_calendar(CalendarCategory::Meeting, "2024-01-01", "2024-03-31", None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/calendar" + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" +) + +func main() { + o := oauth.New("your-client-id").OnOpenURL(func(url string) { fmt.Println("Open:", url) }) + if err := o.Build(context.Background()); err != nil { log.Fatal(err) } + conf, _ := config.New(config.WithOAuthClient(o)) + c, _ := calendar.NewFromCfg(conf) + defer c.Close() + resp, err := c.FinanceCalendar(context.Background(), "Meeting", "2024-01-01", "2024-03-31", nil) + if err != nil { log.Fatal(err) } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | CalendarEventsResponse | +| 400 | Bad request | None | diff --git a/docs/en/docs/fundamental/calendar/merge_calendar.md b/docs/en/docs/fundamental/calendar/merge_calendar.md new file mode 100644 index 00000000..8540c89f --- /dev/null +++ b/docs/en/docs/fundamental/calendar/merge_calendar.md @@ -0,0 +1,165 @@ +--- +slug: merge-calendar +title: Merge Calendar +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Browse upcoming M&A and merger events. + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/quote/finance_calendar
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | + +### Request Example + + + + +```python +from longbridge.openapi import CalendarContext, CalendarCategory, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = CalendarContext(config) + +resp = ctx.finance_calendar(CalendarCategory.Merge, "2024-01-01", "2024-03-31") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncCalendarContext, CalendarCategory, 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 = AsyncCalendarContext.create(config) + resp = await ctx.finance_calendar(CalendarCategory.Merge, "2024-01-01", "2024-03-31") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, CalendarContext, CalendarCategory, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => console.log('Open:', url)) + const config = Config.fromOAuth(oauth) + const ctx = CalendarContext.new(config) + const resp = await ctx.financeCalendar(CalendarCategory.Merge, '2024-01-01', '2024-03-31') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.calendar.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open: " + url)).get(); + Config config = Config.fromOAuth(oauth); + CalendarContext ctx = CalendarContext.create(config)) { + var resp = ctx.financeCalendar(CalendarCategory.Merge, "2024-01-01", "2024-03-31", null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, calendar::{CalendarContext, CalendarCategory}, 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 = CalendarContext::new(config); + let resp = ctx.finance_calendar(CalendarCategory::Merge, "2024-01-01", "2024-03-31", None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/calendar" + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" +) + +func main() { + o := oauth.New("your-client-id").OnOpenURL(func(url string) { fmt.Println("Open:", url) }) + if err := o.Build(context.Background()); err != nil { log.Fatal(err) } + conf, _ := config.New(config.WithOAuthClient(o)) + c, _ := calendar.NewFromCfg(conf) + defer c.Close() + resp, err := c.FinanceCalendar(context.Background(), "Merge", "2024-01-01", "2024-03-31", nil) + if err != nil { log.Fatal(err) } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | CalendarEventsResponse | +| 400 | Bad request | None | diff --git a/docs/en/docs/fundamental/calendar/split_calendar.md b/docs/en/docs/fundamental/calendar/split_calendar.md index d8964db5..c2b33e66 100644 --- a/docs/en/docs/fundamental/calendar/split_calendar.md +++ b/docs/en/docs/fundamental/calendar/split_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar split longbridge finance-calendar split --market HK - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/splits
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar split --market HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | Start date, YYYY-MM-DD | +| end | string | YES | End date, YYYY-MM-DD | +| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | ### Request Example - - - -longbridge finance-calendar split -longbridge finance-calendar split --market HK - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/_category_.json b/docs/en/docs/fundamental/fundamental/_category_.json index 32971e2a..682842c4 100644 --- a/docs/en/docs/fundamental/fundamental/_category_.json +++ b/docs/en/docs/fundamental/fundamental/_category_.json @@ -2,6 +2,6 @@ "position": 1, "label": "Fundamentals", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/fundamental/fundamental/buyback.md b/docs/en/docs/fundamental/fundamental/buyback.md new file mode 100644 index 00000000..69a37214 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/buyback.md @@ -0,0 +1,239 @@ +--- +slug: buyback +title: Buyback +sidebar_position: 20 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get share buyback data including historical buyback amounts and ratios. + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/buyback
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.buyback("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.buyback("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.buyback('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.getBuyback("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.buyback("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.buyback("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.Buyback(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "period": "FY2023", + "buyback_amount": 77550000000, + "buyback_shares": 430000000, + "buyback_ratio": 0.0278, + "currency": "USD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [BuybackData](#BuybackData) | +| 400 | Bad request | None | + +## Schemas + +### BuybackData + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| list | object[] | true | List of buyback records | +| list[].period | string | false | Fiscal period (e.g. FY2023, Q3 2024) | +| list[].buyback_amount | int64 | false | Total buyback amount | +| list[].buyback_shares | int64 | false | Number of shares repurchased | +| list[].buyback_ratio | double | false | Buyback as a ratio of shares outstanding | +| list[].currency | string | false | Currency code | diff --git a/docs/en/docs/fundamental/fundamental/company_profile.md b/docs/en/docs/fundamental/fundamental/company_profile.md index 5b874b90..3aa87810 100644 --- a/docs/en/docs/fundamental/fundamental/company_profile.md +++ b/docs/en/docs/fundamental/fundamental/company_profile.md @@ -39,14 +39,6 @@ longbridge company AAPL.US ### Request Example - - - -longbridge company TSLA.US -longbridge company AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/consensus.md b/docs/en/docs/fundamental/fundamental/consensus.md new file mode 100644 index 00000000..3b6f1fe4 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/consensus.md @@ -0,0 +1,244 @@ +--- +slug: consensus +title: Financial Consensus +sidebar_position: 14 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get financial consensus estimates including revenue, EPS, and net income forecasts. + + +longbridge consensus TSLA.US +longbridge consensus AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/consensus
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.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.consensus("TSLA.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.consensus("TSLA.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.consensus('TSLA.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.getConsensus("TSLA.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.consensus("TSLA.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.consensus("TSLA.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.Consensus(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "list": [ + { + "period": "FY2024", + "revenue": 105000000000, + "eps": 3.12, + "net_income": 10500000000, + "analyst_count": 35 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [FinancialConsensus](#FinancialConsensus) | +| 400 | Bad request | None | + +## Schemas + +### FinancialConsensus + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| list | object[] | true | List of consensus forecast periods | +| list[].period | string | false | Fiscal period (e.g. FY2024) | +| list[].revenue | int64 | false | Consensus revenue estimate | +| list[].eps | double | false | Consensus EPS estimate | +| list[].net_income | int64 | false | Consensus net income estimate | +| list[].analyst_count | int32 | false | Number of analysts contributing | diff --git a/docs/en/docs/fundamental/fundamental/corporate_actions.md b/docs/en/docs/fundamental/fundamental/corporate_actions.md index ece51be0..18c1a409 100644 --- a/docs/en/docs/fundamental/fundamental/corporate_actions.md +++ b/docs/en/docs/fundamental/fundamental/corporate_actions.md @@ -41,14 +41,6 @@ longbridge corp-action AAPL.US ### Request Example - - - -longbridge corp-action TSLA.US -longbridge corp-action AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/dividend_detail.md b/docs/en/docs/fundamental/fundamental/dividend_detail.md new file mode 100644 index 00000000..04be2259 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/dividend_detail.md @@ -0,0 +1,243 @@ +--- +slug: dividend-detail +title: Dividend Detail +sidebar_position: 12 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get detailed dividend information including declared, ex-dividend, and payment dates. + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/dividend_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.dividend_detail("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.dividend_detail("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.dividendDetail('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.getDividendDetail("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.dividend_detail("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.dividend_detail("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.DividendDetail(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "dividend_type": "cash", + "amount": 0.24, + "currency": "USD", + "declared_date": "2024-02-01", + "ex_date": "2024-02-09", + "record_date": "2024-02-12", + "payment_date": "2024-02-15" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [DividendList](#DividendList) | +| 400 | Bad request | None | + +## Schemas + +### DividendList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of dividend records | +| list[].symbol | string | true | Security symbol | +| list[].dividend_type | string | false | Dividend type (e.g. cash, stock) | +| list[].amount | double | false | Dividend amount per share | +| list[].currency | string | false | Currency code | +| list[].declared_date | string | false | Declaration date (YYYY-MM-DD) | +| list[].ex_date | string | false | Ex-dividend date (YYYY-MM-DD) | +| list[].record_date | string | false | Record date (YYYY-MM-DD) | +| list[].payment_date | string | false | Payment date (YYYY-MM-DD) | diff --git a/docs/en/docs/fundamental/fundamental/dividends.md b/docs/en/docs/fundamental/fundamental/dividends.md index 2d0e1635..509af317 100644 --- a/docs/en/docs/fundamental/fundamental/dividends.md +++ b/docs/en/docs/fundamental/fundamental/dividends.md @@ -41,14 +41,6 @@ longbridge dividend AAPL.US ### Request Example - - - -longbridge dividend TSLA.US -longbridge dividend AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/executives.md b/docs/en/docs/fundamental/fundamental/executives.md index 25dedde1..7d48e1e4 100644 --- a/docs/en/docs/fundamental/fundamental/executives.md +++ b/docs/en/docs/fundamental/fundamental/executives.md @@ -39,14 +39,6 @@ longbridge executive AAPL.US ### Request Example - - - -longbridge executive TSLA.US -longbridge executive AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/financial_report.md b/docs/en/docs/fundamental/fundamental/financial_report.md index ce9b1d4a..400937ff 100644 --- a/docs/en/docs/fundamental/fundamental/financial_report.md +++ b/docs/en/docs/fundamental/fundamental/financial_report.md @@ -41,14 +41,6 @@ longbridge financial-report AAPL.US ### Request Example - - - -longbridge financial-report TSLA.US --kind IS -longbridge financial-report AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/forecast_eps.md b/docs/en/docs/fundamental/fundamental/forecast_eps.md new file mode 100644 index 00000000..9073708f --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/forecast_eps.md @@ -0,0 +1,244 @@ +--- +slug: forecast-eps +title: Forecast EPS +sidebar_position: 13 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get EPS forecasts and analyst consensus estimates. + + +longbridge forecast-eps TSLA.US +longbridge forecast-eps AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/forecast_eps
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.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.forecast_eps("TSLA.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.forecast_eps("TSLA.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.forecastEps('TSLA.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.getForecastEps("TSLA.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.forecast_eps("TSLA.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.forecast_eps("TSLA.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.ForecastEps(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "list": [ + { + "period": "FY2024", + "consensus_eps": 3.12, + "high_eps": 4.50, + "low_eps": 2.10, + "analyst_count": 35 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ForecastEps](#ForecastEps) | +| 400 | Bad request | None | + +## Schemas + +### ForecastEps + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| list | object[] | true | List of EPS forecast periods | +| list[].period | string | false | Fiscal period (e.g. FY2024, Q1 2024) | +| list[].consensus_eps | double | false | Consensus EPS estimate | +| list[].high_eps | double | false | Highest EPS estimate | +| list[].low_eps | double | false | Lowest EPS estimate | +| list[].analyst_count | int32 | false | Number of analysts contributing | diff --git a/docs/en/docs/fundamental/fundamental/fund_holdings.md b/docs/en/docs/fundamental/fundamental/fund_holdings.md index 5bf55ac0..4398a05c 100644 --- a/docs/en/docs/fundamental/fundamental/fund_holdings.md +++ b/docs/en/docs/fundamental/fundamental/fund_holdings.md @@ -39,14 +39,6 @@ longbridge fund-holder AAPL.US ### Request Example - - - -longbridge fund-holder TSLA.US -longbridge fund-holder AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/industry_valuation.md b/docs/en/docs/fundamental/fundamental/industry_valuation.md new file mode 100644 index 00000000..2eea902d --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/industry_valuation.md @@ -0,0 +1,248 @@ +--- +slug: industry-valuation +title: Industry Valuation +sidebar_position: 16 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get peer valuation comparison within the same industry. + + +longbridge industry-valuation TSLA.US +longbridge industry-valuation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/industry_valuation
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.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.industry_valuation("TSLA.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_valuation("TSLA.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.industryValuation('TSLA.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.getIndustryValuation("TSLA.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_valuation("TSLA.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_valuation("TSLA.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.IndustryValuation(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "industry": "Automobiles", + "list": [ + { + "symbol": "TSLA.US", + "name": "Tesla Inc.", + "pe": 55.2, + "pb": 12.1, + "ps": 6.8, + "market_cap": 700000000000 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [IndustryValuationList](#IndustryValuationList) | +| 400 | Bad request | None | + +## Schemas + +### IndustryValuationList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| industry | string | false | Industry classification | +| list | object[] | true | List of peer companies | +| list[].symbol | string | false | Peer security symbol | +| list[].name | string | false | Company name | +| list[].pe | double | false | Price-to-Earnings ratio | +| list[].pb | double | false | Price-to-Book ratio | +| list[].ps | double | false | Price-to-Sales ratio | +| list[].market_cap | int64 | false | Market capitalization | diff --git a/docs/en/docs/fundamental/fundamental/industry_valuation_dist.md b/docs/en/docs/fundamental/fundamental/industry_valuation_dist.md new file mode 100644 index 00000000..13bc1fc0 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/industry_valuation_dist.md @@ -0,0 +1,238 @@ +--- +slug: industry-valuation-dist +title: Industry Valuation Distribution +sidebar_position: 17 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get the valuation distribution histogram for the symbol's industry. + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/industry_valuation_dist
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.industry_valuation_dist("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.industry_valuation_dist("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.industryValuationDist('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.getIndustryValuationDist("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.industry_valuation_dist("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.industry_valuation_dist("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.IndustryValuationDist(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "metric": "pe", + "symbol_value": 28.5, + "buckets": [ + { "range_start": 0, "range_end": 10, "count": 5 }, + { "range_start": 10, "range_end": 20, "count": 18 }, + { "range_start": 20, "range_end": 30, "count": 22 }, + { "range_start": 30, "range_end": 50, "count": 12 } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [IndustryValuationDist](#IndustryValuationDist) | +| 400 | Bad request | None | + +## Schemas + +### IndustryValuationDist + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| metric | string | false | Valuation metric (e.g. pe, pb, ps) | +| symbol_value | double | false | The symbol's own metric value | +| buckets | object[] | false | Distribution histogram buckets | +| buckets[].range_start | double | false | Bucket lower bound | +| buckets[].range_end | double | false | Bucket upper bound | +| buckets[].count | int32 | false | Number of companies in this bucket | diff --git a/docs/en/docs/fundamental/fundamental/institution_rating.md b/docs/en/docs/fundamental/fundamental/institution_rating.md new file mode 100644 index 00000000..8e92d8e7 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/institution_rating.md @@ -0,0 +1,243 @@ +--- +slug: institution-rating +title: Institution Rating +sidebar_position: 10 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get analyst institution rating snapshot (rating distribution and average target price). + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/institution_rating
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.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("TSLA.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("TSLA.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.institutionRating('TSLA.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.getInstitutionRating("TSLA.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("TSLA.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("TSLA.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.InstitutionRating(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "buy": 18, + "outperform": 5, + "hold": 12, + "underperform": 3, + "sell": 2, + "total": 40, + "avg_target_price": 285.50 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [InstitutionRating](#InstitutionRating) | +| 400 | Bad request | None | + +## Schemas + +### InstitutionRating + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| buy | int32 | false | Number of Buy ratings | +| outperform | int32 | false | Number of Outperform ratings | +| hold | int32 | false | Number of Hold ratings | +| underperform | int32 | false | Number of Underperform ratings | +| sell | int32 | false | Number of Sell ratings | +| total | int32 | false | Total number of ratings | +| avg_target_price | double | false | Average target price | diff --git a/docs/en/docs/fundamental/fundamental/institution_rating_detail.md b/docs/en/docs/fundamental/fundamental/institution_rating_detail.md new file mode 100644 index 00000000..99e1c96d --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/institution_rating_detail.md @@ -0,0 +1,244 @@ +--- +slug: institution-rating-detail +title: Institution Rating Detail +sidebar_position: 11 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get historical analyst rating and target price details. + + +longbridge institution-rating detail TSLA.US +longbridge institution-rating detail AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/institution_rating_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `TSLA.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_detail("TSLA.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_detail("TSLA.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.institutionRatingDetail('TSLA.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.getInstitutionRatingDetail("TSLA.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_detail("TSLA.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_detail("TSLA.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.InstitutionRatingDetail(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "TSLA.US", + "broker": "Goldman Sachs", + "analyst": "Mark Delaney", + "rating": "Buy", + "target_price": 320.00, + "date": "2024-03-15" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [InstitutionRatingDetail](#InstitutionRatingDetail) | +| 400 | Bad request | None | + +## Schemas + +### InstitutionRatingDetail + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | true | List of rating details | +| list[].symbol | string | true | Security symbol | +| list[].broker | string | false | Brokerage firm name | +| list[].analyst | string | false | Analyst name | +| list[].rating | string | false | Rating (e.g. Buy, Hold, Sell) | +| list[].target_price | double | false | Target price | +| list[].date | string | false | Rating date (YYYY-MM-DD) | diff --git a/docs/en/docs/fundamental/fundamental/invest_relation.md b/docs/en/docs/fundamental/fundamental/invest_relation.md new file mode 100644 index 00000000..16c6ed93 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/invest_relation.md @@ -0,0 +1,250 @@ +--- +slug: invest-relation +title: Investment Relations +sidebar_position: 18 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get investment relations including parent company, subsidiaries, and major holdings. + + +longbridge invest-relation 700.HK +longbridge invest-relation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/invest_relation
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `700.HK` | + +### 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.invest_relation("700.HK") +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.invest_relation("700.HK") + 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.investRelation('700.HK') + 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.getInvestRelation("700.HK").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.invest_relation("700.HK").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.invest_relation("700.HK", [](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.InvestRelation(context.Background(), "700.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "parent": { + "symbol": "", + "name": "" + }, + "subsidiaries": [ + { "symbol": "TCEHY.US", "name": "Tencent Holdings ADR", "holding_ratio": 1.0 } + ], + "holdings": [ + { "symbol": "SE.US", "name": "Sea Limited", "holding_ratio": 18.7 } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [InvestRelations](#InvestRelations) | +| 400 | Bad request | None | + +## Schemas + +### InvestRelations + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| parent | object | false | Parent company information | +| parent.symbol | string | false | Parent security symbol | +| parent.name | string | false | Parent company name | +| subsidiaries | object[] | false | List of subsidiaries | +| subsidiaries[].symbol | string | false | Subsidiary security symbol | +| subsidiaries[].name | string | false | Subsidiary company name | +| subsidiaries[].holding_ratio | double | false | Holding ratio (%) | +| holdings | object[] | false | List of major holdings | +| holdings[].symbol | string | false | Holding security symbol | +| holdings[].name | string | false | Holding company name | +| holdings[].holding_ratio | double | false | Holding ratio (%) | diff --git a/docs/en/docs/fundamental/fundamental/operating.md b/docs/en/docs/fundamental/fundamental/operating.md new file mode 100644 index 00000000..73b56850 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/operating.md @@ -0,0 +1,251 @@ +--- +slug: operating +title: Operating Metrics +sidebar_position: 19 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get operating metrics and financial indicator summaries by report period. + + +longbridge operating AAPL.US +longbridge operating TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/operating
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| period | string | NO | Report period filter, e.g. `q1`, `q2`, `q3`, `q4`, `annual` | + +### 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.operating("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.operating("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.operating('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.getOperating("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.operating("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.operating("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.Operating(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "period": "Q1 2024", + "revenue": 119575000000, + "gross_profit": 54856000000, + "operating_income": 40372000000, + "net_income": 33916000000, + "gross_margin": 0.4588, + "operating_margin": 0.3377, + "net_margin": 0.2837 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [OperatingList](#OperatingList) | +| 400 | Bad request | None | + +## Schemas + +### OperatingList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| list | object[] | true | List of operating metric records | +| list[].period | string | false | Report period (e.g. Q1 2024, Annual 2023) | +| list[].revenue | int64 | false | Total revenue | +| list[].gross_profit | int64 | false | Gross profit | +| list[].operating_income | int64 | false | Operating income | +| list[].net_income | int64 | false | Net income | +| list[].gross_margin | double | false | Gross margin ratio | +| list[].operating_margin | double | false | Operating margin ratio | +| list[].net_margin | double | false | Net margin ratio | diff --git a/docs/en/docs/fundamental/fundamental/ratings.md b/docs/en/docs/fundamental/fundamental/ratings.md index fcb7ecba..fed89572 100644 --- a/docs/en/docs/fundamental/fundamental/ratings.md +++ b/docs/en/docs/fundamental/fundamental/ratings.md @@ -39,14 +39,6 @@ longbridge institution-rating AAPL.US ### Request Example - - - -longbridge institution-rating TSLA.US -longbridge institution-rating AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/shareholders.md b/docs/en/docs/fundamental/fundamental/shareholders.md index 320f0cf3..035d3cfb 100644 --- a/docs/en/docs/fundamental/fundamental/shareholders.md +++ b/docs/en/docs/fundamental/fundamental/shareholders.md @@ -39,14 +39,6 @@ longbridge shareholder AAPL.US ### Request Example - - - -longbridge shareholder TSLA.US -longbridge shareholder AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/fundamental/valuation_history.md b/docs/en/docs/fundamental/fundamental/valuation_history.md new file mode 100644 index 00000000..70df1191 --- /dev/null +++ b/docs/en/docs/fundamental/fundamental/valuation_history.md @@ -0,0 +1,239 @@ +--- +slug: valuation-history +title: Valuation History +sidebar_position: 15 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get historical valuation metric time series (PE, PB, PS, dividend yield). + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/valuation_history
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.valuation_history("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.valuation_history("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.valuationHistory('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.getValuationHistory("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.valuation_history("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.valuation_history("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.ValuationHistory(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "date": "2024-03-31", + "pe": 28.5, + "pb": 46.2, + "ps": 7.8, + "dividend_yield": 0.55 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ValuationHistoryResponse](#ValuationHistoryResponse) | +| 400 | Bad request | None | + +## Schemas + +### ValuationHistoryResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | Security symbol | +| list | object[] | true | Historical valuation data points | +| list[].date | string | false | Date (YYYY-MM-DD) | +| list[].pe | double | false | Price-to-Earnings ratio | +| list[].pb | double | false | Price-to-Book ratio | +| list[].ps | double | false | Price-to-Sales ratio | +| list[].dividend_yield | double | false | Dividend yield (%) | diff --git a/docs/en/docs/fundamental/fundamental/valuations.md b/docs/en/docs/fundamental/fundamental/valuations.md index cedc078e..fde41e69 100644 --- a/docs/en/docs/fundamental/fundamental/valuations.md +++ b/docs/en/docs/fundamental/fundamental/valuations.md @@ -40,14 +40,6 @@ longbridge valuation AAPL.US ### Request Example - - - -longbridge valuation TSLA.US --indicator pe -longbridge valuation AAPL.US - - - ```python diff --git a/docs/en/docs/fundamental/market/_category_.json b/docs/en/docs/fundamental/market/_category_.json index 84636e61..4b3b7b52 100644 --- a/docs/en/docs/fundamental/market/_category_.json +++ b/docs/en/docs/fundamental/market/_category_.json @@ -2,6 +2,6 @@ "position": 2, "label": "Market", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/en/docs/fundamental/market/ah_premium.md b/docs/en/docs/fundamental/market/ah_premium.md index cdfbd58e..a98e3970 100644 --- a/docs/en/docs/fundamental/market/ah_premium.md +++ b/docs/en/docs/fundamental/market/ah_premium.md @@ -39,14 +39,6 @@ longbridge ah-premium 0939.HK ### Request Example - - - -longbridge ah-premium 939.HK -longbridge ah-premium 0939.HK - - - ```python diff --git a/docs/en/docs/fundamental/market/ah_premium_intraday.md b/docs/en/docs/fundamental/market/ah_premium_intraday.md new file mode 100644 index 00000000..d8d24256 --- /dev/null +++ b/docs/en/docs/fundamental/market/ah_premium_intraday.md @@ -0,0 +1,212 @@ +--- +slug: ah-premium-intraday +title: A/H Premium Intraday +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get intraday A/H premium timeseries data for a dual-listed security. + + +longbridge ah-premium intraday 939.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/ah_premium_intraday
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | HK-side symbol of a dual-listed stock, e.g. `939.HK` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.ah_premium_intraday("939.HK") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.ah_premium_intraday("939.HK") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.ahPremiumIntraday('939.HK') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getAhPremiumIntraday("939.HK").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.ah_premium_intraday("939.HK").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.AhPremiumIntraday(context.Background(), "939.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "939.HK", + "timeseries": [ + { + "timestamp": "1774310400", + "premium": "2.35" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [ah_premium_intraday_rsp](#ah_premium_intraday_rsp) | +| 400 | Bad request | None | + +## Schemas + +### ah_premium_intraday_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | HK-side security symbol | +| timeseries | object[] | true | Intraday A/H premium timeseries | +| ∟ timestamp | string | true | Unix timestamp | +| ∟ premium | string | true | A/H premium percentage | diff --git a/docs/en/docs/fundamental/market/broker_holding_daily.md b/docs/en/docs/fundamental/market/broker_holding_daily.md new file mode 100644 index 00000000..f9831026 --- /dev/null +++ b/docs/en/docs/fundamental/market/broker_holding_daily.md @@ -0,0 +1,217 @@ +--- +slug: broker-holding-daily +title: Broker Holding Daily +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get daily holding history for a specific broker in an HK-listed security. + + +longbridge broker-holding daily 700.HK --broker B01224 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_holding_daily
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | HK security symbol, e.g. `700.HK` | +| broker_id | string | YES | Broker participant ID, e.g. `B01224` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_holding_daily("700.HK", "B01224") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_holding_daily("700.HK", "B01224") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.brokerHoldingDaily('700.HK', 'B01224') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerHoldingDaily("700.HK", "B01224").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_holding_daily("700.HK", "B01224").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerHoldingDaily(context.Background(), "700.HK", "B01224") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "broker_id": "B01224", + "broker_name": "HSBC Securities", + "history": [ + { + "date": "2024-01-15", + "holding_qty": "500000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [broker_holding_daily_rsp](#broker_holding_daily_rsp) | +| 400 | Bad request | None | + +## Schemas + +### broker_holding_daily_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | HK security symbol | +| broker_id | string | true | Broker participant ID | +| broker_name | string | true | Broker name | +| history | object[] | true | Daily holding history | +| ∟ date | string | true | Date (YYYY-MM-DD) | +| ∟ holding_qty | string | true | Holding quantity on that date | diff --git a/docs/en/docs/fundamental/market/broker_holding_detail.md b/docs/en/docs/fundamental/market/broker_holding_detail.md new file mode 100644 index 00000000..fe37be00 --- /dev/null +++ b/docs/en/docs/fundamental/market/broker_holding_detail.md @@ -0,0 +1,216 @@ +--- +slug: broker-holding-detail +title: Broker Holding Detail +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +Get full broker holding detail list for an HK-listed security (all brokers and their positions). + + +longbridge broker-holding detail 700.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_holding_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | YES | HK security symbol, e.g. `700.HK` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_holding_detail("700.HK") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_holding_detail("700.HK") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.brokerHoldingDetail('700.HK') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerHoldingDetail("700.HK").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_holding_detail("700.HK").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerHoldingDetail(context.Background(), "700.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "updated_at": "1774310400", + "brokers": [ + { + "broker_id": "B01224", + "broker_name": "HSBC Securities", + "holding_qty": "500000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | Success | [broker_holding_detail_rsp](#broker_holding_detail_rsp) | +| 400 | Bad request | None | + +## Schemas + +### broker_holding_detail_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | HK security symbol | +| updated_at | string | true | Last updated Unix timestamp | +| brokers | object[] | true | Broker holding list | +| ∟ broker_id | string | true | Broker participant ID | +| ∟ broker_name | string | true | Broker name | +| ∟ holding_qty | string | true | Holding quantity | diff --git a/docs/en/docs/fundamental/market/broker_positions.md b/docs/en/docs/fundamental/market/broker_positions.md index b91042ba..1d97337b 100644 --- a/docs/en/docs/fundamental/market/broker_positions.md +++ b/docs/en/docs/fundamental/market/broker_positions.md @@ -39,14 +39,6 @@ longbridge broker-holding 9988.HK ### Request Example - - - -longbridge broker-holding 700.HK -longbridge broker-holding 9988.HK - - - ```python diff --git a/docs/en/docs/fundamental/market/index_components.md b/docs/en/docs/fundamental/market/index_components.md index 267f425d..0a6fcd73 100644 --- a/docs/en/docs/fundamental/market/index_components.md +++ b/docs/en/docs/fundamental/market/index_components.md @@ -39,14 +39,6 @@ longbridge constituent SPY.US ### Request Example - - - -longbridge constituent HSI.HK -longbridge constituent SPY.US - - - ```python diff --git a/docs/en/docs/fundamental/market/market_status.md b/docs/en/docs/fundamental/market/market_status.md index f0b74ff4..d7059ea1 100644 --- a/docs/en/docs/fundamental/market/market_status.md +++ b/docs/en/docs/fundamental/market/market_status.md @@ -38,13 +38,6 @@ longbridge market-status ### Request Example - - - -longbridge market-status - - - ```python diff --git a/docs/en/docs/fundamental/market/trading_stats.md b/docs/en/docs/fundamental/market/trading_stats.md index 20b84719..9224fa4f 100644 --- a/docs/en/docs/fundamental/market/trading_stats.md +++ b/docs/en/docs/fundamental/market/trading_stats.md @@ -39,14 +39,6 @@ longbridge trade-stats TSLA.US ### Request Example - - - -longbridge trade-stats 700.HK -longbridge trade-stats TSLA.US - - - ```python diff --git a/docs/en/docs/fundamental/market/unusual_items.md b/docs/en/docs/fundamental/market/unusual_items.md index ad3ea8a2..ae348193 100644 --- a/docs/en/docs/fundamental/market/unusual_items.md +++ b/docs/en/docs/fundamental/market/unusual_items.md @@ -39,14 +39,6 @@ longbridge anomaly --market HK ### Request Example - - - -longbridge anomaly --market US -longbridge anomaly --market HK - - - ```python diff --git a/docs/en/docs/fundamental/overview.md b/docs/en/docs/fundamental/overview.md new file mode 100644 index 00000000..70d32fbb --- /dev/null +++ b/docs/en/docs/fundamental/overview.md @@ -0,0 +1,51 @@ +--- +sidebar_position: 0 +id: fundamental_overview +title: Overview +slug: overview +--- + +# Fundamental API Overview + +Research and market data APIs covering company fundamentals, market structure, and financial calendars. All methods are read-only and available through the SDK. + +## FundamentalContext + +Company-level financial data and corporate information. + +| Method | Description | +|---|---| +| [company_profile](./fundamental/company-profile) | Company overview, industry, and key facts | +| [financial_report](./fundamental/financial-report) | Income statement, balance sheet, and cash flow | +| [valuations](./fundamental/valuations) | PE, PB, PS, EV/EBITDA and other valuation metrics | +| [ratings](./fundamental/ratings) | Analyst ratings and price targets | +| [dividends](./fundamental/dividends) | Historical dividend records | +| [fund_holdings](./fundamental/fund-holdings) | Institutional and fund ownership | +| [shareholders](./fundamental/shareholders) | Major shareholders | +| [executives](./fundamental/executives) | Executive team and board members | +| [corporate_actions](./fundamental/corporate-actions) | Splits, bonus issues, rights offerings | + +## MarketContext + +Market-level data including index components, broker positions, and anomaly scanning. + +| Method | Description | +|---|---| +| [market_status](./market/market-status) | Current trading session status for each market | +| [trading_stats](./market/trading-stats) | Intraday trading statistics for a symbol | +| [index_components](./market/index-components) | Constituents of a market index | +| [ah_premium](./market/ah-premium) | A/H share premium ratio for dual-listed stocks | +| [broker_positions](./market/broker-positions) | HK broker participant holdings (CCASS) | +| [unusual_items](./market/unusual-items) | Unusual price or volume movements | + +## CalendarContext + +Financial event calendars for planning around earnings, dividends, and macro releases. + +| Method | Description | +|---|---| +| [earnings_calendar](./calendar/earnings-calendar) | Upcoming and recent earnings release dates | +| [dividend_calendar](./calendar/dividend-calendar) | Ex-dividend and payment dates | +| [ipo_calendar](./calendar/ipo-calendar) | IPO subscription and listing dates | +| [split_calendar](./calendar/split-calendar) | Stock split effective dates | +| [macro_calendar](./calendar/macro-calendar) | Economic data release schedule | diff --git a/docs/zh-CN/docs/account/_category_.json b/docs/zh-CN/docs/account/_category_.json index 26a866af..3a023a9d 100644 --- a/docs/zh-CN/docs/account/_category_.json +++ b/docs/zh-CN/docs/account/_category_.json @@ -2,6 +2,7 @@ "position": 6, "label": "账户", "collapsible": true, - "collapsed": false, - "link": null + "collapsed": true, + "link": null, + "icon": "briefcase" } diff --git a/docs/zh-CN/docs/account/alert/_category_.json b/docs/zh-CN/docs/account/alert/_category_.json index cb05264d..0c6a9b46 100644 --- a/docs/zh-CN/docs/account/alert/_category_.json +++ b/docs/zh-CN/docs/account/alert/_category_.json @@ -2,6 +2,6 @@ "position": 2, "label": "价格提醒", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/account/alert/create_alert.md b/docs/zh-CN/docs/account/alert/create_alert.md index 4c0dfe8c..f5a6cf33 100644 --- a/docs/zh-CN/docs/account/alert/create_alert.md +++ b/docs/zh-CN/docs/account/alert/create_alert.md @@ -34,22 +34,14 @@ longbridge alert add AAPL.US --price 150 --direction fall | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `TSLA.US` | -| price | string | YES | Target price | -| direction | string | YES | Alert direction: `rise` or `fall` | -| frequency | string | NO | Trigger frequency: `once` (default) or `every` | +| symbol | string | 是 | 证券代码,例如 `TSLA.US` | +| price | string | 是 | 目标价格 | +| direction | string | 是 | 提醒方向:`rise`(上涨)或 `fall`(下跌) | +| frequency | string | 否 | 触发频率:`once`(仅一次,默认)或 `every`(每次) | ### Request Example - - - -longbridge alert add TSLA.US --price 300 --direction rise -longbridge alert add AAPL.US --price 150 --direction fall - - - ```python @@ -226,8 +218,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [create_alert_rsp](#create_alert_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [create_alert_rsp](#create_alert_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -237,4 +229,4 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | true | ID of the newly created alert | +| id | int64 | true | 新创建提醒的 ID | diff --git a/docs/zh-CN/docs/account/alert/delete_alert.md b/docs/zh-CN/docs/account/alert/delete_alert.md index 3c099e4a..cf5eec60 100644 --- a/docs/zh-CN/docs/account/alert/delete_alert.md +++ b/docs/zh-CN/docs/account/alert/delete_alert.md @@ -34,19 +34,11 @@ longbridge alert delete 112326 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Alert ID (path parameter) | +| id | int64 | 是 | 提醒 ID(路径参数) | ### Request Example - - - -longbridge alert delete 486469 -longbridge alert delete 112326 - - - ```python @@ -221,8 +213,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [delete_alert_rsp](#delete_alert_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [delete_alert_rsp](#delete_alert_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -230,4 +222,4 @@ func main() { -No response body fields. +无响应体字段。 diff --git a/docs/zh-CN/docs/account/alert/disable_alert.md b/docs/zh-CN/docs/account/alert/disable_alert.md new file mode 100644 index 00000000..39c45a51 --- /dev/null +++ b/docs/zh-CN/docs/account/alert/disable_alert.md @@ -0,0 +1,183 @@ +--- +slug: disable-alert +title: 暂停提醒 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +暂停一个价格提醒而不删除它。 + + +longbridge alert disable 486469 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/{alert_id}/disable
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| alert_id | string | 是 | 要暂停的提醒 ID | + +### Request Example + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +ctx.disable("486469") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + await ctx.disable("486469") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + await ctx.disable('486469') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + ctx.disable("486469").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + ctx.disable("486469").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Disable(context.Background(), "486469"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/alert/enable_alert.md b/docs/zh-CN/docs/account/alert/enable_alert.md new file mode 100644 index 00000000..17fad39a --- /dev/null +++ b/docs/zh-CN/docs/account/alert/enable_alert.md @@ -0,0 +1,183 @@ +--- +slug: enable-alert +title: 启用提醒 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +重新启用一个已暂停的价格提醒。 + + +longbridge alert enable 486469 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/{alert_id}/enable
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| alert_id | string | 是 | 要启用的提醒 ID | + +### Request Example + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +ctx.enable("486469") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + await ctx.enable("486469") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + await ctx.enable('486469') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + ctx.enable("486469").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + ctx.enable("486469").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Enable(context.Background(), "486469"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/alert/list_alerts.md b/docs/zh-CN/docs/account/alert/list_alerts.md index df3da496..c9e19cb0 100644 --- a/docs/zh-CN/docs/account/alert/list_alerts.md +++ b/docs/zh-CN/docs/account/alert/list_alerts.md @@ -34,19 +34,11 @@ longbridge alert TSLA.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | NO | Filter by security symbol, e.g. `TSLA.US` | +| symbol | string | 否 | 按证券代码筛选,例如 `TSLA.US` | ### Request Example - - - -longbridge alert -longbridge alert TSLA.US - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [list_alerts_rsp](#list_alerts_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [list_alerts_rsp](#list_alerts_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -243,10 +235,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Alert list | -| ∟ id | int64 | true | Alert ID | -| ∟ symbol | string | true | Security symbol | -| ∟ price | string | true | Target price | -| ∟ direction | string | true | Direction: `rise` or `fall` | -| ∟ enabled | bool | true | Whether alert is enabled | -| ∟ frequency | string | true | Trigger frequency: `once` or `every` | +| list | object[] | true | 提醒列表 | +| ∟ id | int64 | true | 提醒 ID | +| ∟ symbol | string | true | 证券代码 | +| ∟ price | string | true | 目标价格 | +| ∟ direction | string | true | 方向:`rise`(上涨)或 `fall`(下跌) | +| ∟ enabled | bool | true | 提醒是否启用 | +| ∟ frequency | string | true | 触发频率:`once`(仅一次)或 `every`(每次) | diff --git a/docs/zh-CN/docs/account/alert/update_alert.md b/docs/zh-CN/docs/account/alert/update_alert.md index b1f200a2..c402750d 100644 --- a/docs/zh-CN/docs/account/alert/update_alert.md +++ b/docs/zh-CN/docs/account/alert/update_alert.md @@ -34,20 +34,12 @@ longbridge alert disable 112326 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Alert ID (path parameter) | -| enabled | bool | YES | Set to `true` to enable or `false` to disable | +| id | int64 | 是 | 提醒 ID(路径参数) | +| enabled | bool | 是 | 设为 `true` 启用,`false` 禁用 | ### Request Example - - - -longbridge alert enable 112326 -longbridge alert disable 112326 - - - ```python @@ -222,8 +214,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [update_alert_rsp](#update_alert_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [update_alert_rsp](#update_alert_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -231,4 +223,4 @@ func main() { -No response body fields. +无响应体字段。 diff --git a/docs/zh-CN/docs/account/dca/_category_.json b/docs/zh-CN/docs/account/dca/_category_.json index 8c756ffd..2417ac35 100644 --- a/docs/zh-CN/docs/account/dca/_category_.json +++ b/docs/zh-CN/docs/account/dca/_category_.json @@ -2,6 +2,6 @@ "position": 3, "label": "定投计划", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/account/dca/calc_date.md b/docs/zh-CN/docs/account/dca/calc_date.md new file mode 100644 index 00000000..89014b11 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/calc_date.md @@ -0,0 +1,211 @@ +--- +slug: calc-date +title: 计算定投日期 +sidebar_position: 10 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +根据给定的定投计划参数,计算下一次预计交易日期。 + + +longbridge dca calc-date AAPL.US --frequency monthly --day-of-month 15 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/calc_date
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 标的代码 | +| frequency | string | 是 | 定投频率:`daily`、`weekly`、`fortnightly`、`monthly` | +| day_of_week | string | 否 | 每周计划的执行星期:`mon`–`fri` | +| day_of_month | integer | 否 | 每月/每两周计划的执行日期:1–28 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder, DCAFrequency + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.calc_date("AAPL.US", DCAFrequency.Monthly, day_of_month=15) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, Config, OAuthBuilder, DCAFrequency + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncDCAContext.create(config) + + resp = await ctx.calc_date("AAPL.US", DCAFrequency.Monthly, day_of_month=15) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, OAuth, DCAFrequency } = 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 = DCAContext.new(config) + const resp = await ctx.calcDate('AAPL.US', DCAFrequency.Monthly, undefined, 15) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var opts = new CalcDateOptions("AAPL.US", DCAFrequency.MONTHLY).dayOfMonth(15); + var resp = ctx.calcDate(opts).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, dca::DCAFrequency, 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 = DCAContext::new(config); + let resp = ctx.calc_date("AAPL.US", DCAFrequency::Monthly, None, Some(15)).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + dayOfMonth := 15 + opts := &dca.CalcDateOptions{ + Symbol: "AAPL.US", + Frequency: dca.FrequencyMonthly, + DayOfMonth: &dayOfMonth, + } + resp, err := c.CalcDate(context.Background(), opts) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "trade_date": "2024-02-15" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DcaCalcDateResult](#DcaCalcDateResult) | +| 400 | 请求错误 | None | + +## Schemas + +### DcaCalcDateResult + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| trade_date | string | true | 下一次预计交易日期(YYYY-MM-DD) | diff --git a/docs/zh-CN/docs/account/dca/check_support.md b/docs/zh-CN/docs/account/dca/check_support.md new file mode 100644 index 00000000..a7151700 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/check_support.md @@ -0,0 +1,212 @@ +--- +slug: check-support +title: 检查定投支持 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +检查指定标的是否支持定投。 + + +longbridge dca check AAPL.US 700.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/support
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbols | string[] | 是 | 待检查的标的代码列表 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.check_support(["AAPL.US", "700.HK"]) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.check_support(["AAPL.US", "700.HK"]) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.checkSupport(['AAPL.US', '700.HK']) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; +import java.util.Arrays; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.checkSupport(Arrays.asList("AAPL.US", "700.HK")).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.check_support(vec!["AAPL.US".into(), "700.HK".into()]).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CheckSupport(context.Background(), []string{"AAPL.US", "700.HK"}) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { "symbol": "AAPL.US", "support": true }, + { "symbol": "700.HK", "support": true } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DcaSupportList](#DcaSupportList) | +| 400 | 请求错误 | None | + +## Schemas + +### DcaSupportList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | DcaSupportItem[] | true | 支持情况列表 | + +### DcaSupportItem + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | 标的代码 | +| support | boolean | true | 是否支持定投 | diff --git a/docs/zh-CN/docs/account/dca/create_dca.md b/docs/zh-CN/docs/account/dca/create_dca.md index b48edb95..3a59a898 100644 --- a/docs/zh-CN/docs/account/dca/create_dca.md +++ b/docs/zh-CN/docs/account/dca/create_dca.md @@ -34,23 +34,15 @@ longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| amount | string | YES | Recurring investment amount | -| frequency | string | YES | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | -| day_of_week | string | NO | Day of week for weekly/fortnightly plans: `mon`–`fri` | -| day_of_month | integer | NO | Day of month for monthly plans (1–28) | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| amount | string | 是 | 定投金额 | +| frequency | string | 是 | 频率:`Daily`(每日)、`Weekly`(每周)、`Fortnightly`(每两周)、`Monthly`(每月) | +| day_of_week | string | 否 | 每周/每两周计划的执行星期:`mon`–`fri` | +| day_of_month | integer | 否 | 每月计划的执行日期(1–28) | ### Request Example - - - -longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 -longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon - - - ```python @@ -227,8 +219,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [create_dca_rsp](#create_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [create_dca_rsp](#create_dca_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -238,4 +230,4 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | true | ID of the newly created plan | +| id | string | true | 新创建计划的 ID | diff --git a/docs/zh-CN/docs/account/dca/dca_history.md b/docs/zh-CN/docs/account/dca/dca_history.md index 22a6113c..cca4c910 100644 --- a/docs/zh-CN/docs/account/dca/dca_history.md +++ b/docs/zh-CN/docs/account/dca/dca_history.md @@ -33,20 +33,13 @@ longbridge dca history 1225781523156889600 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | YES | Plan ID (path parameter) | -| page | integer | NO | Page number (1-based, default: 1) | -| size | integer | NO | Records per page (default: 20) | +| id | string | 是 | 计划 ID(路径参数) | +| page | integer | 否 | 页码(从 1 开始,默认:1) | +| size | integer | 否 | 每页数量(默认:20) | ### Request Example - - - -longbridge dca history 1225781523156889600 - - - ```python @@ -232,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [dca_history_rsp](#dca_history_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [dca_history_rsp](#dca_history_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -243,10 +236,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Trade history records | -| ∟ trade_date | string | true | Trade execution date (ISO 8601) | -| ∟ symbol | string | true | Security symbol | -| ∟ amount | string | true | Invested amount | -| ∟ price | string | false | Execution price | -| ∟ quantity | string | false | Quantity purchased | -| ∟ status | string | true | Trade status: `Filled`, `Failed` | +| list | object[] | true | 交易历史记录 | +| ∟ trade_date | string | true | 交易执行日期(ISO 8601) | +| ∟ symbol | string | true | 证券代码 | +| ∟ amount | string | true | 投入金额 | +| ∟ price | string | false | 成交价格 | +| ∟ quantity | string | false | 买入数量 | +| ∟ status | string | true | 交易状态:`Filled`(已成交)、`Failed`(失败) | diff --git a/docs/zh-CN/docs/account/dca/dca_stats.md b/docs/zh-CN/docs/account/dca/dca_stats.md new file mode 100644 index 00000000..9e8922f3 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/dca_stats.md @@ -0,0 +1,205 @@ +--- +slug: dca-stats +title: 定投统计 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取定投统计汇总信息,包括总投入金额和盈亏情况。 + + +longbridge dca stats + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/stats
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 否 | 按标的过滤 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.stats() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.stats() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.stats() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.stats(null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.stats(None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Stats(context.Background(), nil) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "total_invested": "10000.00", + "total_profit_loss": "1500.00", + "total_profit_loss_rate": "0.15" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DcaStats](#DcaStats) | +| 400 | 请求错误 | None | + +## Schemas + +### DcaStats + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| total_invested | string | true | 总投入金额 | +| total_profit_loss | string | true | 总盈亏金额 | +| total_profit_loss_rate | string | true | 总盈亏比率 | diff --git a/docs/zh-CN/docs/account/dca/delete_dca.md b/docs/zh-CN/docs/account/dca/delete_dca.md index 7eae222d..af30cc10 100644 --- a/docs/zh-CN/docs/account/dca/delete_dca.md +++ b/docs/zh-CN/docs/account/dca/delete_dca.md @@ -33,18 +33,11 @@ longbridge dca stop 1225781523156889600 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | YES | Plan ID (path parameter) | +| id | string | 是 | 计划 ID(路径参数) | ### Request Example - - - -longbridge dca stop 1225781523156889600 - - - ```python @@ -219,8 +212,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [delete_dca_rsp](#delete_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [delete_dca_rsp](#delete_dca_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -228,4 +221,4 @@ func main() { -No response body fields. +无响应体字段。 diff --git a/docs/zh-CN/docs/account/dca/list_dca.md b/docs/zh-CN/docs/account/dca/list_dca.md index 2baaa021..eb72f198 100644 --- a/docs/zh-CN/docs/account/dca/list_dca.md +++ b/docs/zh-CN/docs/account/dca/list_dca.md @@ -34,20 +34,12 @@ longbridge dca --status Active | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| status | string | NO | Filter by plan status: `Active`, `Suspended`, `Finished` | -| symbol | string | NO | Filter by security symbol | +| status | string | 否 | 按计划状态筛选:`Active`(进行中)、`Suspended`(已暂停)、`Finished`(已结束) | +| symbol | string | 否 | 按证券代码筛选 | ### Request Example - - - -longbridge dca -longbridge dca --status Active - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [list_dca_rsp](#list_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [list_dca_rsp](#list_dca_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -245,11 +237,11 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | DCA plan list | -| ∟ id | string | true | Plan ID | -| ∟ symbol | string | true | Security symbol | -| ∟ status | string | true | Plan status: `Active`, `Suspended`, `Finished` | -| ∟ amount | string | true | Recurring investment amount | -| ∟ frequency | string | true | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | -| ∟ day_of_week | string | false | Day of week for weekly/fortnightly plans | -| ∟ next_trade_date | string | false | Next scheduled trade date (ISO 8601) | +| list | object[] | true | 定投计划列表 | +| ∟ id | string | true | 计划 ID | +| ∟ symbol | string | true | 证券代码 | +| ∟ status | string | true | 计划状态:`Active`(进行中)、`Suspended`(已暂停)、`Finished`(已结束) | +| ∟ amount | string | true | 定投金额 | +| ∟ frequency | string | true | 频率:`Daily`(每日)、`Weekly`(每周)、`Fortnightly`(每两周)、`Monthly`(每月) | +| ∟ day_of_week | string | false | 每周/每两周计划的执行星期 | +| ∟ next_trade_date | string | false | 下次计划交易日期(ISO 8601) | diff --git a/docs/zh-CN/docs/account/dca/pause_dca.md b/docs/zh-CN/docs/account/dca/pause_dca.md new file mode 100644 index 00000000..58f24e5b --- /dev/null +++ b/docs/zh-CN/docs/account/dca/pause_dca.md @@ -0,0 +1,181 @@ +--- +slug: pause-dca +title: 暂停定投计划 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +暂停一个定投计划。计划暂停后可随时恢复。 + + +longbridge dca pause 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/pause
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | 是 | 定投计划 ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.pause("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.pause("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.pause('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.pause("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.pause("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Pause(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/dca/resume_dca.md b/docs/zh-CN/docs/account/dca/resume_dca.md new file mode 100644 index 00000000..e891ffe3 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/resume_dca.md @@ -0,0 +1,181 @@ +--- +slug: resume-dca +title: 恢复定投计划 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +恢复一个已暂停的定投计划。 + + +longbridge dca resume 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/resume
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | 是 | 定投计划 ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.resume("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.resume("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.resume('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.resume("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.resume("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Resume(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/dca/set_reminder.md b/docs/zh-CN/docs/account/dca/set_reminder.md new file mode 100644 index 00000000..3968cb03 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/set_reminder.md @@ -0,0 +1,183 @@ +--- +slug: set-reminder +title: 设置定投提醒 +sidebar_position: 11 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +设置定投计划的提前提醒时间。支持的值:`1`、`6` 或 `12` 小时。 + + +longbridge dca set-reminder 12 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/reminder
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| hours | string | 是 | 提醒提前小时数:`1`、`6` 或 `12` | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.set_reminder("12") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.set_reminder("12") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.setReminder('12') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.setReminder("12").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.set_reminder("12").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.SetReminder(context.Background(), "12"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/dca/stop_dca.md b/docs/zh-CN/docs/account/dca/stop_dca.md new file mode 100644 index 00000000..fafc3a34 --- /dev/null +++ b/docs/zh-CN/docs/account/dca/stop_dca.md @@ -0,0 +1,181 @@ +--- +slug: stop-dca +title: 终止定投计划 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +永久终止一个定投计划。此操作不可撤销。 + + +longbridge dca stop 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/stop
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | 是 | 定投计划 ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.stop("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.stop("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.stop('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.stop("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.stop("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Stop(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/dca/update_dca.md b/docs/zh-CN/docs/account/dca/update_dca.md index d28e5aec..f6ff8b2e 100644 --- a/docs/zh-CN/docs/account/dca/update_dca.md +++ b/docs/zh-CN/docs/account/dca/update_dca.md @@ -34,20 +34,12 @@ longbridge dca resume 1225781523156889600 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | YES | Plan ID (path parameter) | -| action | string | YES | Action to perform: `pause` or `resume` | +| id | string | 是 | 计划 ID(路径参数) | +| action | string | 是 | 执行操作:`pause`(暂停)或 `resume`(恢复) | ### Request Example - - - -longbridge dca pause 1225781523156889600 -longbridge dca resume 1225781523156889600 - - - ```python @@ -222,8 +214,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [update_dca_rsp](#update_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [update_dca_rsp](#update_dca_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -231,4 +223,4 @@ func main() { -No response body fields. +无响应体字段。 diff --git a/docs/zh-CN/docs/account/overview.md b/docs/zh-CN/docs/account/overview.md new file mode 100644 index 00000000..4d3a1331 --- /dev/null +++ b/docs/zh-CN/docs/account/overview.md @@ -0,0 +1,55 @@ +--- +sidebar_position: 0 +id: account_overview +title: 概览 +slug: overview +--- + +# 账户 API 概览 + +账户管理接口,涵盖组合分析、价格提醒、定投计划和股单管理。大多数接口需要交易级别的认证权限。 + +## PortfolioContext + +组合盈亏分析与外汇汇率查询。 + +| 方法 | 说明 | +|---|---| +| [profit_analysis_summary](./portfolio/profit-analysis-summary) | 组合整体盈亏汇总 | +| [profit_analysis_detail](./portfolio/profit-analysis-detail) | 按持仓明细的盈亏拆分 | +| [profit_analysis_by_market](./portfolio/profit-analysis-by-market) | 按市场分组的盈亏统计 | +| [capital_flow](./portfolio/capital-flow) | 账户资金流水记录 | +| [exchange_rates](./portfolio/exchange-rates) | 支持币种的当前汇率 | + +## AlertContext + +创建和管理标的价格提醒。 + +| 方法 | 说明 | +|---|---| +| [list_alerts](./alert/list-alerts) | 查看所有有效的价格提醒 | +| [create_alert](./alert/create-alert) | 创建新的价格提醒 | +| [update_alert](./alert/update-alert) | 修改已有提醒 | +| [delete_alert](./alert/delete-alert) | 删除价格提醒 | + +## DCAContext + +管理定期定额投资(定投)计划。 + +| 方法 | 说明 | +|---|---| +| [list_dca](./dca/list-dca) | 查看所有定投计划 | +| [create_dca](./dca/create-dca) | 新建定投计划 | +| [dca_history](./dca/dca-history) | 查看定投计划的执行记录 | +| [delete_dca](./dca/delete-dca) | 取消定投计划 | + +## SharelistContext + +创建和管理社区股单(可分享给他人的自选列表)。 + +| 方法 | 说明 | +|---|---| +| [list_sharelist](./sharelist/list-sharelist) | 查看所有股单 | +| [create_sharelist](./sharelist/create-sharelist) | 新建股单 | +| [update_sharelist](./sharelist/update-sharelist) | 更新股单 | +| [delete_sharelist](./sharelist/delete-sharelist) | 删除股单 | diff --git a/docs/zh-CN/docs/account/portfolio/_category_.json b/docs/zh-CN/docs/account/portfolio/_category_.json index a9617cb4..2b2ce20a 100644 --- a/docs/zh-CN/docs/account/portfolio/_category_.json +++ b/docs/zh-CN/docs/account/portfolio/_category_.json @@ -2,6 +2,6 @@ "position": 1, "label": "投资组合", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/account/portfolio/exchange_rates.md b/docs/zh-CN/docs/account/portfolio/exchange_rates.md index 28c79903..e5154871 100644 --- a/docs/zh-CN/docs/account/portfolio/exchange_rates.md +++ b/docs/zh-CN/docs/account/portfolio/exchange_rates.md @@ -33,18 +33,11 @@ longbridge exchange-rate | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| base | string | NO | Base currency, e.g. `USD`. Omit for all pairs. | +| base | string | 否 | 基础货币,例如 `USD`,不传则返回所有货币对 | ### Request Example - - - -longbridge exchange-rate - - - ```python @@ -228,8 +221,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [exchange_rates_rsp](#exchange_rates_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [exchange_rates_rsp](#exchange_rates_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -239,8 +232,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Exchange rate list | -| ∟ pair | string | true | Currency pair, e.g. `HKD/USD` | -| ∟ bid_rate | string | true | Bid rate | -| ∟ offer_rate | string | true | Offer rate | -| ∟ average_rate | string | true | Average rate | +| list | object[] | true | 汇率列表 | +| ∟ pair | string | true | 货币对,例如 `HKD/USD` | +| ∟ bid_rate | string | true | 买入汇率 | +| ∟ offer_rate | string | true | 卖出汇率 | +| ∟ average_rate | string | true | 中间汇率 | diff --git a/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md index 26531851..cc5ac6b0 100644 --- a/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_by_market.md @@ -34,20 +34,12 @@ longbridge profit-analysis --start 2026-01-01 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | -| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | +| start_date | string | 否 | 分析开始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 分析结束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge profit-analysis --format json -longbridge profit-analysis --start 2026-01-01 - - - ```python @@ -239,8 +231,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -250,9 +242,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | P&L by market list | -| ∟ market | string | true | Market code | -| ∟ pnl | string | true | P&L for this market | -| ∟ pnl_pct | string | true | P&L percentage | -| ∟ market_value | string | false | Market value | -| ∟ currency | string | true | Settlement currency | +| list | object[] | true | 按市场盈亏列表 | +| ∟ market | string | true | 市场代码 | +| ∟ pnl | string | true | 该市场盈亏金额 | +| ∟ pnl_pct | string | true | 盈亏百分比 | +| ∟ market_value | string | false | 市值 | +| ∟ currency | string | true | 结算货币 | diff --git a/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md index 1865c13e..296aea04 100644 --- a/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_detail.md @@ -34,21 +34,13 @@ longbridge profit-analysis detail AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `TSLA.US` | -| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | -| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | +| symbol | string | 是 | 证券代码,例如 `TSLA.US` | +| start_date | string | 否 | 分析开始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 分析结束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge profit-analysis detail TSLA.US -longbridge profit-analysis detail AAPL.US - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -242,10 +234,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | true | Security symbol | -| name | string | true | Security name | -| pnl | string | true | Total P&L | -| pnl_pct | string | true | P&L percentage | -| cost | string | true | Total cost basis | -| market_value | string | false | Current market value | -| currency | string | true | Currency | +| symbol | string | true | 证券代码 | +| name | string | true | 证券名称 | +| pnl | string | true | 总盈亏金额 | +| pnl_pct | string | true | 盈亏百分比 | +| cost | string | true | 总成本 | +| market_value | string | false | 当前市值 | +| currency | string | true | 货币 | diff --git a/docs/zh-CN/docs/account/portfolio/capital_flow.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_flows.md similarity index 75% rename from docs/zh-CN/docs/account/portfolio/capital_flow.md rename to docs/zh-CN/docs/account/portfolio/profit_analysis_flows.md index a8cbf4c8..d7112cff 100644 --- a/docs/zh-CN/docs/account/portfolio/capital_flow.md +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_flows.md @@ -1,6 +1,6 @@ --- -slug: capital-flow -title: 资金流水 +slug: profit-analysis-flows +title: 盈亏流水 sidebar_position: 5 language_tabs: false toc_footers: [] @@ -17,14 +17,14 @@ longbridge cash-flow longbridge cash-flow --format json - + ## Request - +
HTTP MethodGET
HTTP URL/v1/account/capital_flow
HTTP URL/v1/account/profit_analysis/flows
@@ -34,24 +34,14 @@ longbridge cash-flow --format json | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_time | integer | NO | Start time as Unix timestamp (seconds) | -| end_time | integer | NO | End time as Unix timestamp (seconds) | -| business_type | integer | NO | Business type filter. Omit for all types. | -| symbol | string | NO | Filter by security symbol | -| page | integer | NO | Page number (1-based, default: 1) | -| size | integer | NO | Records per page (default: 20) | +| symbol | string | YES | 证券代码 | +| page | integer | NO | 页码(默认 1) | +| size | integer | NO | 每页数量(默认 20) | +| derivative | boolean | NO | 是否包含衍生品仓位 | ### Request Example - - - -longbridge cash-flow -longbridge cash-flow --format json - - - ```python @@ -61,7 +51,7 @@ oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) config = Config.from_oauth(oauth) ctx = PortfolioContext(config) -resp = ctx.capital_flow() +resp = ctx.profit_analysis_flows() print(resp) ``` @@ -77,7 +67,7 @@ async def main() -> None: config = Config.from_oauth(oauth) ctx = AsyncPortfolioContext.create(config) - resp = await ctx.capital_flow() + resp = await ctx.profit_analysis_flows() print(resp) if __name__ == "__main__": @@ -96,7 +86,7 @@ async function main() { }) const config = Config.fromOAuth(oauth) const ctx = PortfolioContext.new(config) - const resp = await ctx.capital_flow() + const resp = await ctx.profit_analysis_flows() console.log(resp) } main().catch(console.error) @@ -114,7 +104,7 @@ class Main { try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); Config config = Config.fromOAuth(oauth); PortfolioContext ctx = PortfolioContext.create(config)) { - var resp = ctx.getCapitalFlow().get(); + var resp = ctx.getProfitAnalysisFlows().get(); System.out.println(resp); } } @@ -133,7 +123,7 @@ 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 = PortfolioContext::new(config); - let resp = ctx.capital_flow().await?; + let resp = ctx.profit_analysis_flows().await?; println!("{:?}", resp); Ok(()) } @@ -156,7 +146,7 @@ int main() { if (!res) return; Config config = Config::from_oauth(*res); PortfolioContext ctx = PortfolioContext::create(config); - ctx.capital_flow([](auto resp) { + ctx.profit_analysis_flows([](auto resp) { if (resp) std::cout << "OK" << std::endl; }); }); @@ -195,7 +185,7 @@ func main() { log.Fatal(err) } defer c.Close() - resp, err := c.CapitalFlow(context.Background()) + resp, err := c.ProfitAnalysisFlows(context.Background()) if err != nil { log.Fatal(err) } @@ -238,22 +228,22 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [capital_flow_rsp](#capital_flow_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_flows_rsp](#profit_analysis_flows_rsp) | +| 400 | 请求错误 | None | ## Schemas -### capital_flow_rsp +### profit_analysis_flows_rsp - + | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Cash flow records | -| ∟ transaction_flow_name | string | true | Flow type description | -| ∟ direction | int32 | true | `1` = inflow, `-1` = outflow | -| ∟ business_type | int32 | true | Business type code | -| ∟ balance | string | true | Amount | -| ∟ currency | string | true | Currency | -| ∟ business_time | string | true | Transaction time as Unix timestamp | -| ∟ symbol | string | false | Associated security symbol | +| list | object[] | true | 资金流水记录 | +| ∟ transaction_flow_name | string | true | 流水类型描述 | +| ∟ direction | int32 | true | `1` 表示入账,`-1` 表示出账 | +| ∟ business_type | int32 | true | 业务类型编码 | +| ∟ balance | string | true | 金额 | +| ∟ currency | string | true | 货币 | +| ∟ business_time | string | true | 交易时间,Unix 时间戳 | +| ∟ symbol | string | false | 关联证券代码 | diff --git a/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md b/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md index a577386c..5b563f79 100644 --- a/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md +++ b/docs/zh-CN/docs/account/portfolio/profit_analysis_summary.md @@ -34,20 +34,12 @@ longbridge profit-analysis --start 2026-01-01 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | -| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | +| start_date | string | 否 | 分析开始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 分析结束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge profit-analysis -longbridge profit-analysis --start 2026-01-01 - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -243,12 +235,12 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| currency | string | true | Settlement currency | -| total_asset | string | true | Total asset value | -| invest_amount | string | true | Total invested amount | -| total_pnl | string | true | Total P&L | -| simple_yield | string | true | Simple yield ratio | -| twr | string | true | Time-weighted return | -| stocks_traded | int32 | true | Number of stocks traded | -| start_date | string | true | Analysis start date | -| end_date | string | true | Analysis end date | +| currency | string | true | 结算货币 | +| total_asset | string | true | 总资产价值 | +| invest_amount | string | true | 总投入金额 | +| total_pnl | string | true | 总盈亏金额 | +| simple_yield | string | true | 简单收益率 | +| twr | string | true | 时间加权收益率 | +| stocks_traded | int32 | true | 已交易股票数量 | +| start_date | string | true | 分析开始日期 | +| end_date | string | true | 分析结束日期 | diff --git a/docs/zh-CN/docs/account/sharelist/_category_.json b/docs/zh-CN/docs/account/sharelist/_category_.json index fc9f8184..9d8347ed 100644 --- a/docs/zh-CN/docs/account/sharelist/_category_.json +++ b/docs/zh-CN/docs/account/sharelist/_category_.json @@ -2,6 +2,6 @@ "position": 4, "label": "自选股", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/account/sharelist/add_securities.md b/docs/zh-CN/docs/account/sharelist/add_securities.md new file mode 100644 index 00000000..550abb92 --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/add_securities.md @@ -0,0 +1,185 @@ +--- +slug: add-securities +title: 添加标的到股单 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +向股单中添加一个或多个标的。 + + +longbridge sharelist add 123 TSLA.US AAPL.US + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/sharelist/{id}/securities
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股单 ID | +| symbols | string[] | 是 | 待添加的标的代码 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.add_securities(123, ["TSLA.US", "AAPL.US"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.add_securities(123, ["TSLA.US", "AAPL.US"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.addSecurities(123, ['TSLA.US', 'AAPL.US']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.addSecurities(123, Arrays.asList("TSLA.US", "AAPL.US")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.add_securities(123, vec!["TSLA.US".into(), "AAPL.US".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.AddSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/sharelist/create_sharelist.md b/docs/zh-CN/docs/account/sharelist/create_sharelist.md index 3d7c2e80..a9af441f 100644 --- a/docs/zh-CN/docs/account/sharelist/create_sharelist.md +++ b/docs/zh-CN/docs/account/sharelist/create_sharelist.md @@ -33,20 +33,13 @@ longbridge sharelist create --name "AI Picks" --description "Top AI infrastructu | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| name | string | YES | Sharelist name | -| description | string | NO | Description | -| securities | string[] | NO | Initial list of security symbols, e.g. `["AAPL.US", "NVDA.US"]` | +| name | string | 是 | 股单名称 | +| description | string | 否 | 描述 | +| securities | string[] | 否 | 初始证券代码列表,例如 `["AAPL.US", "NVDA.US"]` | ### Request Example - - - -longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" - - - ```python @@ -223,8 +216,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [create_sharelist_rsp](#create_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [create_sharelist_rsp](#create_sharelist_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -234,4 +227,4 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | true | ID of the newly created sharelist | +| id | int64 | true | 新创建股单的 ID | diff --git a/docs/zh-CN/docs/account/sharelist/delete_sharelist.md b/docs/zh-CN/docs/account/sharelist/delete_sharelist.md index f11b4e0d..0be8fe75 100644 --- a/docs/zh-CN/docs/account/sharelist/delete_sharelist.md +++ b/docs/zh-CN/docs/account/sharelist/delete_sharelist.md @@ -33,18 +33,11 @@ longbridge sharelist delete 15921 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Sharelist ID (path parameter) | +| id | int64 | 是 | 股单 ID(路径参数) | ### Request Example - - - -longbridge sharelist delete 15921 - - - ```python @@ -219,8 +212,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [delete_sharelist_rsp](#delete_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [delete_sharelist_rsp](#delete_sharelist_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -228,4 +221,4 @@ func main() { -No response body fields. +无响应体字段。 diff --git a/docs/zh-CN/docs/account/sharelist/list_sharelist.md b/docs/zh-CN/docs/account/sharelist/list_sharelist.md index d930390f..d631074a 100644 --- a/docs/zh-CN/docs/account/sharelist/list_sharelist.md +++ b/docs/zh-CN/docs/account/sharelist/list_sharelist.md @@ -34,19 +34,11 @@ longbridge sharelist --format json | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| type | string | NO | Filter: `mine` or `subscribed`. Omit for both. | +| type | string | 否 | 筛选:`mine`(我创建的)或 `subscribed`(我订阅的),不传则返回两者 | ### Request Example - - - -longbridge sharelist -longbridge sharelist --format json - - - ```python @@ -233,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [list_sharelist_rsp](#list_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [list_sharelist_rsp](#list_sharelist_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -244,11 +236,11 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| mine | object[] | true | Sharelists created by the user | -| subscribed | object[] | true | Sharelists subscribed by the user | -| ∟ id | int64 | true | Sharelist ID | -| ∟ name | string | true | Sharelist name | -| ∟ type | string | true | Type: `Regular`, `Official` | -| ∟ day_change | string | false | Day change percentage | -| ∟ ytd_change | string | false | Year-to-date change | -| ∟ subscribers | int32 | false | Subscriber count | +| mine | object[] | true | 用户创建的股单 | +| subscribed | object[] | true | 用户订阅的股单 | +| ∟ id | int64 | true | 股单 ID | +| ∟ name | string | true | 股单名称 | +| ∟ type | string | true | 类型:`Regular`(普通)、`Official`(官方) | +| ∟ day_change | string | false | 当日涨跌幅 | +| ∟ ytd_change | string | false | 年初至今涨跌幅 | +| ∟ subscribers | int32 | false | 订阅人数 | diff --git a/docs/zh-CN/docs/account/sharelist/popular_sharelist.md b/docs/zh-CN/docs/account/sharelist/popular_sharelist.md new file mode 100644 index 00000000..d20503ee --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/popular_sharelist.md @@ -0,0 +1,212 @@ +--- +slug: popular-sharelist +title: 热门股单 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取社区热门股单列表。 + + +longbridge sharelist popular --count 10 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/sharelist/popular
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| count | integer | 否 | 返回数量上限,默认 20 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.popular(10) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.popular(10) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.popular(10) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.popular(10).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.popular(10).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Popular(context.Background(), 10) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { "id": 123, "name": "AI Picks", "description": "Top AI infrastructure stocks" }, + { "id": 456, "name": "EV Leaders", "description": "Electric vehicle sector leaders" } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [SharelistList](#SharelistList) | +| 400 | 请求错误 | None | + +## Schemas + +### SharelistList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | SharelistItem[] | true | 股单列表 | + +### SharelistItem + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | 股单 ID | +| name | string | true | 股单名称 | +| description | string | false | 描述 | diff --git a/docs/zh-CN/docs/account/sharelist/remove_securities.md b/docs/zh-CN/docs/account/sharelist/remove_securities.md new file mode 100644 index 00000000..e1a0ef97 --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/remove_securities.md @@ -0,0 +1,185 @@ +--- +slug: remove-securities +title: 从股单移除标的 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +从股单中移除一个或多个标的。 + + +longbridge sharelist remove 123 TSLA.US + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/sharelist/{id}/securities
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股单 ID | +| symbols | string[] | 是 | 待移除的标的代码 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.remove_securities(123, ["TSLA.US"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.remove_securities(123, ["TSLA.US"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.removeSecurities(123, ['TSLA.US']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.removeSecurities(123, Arrays.asList("TSLA.US")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.remove_securities(123, vec!["TSLA.US".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.RemoveSecurities(context.Background(), 123, []string{"TSLA.US"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/sharelist/sharelist_detail.md b/docs/zh-CN/docs/account/sharelist/sharelist_detail.md new file mode 100644 index 00000000..5e54de8f --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/sharelist_detail.md @@ -0,0 +1,207 @@ +--- +slug: sharelist-detail +title: 股单详情 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取股单详情,包括名称、描述及成分股列表。 + + +longbridge sharelist detail 123 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/sharelist/{id}
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股单 ID | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.detail(123) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.detail(123) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.detail(123) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.detail(123).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.detail(123).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Detail(context.Background(), 123) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 123, + "name": "AI Picks", + "description": "Top AI infrastructure stocks", + "securities": ["AAPL.US", "NVDA.US"] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [SharelistDetail](#SharelistDetail) | +| 400 | 请求错误 | None | + +## Schemas + +### SharelistDetail + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | 股单 ID | +| name | string | true | 股单名称 | +| description | string | false | 描述 | +| securities | string[] | true | 标的代码列表 | diff --git a/docs/zh-CN/docs/account/sharelist/sort_securities.md b/docs/zh-CN/docs/account/sharelist/sort_securities.md new file mode 100644 index 00000000..a6f1fdd0 --- /dev/null +++ b/docs/zh-CN/docs/account/sharelist/sort_securities.md @@ -0,0 +1,185 @@ +--- +slug: sort-securities +title: 股单标的排序 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +对股单中的标的重新排序。传入的标的代码列表即为新顺序。 + + +longbridge sharelist sort 123 TSLA.US AAPL.US 700.HK + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/sharelist/{id}/securities/sort
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股单 ID | +| symbols | string[] | 是 | 按期望顺序排列的标的代码 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.sort_securities(123, ["TSLA.US", "AAPL.US", "700.HK"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.sort_securities(123, ["TSLA.US", "AAPL.US", "700.HK"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.sortSecurities(123, ['TSLA.US', 'AAPL.US', '700.HK']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.sortSecurities(123, Arrays.asList("TSLA.US", "AAPL.US", "700.HK")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.sort_securities(123, vec!["TSLA.US".into(), "AAPL.US".into(), "700.HK".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.SortSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US", "700.HK"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 请求错误 | None | diff --git a/docs/zh-CN/docs/account/sharelist/update_sharelist.md b/docs/zh-CN/docs/account/sharelist/update_sharelist.md index 085e5d34..d970d707 100644 --- a/docs/zh-CN/docs/account/sharelist/update_sharelist.md +++ b/docs/zh-CN/docs/account/sharelist/update_sharelist.md @@ -34,22 +34,14 @@ longbridge sharelist remove 15921 AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Sharelist ID (path parameter) | -| name | string | NO | New name. Omit to keep existing. | -| mode | string | NO | Operation mode for securities: `add`, `remove`, or `replace` | -| securities | string[] | NO | Security symbols affected by the operation | +| id | int64 | 是 | 股单 ID(路径参数) | +| name | string | 否 | 新名称,不传则保持原名 | +| mode | string | 否 | 证券操作模式:`add`(添加)、`remove`(移除)或 `replace`(替换) | +| securities | string[] | 否 | 受操作影响的证券代码列表 | ### Request Example - - - -longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US -longbridge sharelist remove 15921 AAPL.US - - - ```python @@ -224,8 +216,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [update_sharelist_rsp](#update_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [update_sharelist_rsp](#update_sharelist_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -233,4 +225,4 @@ func main() { -No response body fields. +无响应体字段。 diff --git a/docs/zh-CN/docs/fundamental/_category_.json b/docs/zh-CN/docs/fundamental/_category_.json index ffe0f326..73c73235 100644 --- a/docs/zh-CN/docs/fundamental/_category_.json +++ b/docs/zh-CN/docs/fundamental/_category_.json @@ -2,6 +2,7 @@ "position": 5, "label": "基本面", "collapsible": true, - "collapsed": false, - "link": null + "collapsed": true, + "link": null, + "icon": "book-open" } diff --git a/docs/zh-CN/docs/fundamental/calendar/_category_.json b/docs/zh-CN/docs/fundamental/calendar/_category_.json index 912d5c6a..e6d32592 100644 --- a/docs/zh-CN/docs/fundamental/calendar/_category_.json +++ b/docs/zh-CN/docs/fundamental/calendar/_category_.json @@ -2,6 +2,6 @@ "position": 3, "label": "日历", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md b/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md index 46122263..149c0b43 100644 --- a/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md +++ b/docs/zh-CN/docs/fundamental/calendar/dividend_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar dividend longbridge finance-calendar dividend --filter positions - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/dividends
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar dividend --filter positions | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 开始日期,格式 YYYY-MM-DD | +| end | string | YES | 结束日期,格式 YYYY-MM-DD | +| market | string | NO | 市场筛选:US、HK、SH、SZ,不填则返回所有市场 | ### Request Example - - - -longbridge finance-calendar dividend -longbridge finance-calendar dividend --filter positions - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [dividend_calendar_rsp](#dividend_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [dividend_calendar_rsp](#dividend_calendar_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Dividend event list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Company name | -| ∟ ex_date | string | true | Ex-dividend date | -| ∟ pay_date | string | false | Payment date | -| ∟ amount | string | true | Dividend amount per share | -| ∟ currency | string | true | Currency | +| list | object[] | 是 | 分红事件列表 | +| ∟ symbol | string | 是 | 证券代码 | +| ∟ name | string | 是 | 公司名称 | +| ∟ ex_date | string | 是 | 除息日 | +| ∟ pay_date | string | 否 | 派息日 | +| ∟ amount | string | 是 | 每股分红金额 | +| ∟ currency | string | 是 | 货币 | diff --git a/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md b/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md index 9814a012..0dafeca0 100644 --- a/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md +++ b/docs/zh-CN/docs/fundamental/calendar/earnings_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar report longbridge finance-calendar report --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/earnings
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar report --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 开始日期,格式 YYYY-MM-DD | +| end | string | YES | 结束日期,格式 YYYY-MM-DD | +| market | string | NO | 市场筛选:US、HK、SH、SZ,不填则返回所有市场 | ### Request Example - - - -longbridge finance-calendar report -longbridge finance-calendar report --market US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [earnings_calendar_rsp](#earnings_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [earnings_calendar_rsp](#earnings_calendar_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Earnings event list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Company name | -| ∟ report_date | string | true | Expected report date | -| ∟ eps_estimate | string | false | EPS estimate | -| ∟ eps_actual | string | false | Actual EPS (null if not yet reported) | -| ∟ revenue_estimate | string | false | Revenue estimate | +| list | object[] | 是 | 财报事件列表 | +| ∟ symbol | string | 是 | 证券代码 | +| ∟ name | string | 是 | 公司名称 | +| ∟ report_date | string | 是 | 预计发布日期 | +| ∟ eps_estimate | string | 否 | EPS 预期值 | +| ∟ eps_actual | string | 否 | EPS 实际值(未发布时为 null) | +| ∟ revenue_estimate | string | 否 | 营收预期值 | diff --git a/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md b/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md index aea34b45..56ed4214 100644 --- a/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md +++ b/docs/zh-CN/docs/fundamental/calendar/ipo_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar ipo longbridge finance-calendar ipo --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/ipos
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar ipo --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 开始日期,格式 YYYY-MM-DD | +| end | string | YES | 结束日期,格式 YYYY-MM-DD | +| market | string | NO | 市场筛选:US、HK、SH、SZ,不填则返回所有市场 | ### Request Example - - - -longbridge finance-calendar ipo -longbridge finance-calendar ipo --market US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [ipo_calendar_rsp](#ipo_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [ipo_calendar_rsp](#ipo_calendar_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | IPO event list | -| ∟ symbol | string | false | Security symbol (assigned after listing) | -| ∟ name | string | true | Company name | -| ∟ listing_date | string | true | Expected listing date | -| ∟ offer_price | string | false | IPO offer price | -| ∟ currency | string | false | Currency | -| ∟ market | string | true | Market code | +| list | object[] | 是 | IPO 事件列表 | +| ∟ symbol | string | 否 | 证券代码(上市后分配) | +| ∟ name | string | 是 | 公司名称 | +| ∟ listing_date | string | 是 | 预计上市日期 | +| ∟ offer_price | string | 否 | 新股发行价 | +| ∟ currency | string | 否 | 货币 | +| ∟ market | string | 是 | 市场代码 | diff --git a/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md b/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md index 4dced0fb..ab0b0fbd 100644 --- a/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md +++ b/docs/zh-CN/docs/fundamental/calendar/macro_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar macrodata longbridge finance-calendar macrodata --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/macro
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar macrodata --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| country | string | NO | Country code: `US`, `CN`, `EU`, `JP`. Omit for global. | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 开始日期,格式 YYYY-MM-DD | +| end | string | YES | 结束日期,格式 YYYY-MM-DD | +| market | string | NO | 市场筛选:US、HK、SH、SZ,不填则返回所有市场 | ### Request Example - - - -longbridge finance-calendar macrodata -longbridge finance-calendar macrodata --market US - - - ```python @@ -235,8 +227,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [macro_calendar_rsp](#macro_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [macro_calendar_rsp](#macro_calendar_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -246,11 +238,11 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Macro event list | -| ∟ event | string | true | Event name | -| ∟ country | string | true | Country code | -| ∟ release_date | string | true | Release date | -| ∟ actual | string | false | Actual value (null if not yet released) | -| ∟ forecast | string | false | Consensus forecast | -| ∟ previous | string | false | Previous period value | -| ∟ importance | string | false | Importance level: `High`, `Medium`, `Low` | +| list | object[] | 是 | 宏观事件列表 | +| ∟ event | string | 是 | 事件名称 | +| ∟ country | string | 是 | 国家/地区代码 | +| ∟ release_date | string | 是 | 发布日期 | +| ∟ actual | string | 否 | 实际值(未发布时为 null) | +| ∟ forecast | string | 否 | 市场预期值 | +| ∟ previous | string | 否 | 前期值 | +| ∟ importance | string | 否 | 重要程度:`High`(高)、`Medium`(中)、`Low`(低) | diff --git a/docs/zh-CN/docs/fundamental/calendar/split_calendar.md b/docs/zh-CN/docs/fundamental/calendar/split_calendar.md index 255d11de..4d3dd440 100644 --- a/docs/zh-CN/docs/fundamental/calendar/split_calendar.md +++ b/docs/zh-CN/docs/fundamental/calendar/split_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar split longbridge finance-calendar split --market HK - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/splits
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar split --market HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 开始日期,格式 YYYY-MM-DD | +| end | string | YES | 结束日期,格式 YYYY-MM-DD | +| market | string | NO | 市场筛选:US、HK、SH、SZ,不填则返回所有市场 | ### Request Example - - - -longbridge finance-calendar split -longbridge finance-calendar split --market HK - - - ```python @@ -233,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [split_calendar_rsp](#split_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [split_calendar_rsp](#split_calendar_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -244,9 +236,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Split event list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Company name | -| ∟ date | string | true | Effective date | -| ∟ ratio | string | true | Split ratio, e.g. `10:1` | -| ∟ type | string | true | `Split` or `ReverseSplit` | +| list | object[] | 是 | 拆股事件列表 | +| ∟ symbol | string | 是 | 证券代码 | +| ∟ name | string | 是 | 公司名称 | +| ∟ date | string | 是 | 生效日期 | +| ∟ ratio | string | 是 | 拆股比例,例如 `10:1` | +| ∟ type | string | 是 | `Split`(拆股)或 `ReverseSplit`(合股) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/_category_.json b/docs/zh-CN/docs/fundamental/fundamental/_category_.json index 003cf33f..1a9cb8ef 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/_category_.json +++ b/docs/zh-CN/docs/fundamental/fundamental/_category_.json @@ -2,6 +2,6 @@ "position": 1, "label": "基本面数据", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/fundamental/fundamental/buyback.md b/docs/zh-CN/docs/fundamental/fundamental/buyback.md new file mode 100644 index 00000000..1659bf95 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/buyback.md @@ -0,0 +1,239 @@ +--- +slug: buyback +title: 回购数据 +sidebar_position: 20 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取股票回购数据,包括历史回购金额及回购比例。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/buyback
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.buyback("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.buyback("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.buyback('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.getBuyback("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.buyback("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.buyback("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.Buyback(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "period": "FY2023", + "buyback_amount": 77550000000, + "buyback_shares": 430000000, + "buyback_ratio": 0.0278, + "currency": "USD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [BuybackData](#BuybackData) | +| 400 | 请求错误 | None | + +## Schemas + +### BuybackData + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| list | object[] | 是 | 回购记录列表 | +| list[].period | string | 否 | 财报期(如 FY2023、Q3 2024) | +| list[].buyback_amount | int64 | 否 | 回购总金额 | +| list[].buyback_shares | int64 | 否 | 回购股份数量 | +| list[].buyback_ratio | double | 否 | 回购占总股本比例 | +| list[].currency | string | 否 | 货币代码 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/company_profile.md b/docs/zh-CN/docs/fundamental/fundamental/company_profile.md index 23687fe5..dedf1e18 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/company_profile.md +++ b/docs/zh-CN/docs/fundamental/fundamental/company_profile.md @@ -34,19 +34,11 @@ longbridge company AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | ### Request Example - - - -longbridge company TSLA.US -longbridge company AAPL.US - - - ```python @@ -229,8 +221,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [company_profile_rsp](#company_profile_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [company_profile_rsp](#company_profile_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -240,10 +232,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| name | string | true | Company name | -| symbol | string | true | Security symbol | -| founded | string | false | Founding year | -| ceo | string | false | Current CEO | -| employees | int32 | false | Number of employees | -| website | string | false | Company website | -| description | string | false | Business description | +| name | string | 是 | 公司名称 | +| symbol | string | 是 | 证券代码 | +| founded | string | 否 | 成立年份 | +| ceo | string | 否 | 现任 CEO | +| employees | int32 | 否 | 员工人数 | +| website | string | 否 | 公司官网 | +| description | string | 否 | 业务描述 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/consensus.md b/docs/zh-CN/docs/fundamental/fundamental/consensus.md new file mode 100644 index 00000000..6381d7cb --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/consensus.md @@ -0,0 +1,244 @@ +--- +slug: consensus +title: 机构共识 +sidebar_position: 14 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取机构共识预测,包括营收、EPS 和净利润预测。 + + +longbridge consensus TSLA.US +longbridge consensus AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/consensus
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `TSLA.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.consensus("TSLA.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.consensus("TSLA.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.consensus('TSLA.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.getConsensus("TSLA.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.consensus("TSLA.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.consensus("TSLA.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.Consensus(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "list": [ + { + "period": "FY2024", + "revenue": 105000000000, + "eps": 3.12, + "net_income": 10500000000, + "analyst_count": 35 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [FinancialConsensus](#FinancialConsensus) | +| 400 | 请求错误 | None | + +## Schemas + +### FinancialConsensus + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| list | object[] | 是 | 共识预测期列表 | +| list[].period | string | 否 | 财报期(如 FY2024) | +| list[].revenue | int64 | 否 | 共识营收预测 | +| list[].eps | double | 否 | 共识 EPS 预测 | +| list[].net_income | int64 | 否 | 共识净利润预测 | +| list[].analyst_count | int32 | 否 | 参与预测的分析师数量 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md b/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md index 29a8df3e..ec226f33 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md +++ b/docs/zh-CN/docs/fundamental/fundamental/corporate_actions.md @@ -34,21 +34,13 @@ longbridge corp-action AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| start_date | string | 否 | 开始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 结束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge corp-action TSLA.US -longbridge corp-action AAPL.US - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [corporate_actions_rsp](#corporate_actions_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [corporate_actions_rsp](#corporate_actions_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -243,8 +235,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Corporate action list | -| ∟ type | string | true | Action type: `Split`, `Merger`, `Spinoff`, `Rights` | -| ∟ date | string | true | Effective date | -| ∟ ratio | string | false | Split/merge ratio | -| ∟ description | string | false | Action description | +| list | object[] | 是 | 公司行动列表 | +| ∟ type | string | 是 | 行动类型:`Split`(拆股)、`Merger`(合并)、`Spinoff`(分拆)、`Rights`(配股) | +| ∟ date | string | 是 | 生效日期 | +| ∟ ratio | string | 否 | 拆股/合并比例 | +| ∟ description | string | 否 | 行动描述 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/dividend_detail.md b/docs/zh-CN/docs/fundamental/fundamental/dividend_detail.md new file mode 100644 index 00000000..f464837b --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/dividend_detail.md @@ -0,0 +1,243 @@ +--- +slug: dividend-detail +title: 分红详情 +sidebar_position: 12 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取详细分红信息,包括宣告日、除息日和派发日。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/dividend_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.dividend_detail("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.dividend_detail("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.dividendDetail('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.getDividendDetail("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.dividend_detail("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.dividend_detail("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.DividendDetail(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "dividend_type": "cash", + "amount": 0.24, + "currency": "USD", + "declared_date": "2024-02-01", + "ex_date": "2024-02-09", + "record_date": "2024-02-12", + "payment_date": "2024-02-15" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DividendList](#DividendList) | +| 400 | 请求错误 | None | + +## Schemas + +### DividendList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | 是 | 分红记录列表 | +| list[].symbol | string | 是 | 证券代码 | +| list[].dividend_type | string | 否 | 分红类型(如 cash 现金、stock 股票) | +| list[].amount | double | 否 | 每股分红金额 | +| list[].currency | string | 否 | 货币代码 | +| list[].declared_date | string | 否 | 宣告日(YYYY-MM-DD) | +| list[].ex_date | string | 否 | 除息日(YYYY-MM-DD) | +| list[].record_date | string | 否 | 股权登记日(YYYY-MM-DD) | +| list[].payment_date | string | 否 | 派发日(YYYY-MM-DD) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/dividends.md b/docs/zh-CN/docs/fundamental/fundamental/dividends.md index f922d8e9..25d9b7fb 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/dividends.md +++ b/docs/zh-CN/docs/fundamental/fundamental/dividends.md @@ -34,21 +34,13 @@ longbridge dividend AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| start_date | string | 否 | 开始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 结束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge dividend TSLA.US -longbridge dividend AAPL.US - - - ```python @@ -233,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [dividends_rsp](#dividends_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [dividends_rsp](#dividends_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -244,9 +236,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Dividend records | -| ∟ ex_date | string | true | Ex-dividend date | -| ∟ pay_date | string | false | Payment date | -| ∟ amount | string | true | Dividend amount per share | -| ∟ currency | string | true | Currency | -| ∟ type | string | true | Dividend type, e.g. `Cash`, `Stock` | +| list | object[] | 是 | 分红记录列表 | +| ∟ ex_date | string | 是 | 除息日 | +| ∟ pay_date | string | 否 | 派息日 | +| ∟ amount | string | 是 | 每股分红金额 | +| ∟ currency | string | 是 | 货币 | +| ∟ type | string | 是 | 分红类型,例如 `Cash`(现金)、`Stock`(股票) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/executives.md b/docs/zh-CN/docs/fundamental/fundamental/executives.md index 4d7ad25b..7edaf5b8 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/executives.md +++ b/docs/zh-CN/docs/fundamental/fundamental/executives.md @@ -34,19 +34,11 @@ longbridge executive AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | ### Request Example - - - -longbridge executive TSLA.US -longbridge executive AAPL.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [executives_rsp](#executives_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [executives_rsp](#executives_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -241,8 +233,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Executive list | -| ∟ name | string | true | Executive name | -| ∟ title | string | true | Job title | -| ∟ age | int32 | false | Age | -| ∟ since | string | false | Year appointed | +| list | object[] | 是 | 高管列表 | +| ∟ name | string | 是 | 高管姓名 | +| ∟ title | string | 是 | 职位 | +| ∟ age | int32 | 否 | 年龄 | +| ∟ since | string | 否 | 任职年份 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/financial_report.md b/docs/zh-CN/docs/fundamental/fundamental/financial_report.md index 0dad6670..a073dedf 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/financial_report.md +++ b/docs/zh-CN/docs/fundamental/fundamental/financial_report.md @@ -34,21 +34,13 @@ longbridge financial-report AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| kind | string | NO | Statement type: `IS` (income), `BS` (balance sheet), `CF` (cash flow), `ALL` (default) | -| report | string | NO | Reporting period: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| kind | string | 否 | 报表类型:`IS`(利润表)、`BS`(资产负债表)、`CF`(现金流量表)、`ALL`(默认) | +| report | string | 否 | 报告期:`af`(年报)、`saf`(半年报)、`qf`(季报) | ### Request Example - - - -longbridge financial-report TSLA.US --kind IS -longbridge financial-report AAPL.US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [financial_report_rsp](#financial_report_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [financial_report_rsp](#financial_report_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | List of financial statement records | -| ∟ type | string | true | Statement type: `IS`, `BS`, `CF` | -| ∟ period | string | true | Reporting period label | -| ∟ eps | string | false | Earnings per share | -| ∟ revenue | string | false | Total revenue | -| ∟ net_income | string | false | Net income | -| ∟ gross_margin | string | false | Gross margin ratio | +| list | object[] | 是 | 财务报表记录列表 | +| ∟ type | string | 是 | 报表类型:`IS`、`BS`、`CF` | +| ∟ period | string | 是 | 报告期标签 | +| ∟ eps | string | 否 | 每股收益 | +| ∟ revenue | string | 否 | 总营收 | +| ∟ net_income | string | 否 | 净利润 | +| ∟ gross_margin | string | 否 | 毛利率 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/forecast_eps.md b/docs/zh-CN/docs/fundamental/fundamental/forecast_eps.md new file mode 100644 index 00000000..d20812ce --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/forecast_eps.md @@ -0,0 +1,244 @@ +--- +slug: forecast-eps +title: EPS 预测 +sidebar_position: 13 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取 EPS 预测及分析师共识估值。 + + +longbridge forecast-eps TSLA.US +longbridge forecast-eps AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/forecast_eps
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `TSLA.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.forecast_eps("TSLA.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.forecast_eps("TSLA.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.forecastEps('TSLA.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.getForecastEps("TSLA.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.forecast_eps("TSLA.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.forecast_eps("TSLA.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.ForecastEps(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "list": [ + { + "period": "FY2024", + "consensus_eps": 3.12, + "high_eps": 4.50, + "low_eps": 2.10, + "analyst_count": 35 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [ForecastEps](#ForecastEps) | +| 400 | 请求错误 | None | + +## Schemas + +### ForecastEps + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| list | object[] | 是 | EPS 预测期列表 | +| list[].period | string | 否 | 财报期(如 FY2024、Q1 2024) | +| list[].consensus_eps | double | 否 | 共识 EPS 估值 | +| list[].high_eps | double | 否 | 最高 EPS 估值 | +| list[].low_eps | double | 否 | 最低 EPS 估值 | +| list[].analyst_count | int32 | 否 | 参与估值的分析师数量 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md b/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md index df070ce5..48ac3d48 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md +++ b/docs/zh-CN/docs/fundamental/fundamental/fund_holdings.md @@ -34,19 +34,11 @@ longbridge fund-holder AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | ### Request Example - - - -longbridge fund-holder TSLA.US -longbridge fund-holder AAPL.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [fund_holdings_rsp](#fund_holdings_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [fund_holdings_rsp](#fund_holdings_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -241,8 +233,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Fund holder list | -| ∟ fund_name | string | true | Fund name | -| ∟ shares | string | true | Number of shares held | -| ∟ percentage | string | true | Ownership percentage | -| ∟ date | string | false | Report date | +| list | object[] | 是 | 基金持有人列表 | +| ∟ fund_name | string | 是 | 基金名称 | +| ∟ shares | string | 是 | 持股数量 | +| ∟ percentage | string | 是 | 持股比例 | +| ∟ date | string | 否 | 报告日期 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/industry_valuation.md b/docs/zh-CN/docs/fundamental/fundamental/industry_valuation.md new file mode 100644 index 00000000..0764e557 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/industry_valuation.md @@ -0,0 +1,248 @@ +--- +slug: industry-valuation +title: 行业估值对比 +sidebar_position: 16 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取同行业内的同类公司估值对比数据。 + + +longbridge industry-valuation TSLA.US +longbridge industry-valuation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/industry_valuation
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `TSLA.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.industry_valuation("TSLA.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_valuation("TSLA.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.industryValuation('TSLA.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.getIndustryValuation("TSLA.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_valuation("TSLA.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_valuation("TSLA.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.IndustryValuation(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "industry": "Automobiles", + "list": [ + { + "symbol": "TSLA.US", + "name": "Tesla Inc.", + "pe": 55.2, + "pb": 12.1, + "ps": 6.8, + "market_cap": 700000000000 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryValuationList](#IndustryValuationList) | +| 400 | 请求错误 | None | + +## Schemas + +### IndustryValuationList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| industry | string | 否 | 行业分类 | +| list | object[] | 是 | 同行公司列表 | +| list[].symbol | string | 否 | 同行证券代码 | +| list[].name | string | 否 | 公司名称 | +| list[].pe | double | 否 | 市盈率 | +| list[].pb | double | 否 | 市净率 | +| list[].ps | double | 否 | 市销率 | +| list[].market_cap | int64 | 否 | 市值 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/industry_valuation_dist.md b/docs/zh-CN/docs/fundamental/fundamental/industry_valuation_dist.md new file mode 100644 index 00000000..933f242a --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/industry_valuation_dist.md @@ -0,0 +1,238 @@ +--- +slug: industry-valuation-dist +title: 行业估值分布 +sidebar_position: 17 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取该证券所在行业的估值分布直方图。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/industry_valuation_dist
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.industry_valuation_dist("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.industry_valuation_dist("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.industryValuationDist('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.getIndustryValuationDist("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.industry_valuation_dist("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.industry_valuation_dist("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.IndustryValuationDist(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "metric": "pe", + "symbol_value": 28.5, + "buckets": [ + { "range_start": 0, "range_end": 10, "count": 5 }, + { "range_start": 10, "range_end": 20, "count": 18 }, + { "range_start": 20, "range_end": 30, "count": 22 }, + { "range_start": 30, "range_end": 50, "count": 12 } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryValuationDist](#IndustryValuationDist) | +| 400 | 请求错误 | None | + +## Schemas + +### IndustryValuationDist + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| metric | string | 否 | 估值指标(如 pe、pb、ps) | +| symbol_value | double | 否 | 该证券自身的估值指标数值 | +| buckets | object[] | 否 | 分布直方图区间列表 | +| buckets[].range_start | double | 否 | 区间下界 | +| buckets[].range_end | double | 否 | 区间上界 | +| buckets[].count | int32 | 否 | 该区间内的公司数量 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/institution_rating.md b/docs/zh-CN/docs/fundamental/fundamental/institution_rating.md new file mode 100644 index 00000000..f699ad44 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/institution_rating.md @@ -0,0 +1,243 @@ +--- +slug: institution-rating +title: 机构评级 +sidebar_position: 10 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取分析师机构评级快照(评级分布及平均目标价)。 + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/institution_rating
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `TSLA.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("TSLA.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("TSLA.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.institutionRating('TSLA.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.getInstitutionRating("TSLA.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("TSLA.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("TSLA.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.InstitutionRating(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "buy": 18, + "outperform": 5, + "hold": 12, + "underperform": 3, + "sell": 2, + "total": 40, + "avg_target_price": 285.50 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InstitutionRating](#InstitutionRating) | +| 400 | 请求错误 | None | + +## Schemas + +### InstitutionRating + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| buy | int32 | 否 | 买入评级数量 | +| outperform | int32 | 否 | 跑赢大市评级数量 | +| hold | int32 | 否 | 持有评级数量 | +| underperform | int32 | 否 | 跑输大市评级数量 | +| sell | int32 | 否 | 卖出评级数量 | +| total | int32 | 否 | 评级总数 | +| avg_target_price | double | 否 | 平均目标价 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/institution_rating_detail.md b/docs/zh-CN/docs/fundamental/fundamental/institution_rating_detail.md new file mode 100644 index 00000000..83540f4b --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/institution_rating_detail.md @@ -0,0 +1,244 @@ +--- +slug: institution-rating-detail +title: 机构评级详情 +sidebar_position: 11 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取历史分析师评级及目标价详情。 + + +longbridge institution-rating detail TSLA.US +longbridge institution-rating detail AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/institution_rating_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `TSLA.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_detail("TSLA.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_detail("TSLA.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.institutionRatingDetail('TSLA.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.getInstitutionRatingDetail("TSLA.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_detail("TSLA.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_detail("TSLA.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.InstitutionRatingDetail(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "TSLA.US", + "broker": "Goldman Sachs", + "analyst": "Mark Delaney", + "rating": "Buy", + "target_price": 320.00, + "date": "2024-03-15" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InstitutionRatingDetail](#InstitutionRatingDetail) | +| 400 | 请求错误 | None | + +## Schemas + +### InstitutionRatingDetail + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | 是 | 评级详情列表 | +| list[].symbol | string | 是 | 证券代码 | +| list[].broker | string | 否 | 券商名称 | +| list[].analyst | string | 否 | 分析师姓名 | +| list[].rating | string | 否 | 评级(如 Buy、Hold、Sell) | +| list[].target_price | double | 否 | 目标价 | +| list[].date | string | 否 | 评级日期(YYYY-MM-DD) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/invest_relation.md b/docs/zh-CN/docs/fundamental/fundamental/invest_relation.md new file mode 100644 index 00000000..597808ce --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/invest_relation.md @@ -0,0 +1,250 @@ +--- +slug: invest-relation +title: 投资关系 +sidebar_position: 18 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取投资关系数据,包括母公司、子公司及主要持股。 + + +longbridge invest-relation 700.HK +longbridge invest-relation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/invest_relation
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `700.HK` | + +### 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.invest_relation("700.HK") +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.invest_relation("700.HK") + 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.investRelation('700.HK') + 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.getInvestRelation("700.HK").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.invest_relation("700.HK").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.invest_relation("700.HK", [](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.InvestRelation(context.Background(), "700.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "parent": { + "symbol": "", + "name": "" + }, + "subsidiaries": [ + { "symbol": "TCEHY.US", "name": "Tencent Holdings ADR", "holding_ratio": 1.0 } + ], + "holdings": [ + { "symbol": "SE.US", "name": "Sea Limited", "holding_ratio": 18.7 } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InvestRelations](#InvestRelations) | +| 400 | 请求错误 | None | + +## Schemas + +### InvestRelations + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| parent | object | 否 | 母公司信息 | +| parent.symbol | string | 否 | 母公司证券代码 | +| parent.name | string | 否 | 母公司名称 | +| subsidiaries | object[] | 否 | 子公司列表 | +| subsidiaries[].symbol | string | 否 | 子公司证券代码 | +| subsidiaries[].name | string | 否 | 子公司名称 | +| subsidiaries[].holding_ratio | double | 否 | 持股比例(%) | +| holdings | object[] | 否 | 主要持股列表 | +| holdings[].symbol | string | 否 | 持股证券代码 | +| holdings[].name | string | 否 | 持股公司名称 | +| holdings[].holding_ratio | double | 否 | 持股比例(%) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/operating.md b/docs/zh-CN/docs/fundamental/fundamental/operating.md new file mode 100644 index 00000000..48da8c5e --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/operating.md @@ -0,0 +1,251 @@ +--- +slug: operating +title: 经营数据 +sidebar_position: 19 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +按财报期获取经营数据及核心财务指标摘要。 + + +longbridge operating AAPL.US +longbridge operating TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/operating
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| period | string | 否 | 财报期筛选,如 `q1`、`q2`、`q3`、`q4`、`annual` | + +### 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.operating("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.operating("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.operating('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.getOperating("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.operating("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.operating("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.Operating(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "period": "Q1 2024", + "revenue": 119575000000, + "gross_profit": 54856000000, + "operating_income": 40372000000, + "net_income": 33916000000, + "gross_margin": 0.4588, + "operating_margin": 0.3377, + "net_margin": 0.2837 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [OperatingList](#OperatingList) | +| 400 | 请求错误 | None | + +## Schemas + +### OperatingList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| list | object[] | 是 | 经营数据记录列表 | +| list[].period | string | 否 | 财报期(如 Q1 2024、Annual 2023) | +| list[].revenue | int64 | 否 | 总营收 | +| list[].gross_profit | int64 | 否 | 毛利润 | +| list[].operating_income | int64 | 否 | 营业利润 | +| list[].net_income | int64 | 否 | 净利润 | +| list[].gross_margin | double | 否 | 毛利率 | +| list[].operating_margin | double | 否 | 营业利润率 | +| list[].net_margin | double | 否 | 净利润率 | diff --git a/docs/zh-CN/docs/fundamental/fundamental/ratings.md b/docs/zh-CN/docs/fundamental/fundamental/ratings.md index 5d8b499b..425be107 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/ratings.md +++ b/docs/zh-CN/docs/fundamental/fundamental/ratings.md @@ -34,19 +34,11 @@ longbridge institution-rating AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | ### Request Example - - - -longbridge institution-rating TSLA.US -longbridge institution-rating AAPL.US - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [ratings_rsp](#ratings_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [ratings_rsp](#ratings_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -242,9 +234,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | List of analyst ratings | -| ∟ broker_name | string | true | Institution name | -| ∟ rating | string | true | Rating: `Buy`, `Hold`, `Sell` | -| ∟ target_price | string | false | Target price | -| ∟ currency | string | false | Currency | -| ∟ date | string | true | Rating date in `YYYY-MM-DD` format | +| list | object[] | 是 | 分析师评级列表 | +| ∟ broker_name | string | 是 | 机构名称 | +| ∟ rating | string | 是 | 评级:`Buy`(买入)、`Hold`(持有)、`Sell`(卖出) | +| ∟ target_price | string | 否 | 目标价 | +| ∟ currency | string | 否 | 货币 | +| ∟ date | string | 是 | 评级日期,格式 `YYYY-MM-DD` | diff --git a/docs/zh-CN/docs/fundamental/fundamental/shareholders.md b/docs/zh-CN/docs/fundamental/fundamental/shareholders.md index 036f2e22..3f113bcd 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/shareholders.md +++ b/docs/zh-CN/docs/fundamental/fundamental/shareholders.md @@ -34,19 +34,11 @@ longbridge shareholder AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | ### Request Example - - - -longbridge shareholder TSLA.US -longbridge shareholder AAPL.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [shareholders_rsp](#shareholders_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [shareholders_rsp](#shareholders_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -241,8 +233,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Shareholder list | -| ∟ name | string | true | Shareholder name | -| ∟ shares | string | true | Number of shares held | -| ∟ percentage | string | true | Ownership percentage | -| ∟ type | string | false | `Institution` or `Individual` | +| list | object[] | 是 | 股东列表 | +| ∟ name | string | 是 | 股东名称 | +| ∟ shares | string | 是 | 持股数量 | +| ∟ percentage | string | 是 | 持股比例 | +| ∟ type | string | 否 | `Institution`(机构)或 `Individual`(个人) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/valuation_history.md b/docs/zh-CN/docs/fundamental/fundamental/valuation_history.md new file mode 100644 index 00000000..cd1b4c6c --- /dev/null +++ b/docs/zh-CN/docs/fundamental/fundamental/valuation_history.md @@ -0,0 +1,239 @@ +--- +slug: valuation-history +title: 估值历史 +sidebar_position: 15 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取历史估值指标时间序列(市盈率、市净率、市销率、股息率)。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/valuation_history
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.valuation_history("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.valuation_history("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.valuationHistory('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.getValuationHistory("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.valuation_history("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.valuation_history("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.ValuationHistory(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "date": "2024-03-31", + "pe": 28.5, + "pb": 46.2, + "ps": 7.8, + "dividend_yield": 0.55 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [ValuationHistoryResponse](#ValuationHistoryResponse) | +| 400 | 请求错误 | None | + +## Schemas + +### ValuationHistoryResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 证券代码 | +| list | object[] | 是 | 历史估值数据点列表 | +| list[].date | string | 否 | 日期(YYYY-MM-DD) | +| list[].pe | double | 否 | 市盈率(PE) | +| list[].pb | double | 否 | 市净率(PB) | +| list[].ps | double | 否 | 市销率(PS) | +| list[].dividend_yield | double | 否 | 股息率(%) | diff --git a/docs/zh-CN/docs/fundamental/fundamental/valuations.md b/docs/zh-CN/docs/fundamental/fundamental/valuations.md index 997ba3df..3874fdb9 100644 --- a/docs/zh-CN/docs/fundamental/fundamental/valuations.md +++ b/docs/zh-CN/docs/fundamental/fundamental/valuations.md @@ -34,20 +34,12 @@ longbridge valuation AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| indicator | string | NO | Indicator filter: `pe`, `pb`, `ps`, `dvd_yld` | +| symbol | string | 是 | 证券代码,例如 `AAPL.US` | +| indicator | string | 否 | 指标筛选:`pe`、`pb`、`ps`、`dvd_yld` | ### Request Example - - - -longbridge valuation TSLA.US --indicator pe -longbridge valuation AAPL.US - - - ```python @@ -227,8 +219,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [valuations_rsp](#valuations_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [valuations_rsp](#valuations_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -238,9 +230,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| metrics | object | true | Valuation metrics map | -| ∟ pe | object | false | P/E ratio data | -| ∟∟ current | string | true | Current value | -| ∟∟ high | string | true | 5-year high | -| ∟∟ low | string | true | 5-year low | -| ∟∟ median | string | true | 5-year median | +| metrics | object | 是 | 估值指标映射 | +| ∟ pe | object | 否 | 市盈率数据 | +| ∟∟ current | string | 是 | 当前值 | +| ∟∟ high | string | 是 | 5 年最高值 | +| ∟∟ low | string | 是 | 5 年最低值 | +| ∟∟ median | string | 是 | 5 年中位值 | diff --git a/docs/zh-CN/docs/fundamental/market/_category_.json b/docs/zh-CN/docs/fundamental/market/_category_.json index f72654e3..5a191d6b 100644 --- a/docs/zh-CN/docs/fundamental/market/_category_.json +++ b/docs/zh-CN/docs/fundamental/market/_category_.json @@ -2,6 +2,6 @@ "position": 2, "label": "市场", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-CN/docs/fundamental/market/ah_premium.md b/docs/zh-CN/docs/fundamental/market/ah_premium.md index c227b168..5a468b6d 100644 --- a/docs/zh-CN/docs/fundamental/market/ah_premium.md +++ b/docs/zh-CN/docs/fundamental/market/ah_premium.md @@ -34,19 +34,11 @@ longbridge ah-premium 0939.HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | H-share symbol of a dual-listed stock, e.g. `939.HK` | +| symbol | string | 是 | A+H 两地上市股票的 H 股代码,例如 `939.HK` | ### Request Example - - - -longbridge ah-premium 939.HK -longbridge ah-premium 0939.HK - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [ah_premium_rsp](#ah_premium_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [ah_premium_rsp](#ah_premium_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -242,9 +234,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | A/H premium records | -| ∟ date | string | true | Date in `YYYY-MM-DD` format | -| ∟ a_price | string | true | A-share price in CNY | -| ∟ h_price | string | true | H-share price in HKD | -| ∟ premium | string | true | A/H premium ratio | -| ∟ fx_rate | string | true | CNH/HKD exchange rate | +| list | object[] | 是 | A/H 溢价记录列表 | +| ∟ date | string | 是 | 日期,格式 `YYYY-MM-DD` | +| ∟ a_price | string | 是 | A 股价格(人民币) | +| ∟ h_price | string | 是 | H 股价格(港币) | +| ∟ premium | string | 是 | A/H 溢价比率 | +| ∟ fx_rate | string | 是 | CNH/HKD 汇率 | diff --git a/docs/zh-CN/docs/fundamental/market/ah_premium_intraday.md b/docs/zh-CN/docs/fundamental/market/ah_premium_intraday.md new file mode 100644 index 00000000..97d6be13 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/ah_premium_intraday.md @@ -0,0 +1,212 @@ +--- +slug: ah-premium-intraday +title: A/H 溢价盘中数据 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取两地上市证券的盘中 A/H 溢价时间序列数据。 + + +longbridge ah-premium intraday 939.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/ah_premium_intraday
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 两地上市股票的港股代码,例如 `939.HK` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.ah_premium_intraday("939.HK") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.ah_premium_intraday("939.HK") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.ahPremiumIntraday('939.HK') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getAhPremiumIntraday("939.HK").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.ah_premium_intraday("939.HK").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.AhPremiumIntraday(context.Background(), "939.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "939.HK", + "timeseries": [ + { + "timestamp": "1774310400", + "premium": "2.35" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [ah_premium_intraday_rsp](#ah_premium_intraday_rsp) | +| 400 | 请求错误 | None | + +## Schemas + +### ah_premium_intraday_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代码 | +| timeseries | object[] | 是 | 盘中 A/H 溢价时间序列 | +| ∟ timestamp | string | 是 | Unix 时间戳 | +| ∟ premium | string | 是 | A/H 溢价百分比 | diff --git a/docs/zh-CN/docs/fundamental/market/broker_holding_daily.md b/docs/zh-CN/docs/fundamental/market/broker_holding_daily.md new file mode 100644 index 00000000..8257d7d6 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/broker_holding_daily.md @@ -0,0 +1,217 @@ +--- +slug: broker-holding-daily +title: 经纪商每日持仓历史 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取某一经纪商在港股上市证券中的每日持仓历史记录。 + + +longbridge broker-holding daily 700.HK --broker B01224 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_holding_daily
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代码,例如 `700.HK` | +| broker_id | string | 是 | 经纪商参与者 ID,例如 `B01224` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_holding_daily("700.HK", "B01224") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_holding_daily("700.HK", "B01224") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.brokerHoldingDaily('700.HK', 'B01224') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerHoldingDaily("700.HK", "B01224").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_holding_daily("700.HK", "B01224").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerHoldingDaily(context.Background(), "700.HK", "B01224") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "broker_id": "B01224", + "broker_name": "HSBC Securities", + "history": [ + { + "date": "2024-01-15", + "holding_qty": "500000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [broker_holding_daily_rsp](#broker_holding_daily_rsp) | +| 400 | 请求错误 | None | + +## Schemas + +### broker_holding_daily_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代码 | +| broker_id | string | 是 | 经纪商参与者 ID | +| broker_name | string | 是 | 经纪商名称 | +| history | object[] | 是 | 每日持仓历史 | +| ∟ date | string | 是 | 日期(YYYY-MM-DD) | +| ∟ holding_qty | string | 是 | 当日持仓数量 | diff --git a/docs/zh-CN/docs/fundamental/market/broker_holding_detail.md b/docs/zh-CN/docs/fundamental/market/broker_holding_detail.md new file mode 100644 index 00000000..2a3285f5 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/market/broker_holding_detail.md @@ -0,0 +1,216 @@ +--- +slug: broker-holding-detail +title: 经纪商持仓详情 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +获取港股上市证券的完整经纪商持仓详情列表(所有经纪商及其持仓数量)。 + + +longbridge broker-holding detail 700.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_holding_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代码,例如 `700.HK` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_holding_detail("700.HK") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_holding_detail("700.HK") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.brokerHoldingDetail('700.HK') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerHoldingDetail("700.HK").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_holding_detail("700.HK").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerHoldingDetail(context.Background(), "700.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "updated_at": "1774310400", + "brokers": [ + { + "broker_id": "B01224", + "broker_name": "HSBC Securities", + "holding_qty": "500000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [broker_holding_detail_rsp](#broker_holding_detail_rsp) | +| 400 | 请求错误 | None | + +## Schemas + +### broker_holding_detail_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代码 | +| updated_at | string | 是 | 最后更新的 Unix 时间戳 | +| brokers | object[] | 是 | 经纪商持仓列表 | +| ∟ broker_id | string | 是 | 经纪商参与者 ID | +| ∟ broker_name | string | 是 | 经纪商名称 | +| ∟ holding_qty | string | 是 | 持仓数量 | diff --git a/docs/zh-CN/docs/fundamental/market/broker_positions.md b/docs/zh-CN/docs/fundamental/market/broker_positions.md index 5e1e282a..69523515 100644 --- a/docs/zh-CN/docs/fundamental/market/broker_positions.md +++ b/docs/zh-CN/docs/fundamental/market/broker_positions.md @@ -34,19 +34,11 @@ longbridge broker-holding 9988.HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | HK security symbol, e.g. `700.HK` | +| symbol | string | 是 | 港股证券代码,例如 `700.HK` | ### Request Example - - - -longbridge broker-holding 700.HK -longbridge broker-holding 9988.HK - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [broker_positions_rsp](#broker_positions_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [broker_positions_rsp](#broker_positions_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -243,10 +235,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| updated_at | string | true | Last updated Unix timestamp | -| participants | object[] | true | Broker position list | -| ∟ broker_id | int32 | true | Broker ID | -| ∟ broker_name | string | true | Broker name | -| ∟ buy_qty | string | true | Buy quantity | -| ∟ sell_qty | string | true | Sell quantity | -| ∟ net_qty | string | true | Net quantity (buy - sell) | +| updated_at | string | 是 | 最后更新的 Unix 时间戳 | +| participants | object[] | 是 | 经纪商持仓列表 | +| ∟ broker_id | int32 | 是 | 经纪商 ID | +| ∟ broker_name | string | 是 | 经纪商名称 | +| ∟ buy_qty | string | 是 | 买入数量 | +| ∟ sell_qty | string | 是 | 卖出数量 | +| ∟ net_qty | string | 是 | 净持仓数量(买入 - 卖出) | diff --git a/docs/zh-CN/docs/fundamental/market/index_components.md b/docs/zh-CN/docs/fundamental/market/index_components.md index 35208ff5..2a41ef79 100644 --- a/docs/zh-CN/docs/fundamental/market/index_components.md +++ b/docs/zh-CN/docs/fundamental/market/index_components.md @@ -34,19 +34,11 @@ longbridge constituent SPY.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Index or ETF symbol, e.g. `HSI.HK`, `SPY.US` | +| symbol | string | 是 | 指数或 ETF 代码,例如 `HSI.HK`、`SPY.US` | ### Request Example - - - -longbridge constituent HSI.HK -longbridge constituent SPY.US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [index_components_rsp](#index_components_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [index_components_rsp](#index_components_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -245,12 +237,12 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| total | int32 | true | Total number of components | -| rise | int32 | true | Number of rising components | -| fall | int32 | true | Number of falling components | -| flat | int32 | true | Number of flat components | -| components | object[] | true | Component list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Security name | -| ∟ price | string | false | Current price | -| ∟ change_pct | string | false | Percentage change | +| total | int32 | 是 | 成分股总数 | +| rise | int32 | 是 | 上涨成分股数量 | +| fall | int32 | 是 | 下跌成分股数量 | +| flat | int32 | 是 | 平盘成分股数量 | +| components | object[] | 是 | 成分股列表 | +| ∟ symbol | string | 是 | 证券代码 | +| ∟ name | string | 是 | 证券名称 | +| ∟ price | string | 否 | 当前价格 | +| ∟ change_pct | string | 否 | 涨跌幅 | diff --git a/docs/zh-CN/docs/fundamental/market/market_status.md b/docs/zh-CN/docs/fundamental/market/market_status.md index 4b2bb10d..c482c685 100644 --- a/docs/zh-CN/docs/fundamental/market/market_status.md +++ b/docs/zh-CN/docs/fundamental/market/market_status.md @@ -33,18 +33,11 @@ longbridge market-status | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market code: `US`, `HK`, `SH`, `SZ`, `SG`. Omit for all markets. | +| market | string | 否 | 市场代码:`US`、`HK`、`SH`、`SZ`、`SG`。不填则返回全部市场。 | ### Request Example - - - -longbridge market-status - - - ```python @@ -232,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [market_status_rsp](#market_status_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [market_status_rsp](#market_status_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -243,7 +236,7 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Market status list | -| ∟ market | string | true | Market code | -| ∟ status | string | true | Status: `normal_trading`, `closed`, `pre_trading`, `after_trading` | -| ∟ trade_session | string | false | Current trading session | +| list | object[] | 是 | 市场状态列表 | +| ∟ market | string | 是 | 市场代码 | +| ∟ status | string | 是 | 状态:`normal_trading`(正常交易)、`closed`(已收市)、`pre_trading`(盘前)、`after_trading`(盘后) | +| ∟ trade_session | string | 否 | 当前交易时段 | diff --git a/docs/zh-CN/docs/fundamental/market/trading_stats.md b/docs/zh-CN/docs/fundamental/market/trading_stats.md index 7299f616..8583961b 100644 --- a/docs/zh-CN/docs/fundamental/market/trading_stats.md +++ b/docs/zh-CN/docs/fundamental/market/trading_stats.md @@ -34,19 +34,11 @@ longbridge trade-stats TSLA.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `700.HK` | +| symbol | string | 是 | 证券代码,例如 `700.HK` | ### Request Example - - - -longbridge trade-stats 700.HK -longbridge trade-stats TSLA.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [trading_stats_rsp](#trading_stats_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [trading_stats_rsp](#trading_stats_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -241,12 +233,12 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| prev_close | string | true | Previous close price | -| avg_price | string | true | Average trading price | -| trades | int32 | true | Number of trades | -| volume | string | true | Total volume | -| turnover | string | true | Total turnover | -| distribution | object[] | true | Price-volume distribution | -| ∟ price | string | true | Price level | -| ∟ volume | string | true | Volume at this price | -| ∟ pct | string | true | Percentage of total volume | +| prev_close | string | 是 | 前收盘价 | +| avg_price | string | 是 | 平均成交价 | +| trades | int32 | 是 | 成交笔数 | +| volume | string | 是 | 总成交量 | +| turnover | string | 是 | 总成交额 | +| distribution | object[] | 是 | 价格-成交量分布 | +| ∟ price | string | 是 | 价格档位 | +| ∟ volume | string | 是 | 该价格的成交量 | +| ∟ pct | string | 是 | 占总成交量的百分比 | diff --git a/docs/zh-CN/docs/fundamental/market/unusual_items.md b/docs/zh-CN/docs/fundamental/market/unusual_items.md index 8dea5b00..286b8755 100644 --- a/docs/zh-CN/docs/fundamental/market/unusual_items.md +++ b/docs/zh-CN/docs/fundamental/market/unusual_items.md @@ -34,19 +34,11 @@ longbridge anomaly --market HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | YES | Market code: `US`, `HK`, `SH`, `SZ`, `SG` | +| market | string | 是 | 市场代码:`US`、`HK`、`SH`、`SZ`、`SG` | ### Request Example - - - -longbridge anomaly --market US -longbridge anomaly --market HK - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [unusual_items_rsp](#unusual_items_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [unusual_items_rsp](#unusual_items_rsp) | +| 400 | 请求错误 | None | ## Schemas @@ -242,9 +234,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Unusual item list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Security name | -| ∟ alert | string | true | Alert description | -| ∟ emotion | string | false | Market sentiment: `Bullish`, `Bearish` | -| ∟ time | string | true | Alert time as Unix timestamp | +| list | object[] | 是 | 异动列表 | +| ∟ symbol | string | 是 | 证券代码 | +| ∟ name | string | 是 | 证券名称 | +| ∟ alert | string | 是 | 异动描述 | +| ∟ emotion | string | 否 | 市场情绪:`Bullish`(看多)、`Bearish`(看空) | +| ∟ time | string | 是 | 异动时间(Unix 时间戳) | diff --git a/docs/zh-CN/docs/fundamental/overview.md b/docs/zh-CN/docs/fundamental/overview.md new file mode 100644 index 00000000..70eb1a20 --- /dev/null +++ b/docs/zh-CN/docs/fundamental/overview.md @@ -0,0 +1,51 @@ +--- +sidebar_position: 0 +id: fundamental_overview +title: 概览 +slug: overview +--- + +# 基本面 API 概览 + +研究与市场数据接口,涵盖公司基本面、市场结构和财经日历。所有接口均为只读,通过 SDK 调用。 + +## FundamentalContext + +公司层面的财务数据与企业信息。 + +| 方法 | 说明 | +|---|---| +| [company_profile](./fundamental/company-profile) | 公司概况、行业及基本信息 | +| [financial_report](./fundamental/financial-report) | 利润表、资产负债表和现金流量表 | +| [valuations](./fundamental/valuations) | PE、PB、PS、EV/EBITDA 等估值指标 | +| [ratings](./fundamental/ratings) | 机构评级与目标价 | +| [dividends](./fundamental/dividends) | 历史分红记录 | +| [fund_holdings](./fundamental/fund-holdings) | 机构及基金持仓 | +| [shareholders](./fundamental/shareholders) | 主要股东 | +| [executives](./fundamental/executives) | 管理层与董事会成员 | +| [corporate_actions](./fundamental/corporate-actions) | 拆股、送股、配股等公司行动 | + +## MarketContext + +市场层面数据,包括指数成分、经纪商持仓和异动扫描。 + +| 方法 | 说明 | +|---|---| +| [market_status](./market/market-status) | 各市场当前交易状态 | +| [trading_stats](./market/trading-stats) | 标的盘中交易统计 | +| [index_components](./market/index-components) | 指数成分股列表 | +| [ah_premium](./market/ah-premium) | 两地上市股票的 A/H 股溢价率 | +| [broker_positions](./market/broker-positions) | 港股经纪商持仓(中央结算) | +| [unusual_items](./market/unusual-items) | 异常价格或成交量异动 | + +## CalendarContext + +财经事件日历,用于跟踪财报、分红和宏观数据发布。 + +| 方法 | 说明 | +|---|---| +| [earnings_calendar](./calendar/earnings-calendar) | 即将发布和近期的财报日期 | +| [dividend_calendar](./calendar/dividend-calendar) | 除权除息日和派息日 | +| [ipo_calendar](./calendar/ipo-calendar) | 新股认购和上市日期 | +| [split_calendar](./calendar/split-calendar) | 股票拆分生效日期 | +| [macro_calendar](./calendar/macro-calendar) | 宏观经济数据发布计划 | diff --git a/docs/zh-HK/docs/account/_category_.json b/docs/zh-HK/docs/account/_category_.json index 90e6e403..60cfc7ff 100644 --- a/docs/zh-HK/docs/account/_category_.json +++ b/docs/zh-HK/docs/account/_category_.json @@ -2,6 +2,7 @@ "position": 6, "label": "帳戶", "collapsible": true, - "collapsed": false, - "link": null + "collapsed": true, + "link": null, + "icon": "briefcase" } diff --git a/docs/zh-HK/docs/account/alert/_category_.json b/docs/zh-HK/docs/account/alert/_category_.json index 2fd2b4b5..6290e3f3 100644 --- a/docs/zh-HK/docs/account/alert/_category_.json +++ b/docs/zh-HK/docs/account/alert/_category_.json @@ -2,6 +2,6 @@ "position": 2, "label": "價格提醒", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/account/alert/create_alert.md b/docs/zh-HK/docs/account/alert/create_alert.md index 1666ad93..0f45fd22 100644 --- a/docs/zh-HK/docs/account/alert/create_alert.md +++ b/docs/zh-HK/docs/account/alert/create_alert.md @@ -1,6 +1,6 @@ --- slug: create-alert -title: 建立價格提醒 +title: 創建價格提醒 sidebar_position: 2 language_tabs: false toc_footers: [] @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -為指定證券建立價格提醒,當價格高於或低於目標價時觸發通知。 +為指定證券創建價格提醒,當價格高於或低於目標價時觸發通知。 longbridge alert add TSLA.US --price 300 --direction rise @@ -34,22 +34,14 @@ longbridge alert add AAPL.US --price 150 --direction fall | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `TSLA.US` | -| price | string | YES | Target price | -| direction | string | YES | Alert direction: `rise` or `fall` | -| frequency | string | NO | Trigger frequency: `once` (default) or `every` | +| symbol | string | 是 | 證券代碼,例如 `TSLA.US` | +| price | string | 是 | 目標價格 | +| direction | string | 是 | 提醒方向:`rise`(上漲)或 `fall`(下跌) | +| frequency | string | 否 | 觸發頻率:`once`(僅一次,默認)或 `every`(每次) | ### Request Example - - - -longbridge alert add TSLA.US --price 300 --direction rise -longbridge alert add AAPL.US --price 150 --direction fall - - - ```python @@ -226,8 +218,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [create_alert_rsp](#create_alert_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [create_alert_rsp](#create_alert_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -237,4 +229,4 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | true | ID of the newly created alert | +| id | int64 | true | 新創建提醒的 ID | diff --git a/docs/zh-HK/docs/account/alert/delete_alert.md b/docs/zh-HK/docs/account/alert/delete_alert.md index 16089796..15a07cfc 100644 --- a/docs/zh-HK/docs/account/alert/delete_alert.md +++ b/docs/zh-HK/docs/account/alert/delete_alert.md @@ -34,19 +34,11 @@ longbridge alert delete 112326 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Alert ID (path parameter) | +| id | int64 | 是 | 提醒 ID(路徑參數) | ### Request Example - - - -longbridge alert delete 486469 -longbridge alert delete 112326 - - - ```python @@ -221,8 +213,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [delete_alert_rsp](#delete_alert_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [delete_alert_rsp](#delete_alert_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -230,4 +222,4 @@ func main() { -No response body fields. +無響應體字段。 diff --git a/docs/zh-HK/docs/account/alert/disable_alert.md b/docs/zh-HK/docs/account/alert/disable_alert.md new file mode 100644 index 00000000..78d9aad4 --- /dev/null +++ b/docs/zh-HK/docs/account/alert/disable_alert.md @@ -0,0 +1,183 @@ +--- +slug: disable-alert +title: 暫停提醒 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +暫停一個價格提醒而不刪除它。 + + +longbridge alert disable 486469 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/{alert_id}/disable
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| alert_id | string | 是 | 要暫停的提醒 ID | + +### Request Example + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +ctx.disable("486469") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + await ctx.disable("486469") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + await ctx.disable('486469') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + ctx.disable("486469").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + ctx.disable("486469").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Disable(context.Background(), "486469"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/alert/enable_alert.md b/docs/zh-HK/docs/account/alert/enable_alert.md new file mode 100644 index 00000000..8fc118c1 --- /dev/null +++ b/docs/zh-HK/docs/account/alert/enable_alert.md @@ -0,0 +1,183 @@ +--- +slug: enable-alert +title: 啟用提醒 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +重新啟用一個已暫停的價格提醒。 + + +longbridge alert enable 486469 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/account/alerts/{alert_id}/enable
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| alert_id | string | 是 | 要啟用的提醒 ID | + +### Request Example + + + + +```python +from longbridge.openapi import AlertContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = AlertContext(config) + +ctx.enable("486469") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncAlertContext, 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 = AsyncAlertContext.create(config) + + await ctx.enable("486469") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, AlertContext, 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 = AlertContext.new(config) + await ctx.enable('486469') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.alert.*; + +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); + AlertContext ctx = AlertContext.create(config)) { + ctx.enable("486469").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, alert::AlertContext, 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 = AlertContext::new(config); + ctx.enable("486469").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/alert" +) + +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 := alert.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Enable(context.Background(), "486469"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/alert/list_alerts.md b/docs/zh-HK/docs/account/alert/list_alerts.md index f92432a8..df141069 100644 --- a/docs/zh-HK/docs/account/alert/list_alerts.md +++ b/docs/zh-HK/docs/account/alert/list_alerts.md @@ -34,19 +34,11 @@ longbridge alert TSLA.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | NO | Filter by security symbol, e.g. `TSLA.US` | +| symbol | string | 否 | 按證券代碼篩選,例如 `TSLA.US` | ### Request Example - - - -longbridge alert -longbridge alert TSLA.US - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [list_alerts_rsp](#list_alerts_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [list_alerts_rsp](#list_alerts_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -243,10 +235,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Alert list | -| ∟ id | int64 | true | Alert ID | -| ∟ symbol | string | true | Security symbol | -| ∟ price | string | true | Target price | -| ∟ direction | string | true | Direction: `rise` or `fall` | -| ∟ enabled | bool | true | Whether alert is enabled | -| ∟ frequency | string | true | Trigger frequency: `once` or `every` | +| list | object[] | true | 提醒列表 | +| ∟ id | int64 | true | 提醒 ID | +| ∟ symbol | string | true | 證券代碼 | +| ∟ price | string | true | 目標價格 | +| ∟ direction | string | true | 方向:`rise`(上漲)或 `fall`(下跌) | +| ∟ enabled | bool | true | 提醒是否啟用 | +| ∟ frequency | string | true | 觸發頻率:`once`(僅一次)或 `every`(每次) | diff --git a/docs/zh-HK/docs/account/alert/update_alert.md b/docs/zh-HK/docs/account/alert/update_alert.md index 5c42b14e..14db8ab6 100644 --- a/docs/zh-HK/docs/account/alert/update_alert.md +++ b/docs/zh-HK/docs/account/alert/update_alert.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -啟用或停用已有的價格提醒。 +啟用或禁用已有的價格提醒。 longbridge alert enable 112326 @@ -34,20 +34,12 @@ longbridge alert disable 112326 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Alert ID (path parameter) | -| enabled | bool | YES | Set to `true` to enable or `false` to disable | +| id | int64 | 是 | 提醒 ID(路徑參數) | +| enabled | bool | 是 | 設為 `true` 啟用,`false` 禁用 | ### Request Example - - - -longbridge alert enable 112326 -longbridge alert disable 112326 - - - ```python @@ -222,8 +214,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [update_alert_rsp](#update_alert_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [update_alert_rsp](#update_alert_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -231,4 +223,4 @@ func main() { -No response body fields. +無響應體字段。 diff --git a/docs/zh-HK/docs/account/dca/_category_.json b/docs/zh-HK/docs/account/dca/_category_.json index 77374e67..aff6863a 100644 --- a/docs/zh-HK/docs/account/dca/_category_.json +++ b/docs/zh-HK/docs/account/dca/_category_.json @@ -2,6 +2,6 @@ "position": 3, "label": "定期投資", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/account/dca/calc_date.md b/docs/zh-HK/docs/account/dca/calc_date.md new file mode 100644 index 00000000..06648ecf --- /dev/null +++ b/docs/zh-HK/docs/account/dca/calc_date.md @@ -0,0 +1,211 @@ +--- +slug: calc-date +title: 計算定投日期 +sidebar_position: 10 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +根據給定的定投計劃參數,計算下一次預計交易日期。 + + +longbridge dca calc-date AAPL.US --frequency monthly --day-of-month 15 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/calc_date
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 標的代碼 | +| frequency | string | 是 | 定投頻率:`daily`、`weekly`、`fortnightly`、`monthly` | +| day_of_week | string | 否 | 每週計劃的執行星期:`mon`–`fri` | +| day_of_month | integer | 否 | 每月/每兩週計劃的執行日期:1–28 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder, DCAFrequency + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.calc_date("AAPL.US", DCAFrequency.Monthly, day_of_month=15) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, Config, OAuthBuilder, DCAFrequency + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncDCAContext.create(config) + + resp = await ctx.calc_date("AAPL.US", DCAFrequency.Monthly, day_of_month=15) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, OAuth, DCAFrequency } = 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 = DCAContext.new(config) + const resp = await ctx.calcDate('AAPL.US', DCAFrequency.Monthly, undefined, 15) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var opts = new CalcDateOptions("AAPL.US", DCAFrequency.MONTHLY).dayOfMonth(15); + var resp = ctx.calcDate(opts).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, dca::DCAFrequency, 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 = DCAContext::new(config); + let resp = ctx.calc_date("AAPL.US", DCAFrequency::Monthly, None, Some(15)).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + dayOfMonth := 15 + opts := &dca.CalcDateOptions{ + Symbol: "AAPL.US", + Frequency: dca.FrequencyMonthly, + DayOfMonth: &dayOfMonth, + } + resp, err := c.CalcDate(context.Background(), opts) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "trade_date": "2024-02-15" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DcaCalcDateResult](#DcaCalcDateResult) | +| 400 | 請求錯誤 | None | + +## Schemas + +### DcaCalcDateResult + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| trade_date | string | true | 下一次預計交易日期(YYYY-MM-DD) | diff --git a/docs/zh-HK/docs/account/dca/check_support.md b/docs/zh-HK/docs/account/dca/check_support.md new file mode 100644 index 00000000..d89e502d --- /dev/null +++ b/docs/zh-HK/docs/account/dca/check_support.md @@ -0,0 +1,212 @@ +--- +slug: check-support +title: 檢查定投支持 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +檢查指定標的是否支持定投。 + + +longbridge dca check AAPL.US 700.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/support
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbols | string[] | 是 | 待檢查的標的代碼列表 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.check_support(["AAPL.US", "700.HK"]) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.check_support(["AAPL.US", "700.HK"]) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.checkSupport(['AAPL.US', '700.HK']) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; +import java.util.Arrays; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.checkSupport(Arrays.asList("AAPL.US", "700.HK")).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.check_support(vec!["AAPL.US".into(), "700.HK".into()]).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.CheckSupport(context.Background(), []string{"AAPL.US", "700.HK"}) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { "symbol": "AAPL.US", "support": true }, + { "symbol": "700.HK", "support": true } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DcaSupportList](#DcaSupportList) | +| 400 | 請求錯誤 | None | + +## Schemas + +### DcaSupportList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | DcaSupportItem[] | true | 支持情況列表 | + +### DcaSupportItem + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | true | 標的代碼 | +| support | boolean | true | 是否支持定投 | diff --git a/docs/zh-HK/docs/account/dca/create_dca.md b/docs/zh-HK/docs/account/dca/create_dca.md index bce1fb24..60051582 100644 --- a/docs/zh-HK/docs/account/dca/create_dca.md +++ b/docs/zh-HK/docs/account/dca/create_dca.md @@ -1,6 +1,6 @@ --- slug: create-dca -title: 建立定期投資計劃 +title: 創建定期投資計劃 sidebar_position: 2 language_tabs: false toc_footers: [] @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -為指定證券建立新的定期投資計劃。 +為指定證券創建新的定期投資計劃。 longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 @@ -34,23 +34,15 @@ longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| amount | string | YES | Recurring investment amount | -| frequency | string | YES | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | -| day_of_week | string | NO | Day of week for weekly/fortnightly plans: `mon`–`fri` | -| day_of_month | integer | NO | Day of month for monthly plans (1–28) | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| amount | string | 是 | 定投金額 | +| frequency | string | 是 | 頻率:`Daily`(每日)、`Weekly`(每週)、`Fortnightly`(每兩週)、`Monthly`(每月) | +| day_of_week | string | 否 | 每週/每兩週計劃的執行星期:`mon`–`fri` | +| day_of_month | integer | 否 | 每月計劃的執行日期(1–28) | ### Request Example - - - -longbridge dca create AAPL.US --amount 500 --frequency monthly --day-of-month 15 -longbridge dca create TSLA.US --amount 200 --frequency weekly --day-of-week mon - - - ```python @@ -227,8 +219,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [create_dca_rsp](#create_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [create_dca_rsp](#create_dca_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -238,4 +230,4 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | true | ID of the newly created plan | +| id | string | true | 新創建計劃的 ID | diff --git a/docs/zh-HK/docs/account/dca/dca_history.md b/docs/zh-HK/docs/account/dca/dca_history.md index 6d757cbf..1957e5d0 100644 --- a/docs/zh-HK/docs/account/dca/dca_history.md +++ b/docs/zh-HK/docs/account/dca/dca_history.md @@ -33,20 +33,13 @@ longbridge dca history 1225781523156889600 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | YES | Plan ID (path parameter) | -| page | integer | NO | Page number (1-based, default: 1) | -| size | integer | NO | Records per page (default: 20) | +| id | string | 是 | 計劃 ID(路徑參數) | +| page | integer | 否 | 頁碼(從 1 開始,默認:1) | +| size | integer | 否 | 每頁數量(默認:20) | ### Request Example - - - -longbridge dca history 1225781523156889600 - - - ```python @@ -232,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [dca_history_rsp](#dca_history_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [dca_history_rsp](#dca_history_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -243,10 +236,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Trade history records | -| ∟ trade_date | string | true | Trade execution date (ISO 8601) | -| ∟ symbol | string | true | Security symbol | -| ∟ amount | string | true | Invested amount | -| ∟ price | string | false | Execution price | -| ∟ quantity | string | false | Quantity purchased | -| ∟ status | string | true | Trade status: `Filled`, `Failed` | +| list | object[] | true | 交易歷史紀錄 | +| ∟ trade_date | string | true | 交易執行日期(ISO 8601) | +| ∟ symbol | string | true | 證券代碼 | +| ∟ amount | string | true | 投入金額 | +| ∟ price | string | false | 成交價格 | +| ∟ quantity | string | false | 買入數量 | +| ∟ status | string | true | 交易狀態:`Filled`(已成交)、`Failed`(失敗) | diff --git a/docs/zh-HK/docs/account/dca/dca_stats.md b/docs/zh-HK/docs/account/dca/dca_stats.md new file mode 100644 index 00000000..080f2ea3 --- /dev/null +++ b/docs/zh-HK/docs/account/dca/dca_stats.md @@ -0,0 +1,205 @@ +--- +slug: dca-stats +title: 定投統計 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取定投統計匯總信息,包括總投入金額和盈虧情況。 + + +longbridge dca stats + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/dca/stats
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 否 | 按標的過濾 | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +resp = ctx.stats() +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + resp = await ctx.stats() + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + const resp = await ctx.stats() + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + var resp = ctx.stats(null).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + let resp = ctx.stats(None).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Stats(context.Background(), nil) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "total_invested": "10000.00", + "total_profit_loss": "1500.00", + "total_profit_loss_rate": "0.15" + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DcaStats](#DcaStats) | +| 400 | 請求錯誤 | None | + +## Schemas + +### DcaStats + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| total_invested | string | true | 總投入金額 | +| total_profit_loss | string | true | 總盈虧金額 | +| total_profit_loss_rate | string | true | 總盈虧比率 | diff --git a/docs/zh-HK/docs/account/dca/delete_dca.md b/docs/zh-HK/docs/account/dca/delete_dca.md index 4479ba25..96da066f 100644 --- a/docs/zh-HK/docs/account/dca/delete_dca.md +++ b/docs/zh-HK/docs/account/dca/delete_dca.md @@ -33,18 +33,11 @@ longbridge dca stop 1225781523156889600 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | YES | Plan ID (path parameter) | +| id | string | 是 | 計劃 ID(路徑參數) | ### Request Example - - - -longbridge dca stop 1225781523156889600 - - - ```python @@ -219,8 +212,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [delete_dca_rsp](#delete_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [delete_dca_rsp](#delete_dca_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -228,4 +221,4 @@ func main() { -No response body fields. +無響應體字段。 diff --git a/docs/zh-HK/docs/account/dca/list_dca.md b/docs/zh-HK/docs/account/dca/list_dca.md index ffb15e6a..d0a21cad 100644 --- a/docs/zh-HK/docs/account/dca/list_dca.md +++ b/docs/zh-HK/docs/account/dca/list_dca.md @@ -34,20 +34,12 @@ longbridge dca --status Active | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| status | string | NO | Filter by plan status: `Active`, `Suspended`, `Finished` | -| symbol | string | NO | Filter by security symbol | +| status | string | 否 | 按計劃狀態篩選:`Active`(進行中)、`Suspended`(已暫停)、`Finished`(已結束) | +| symbol | string | 否 | 按證券代碼篩選 | ### Request Example - - - -longbridge dca -longbridge dca --status Active - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [list_dca_rsp](#list_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [list_dca_rsp](#list_dca_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -245,11 +237,11 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | DCA plan list | -| ∟ id | string | true | Plan ID | -| ∟ symbol | string | true | Security symbol | -| ∟ status | string | true | Plan status: `Active`, `Suspended`, `Finished` | -| ∟ amount | string | true | Recurring investment amount | -| ∟ frequency | string | true | Frequency: `Daily`, `Weekly`, `Fortnightly`, `Monthly` | -| ∟ day_of_week | string | false | Day of week for weekly/fortnightly plans | -| ∟ next_trade_date | string | false | Next scheduled trade date (ISO 8601) | +| list | object[] | true | 定投計劃列表 | +| ∟ id | string | true | 計劃 ID | +| ∟ symbol | string | true | 證券代碼 | +| ∟ status | string | true | 計劃狀態:`Active`(進行中)、`Suspended`(已暫停)、`Finished`(已結束) | +| ∟ amount | string | true | 定投金額 | +| ∟ frequency | string | true | 頻率:`Daily`(每日)、`Weekly`(每週)、`Fortnightly`(每兩週)、`Monthly`(每月) | +| ∟ day_of_week | string | false | 每週/每兩週計劃的執行星期 | +| ∟ next_trade_date | string | false | 下次計劃交易日期(ISO 8601) | diff --git a/docs/zh-HK/docs/account/dca/pause_dca.md b/docs/zh-HK/docs/account/dca/pause_dca.md new file mode 100644 index 00000000..99c450bc --- /dev/null +++ b/docs/zh-HK/docs/account/dca/pause_dca.md @@ -0,0 +1,181 @@ +--- +slug: pause-dca +title: 暫停定投計劃 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +暫停一個定投計劃。計劃暫停後可隨時恢復。 + + +longbridge dca pause 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/pause
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | 是 | 定投計劃 ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.pause("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.pause("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.pause('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.pause("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.pause("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Pause(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/dca/resume_dca.md b/docs/zh-HK/docs/account/dca/resume_dca.md new file mode 100644 index 00000000..0ceda777 --- /dev/null +++ b/docs/zh-HK/docs/account/dca/resume_dca.md @@ -0,0 +1,181 @@ +--- +slug: resume-dca +title: 恢復定投計劃 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +恢復一個已暫停的定投計劃。 + + +longbridge dca resume 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/resume
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | 是 | 定投計劃 ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.resume("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.resume("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.resume('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.resume("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.resume("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Resume(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/dca/set_reminder.md b/docs/zh-HK/docs/account/dca/set_reminder.md new file mode 100644 index 00000000..81a38286 --- /dev/null +++ b/docs/zh-HK/docs/account/dca/set_reminder.md @@ -0,0 +1,183 @@ +--- +slug: set-reminder +title: 設置定投提醒 +sidebar_position: 11 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +設置定投計劃的提前提醒時間。支持的值:`1`、`6` 或 `12` 小時。 + + +longbridge dca set-reminder 12 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/reminder
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| hours | string | 是 | 提醒提前小時數:`1`、`6` 或 `12` | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.set_reminder("12") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.set_reminder("12") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.setReminder('12') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.setReminder("12").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.set_reminder("12").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.SetReminder(context.Background(), "12"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/dca/stop_dca.md b/docs/zh-HK/docs/account/dca/stop_dca.md new file mode 100644 index 00000000..44a1f46b --- /dev/null +++ b/docs/zh-HK/docs/account/dca/stop_dca.md @@ -0,0 +1,181 @@ +--- +slug: stop-dca +title: 終止定投計劃 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +永久終止一個定投計劃。此操作不可撤銷。 + + +longbridge dca stop 12345 + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/dca/{plan_id}/stop
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| plan_id | string | 是 | 定投計劃 ID | + +### Request Example + + + + +```python +from longbridge.openapi import DCAContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = DCAContext(config) + +ctx.stop("12345") +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config) + + await ctx.stop("12345") + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, DCAContext, 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 = DCAContext.new(config) + await ctx.stop('12345') +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.dca.*; + +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); + DCAContext ctx = DCAContext.create(config)) { + ctx.stop("12345").get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config); + ctx.stop("12345").await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/dca" +) + +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 := dca.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.Stop(context.Background(), "12345"); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/dca/update_dca.md b/docs/zh-HK/docs/account/dca/update_dca.md index 2672a225..d24040cd 100644 --- a/docs/zh-HK/docs/account/dca/update_dca.md +++ b/docs/zh-HK/docs/account/dca/update_dca.md @@ -34,20 +34,12 @@ longbridge dca resume 1225781523156889600 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | string | YES | Plan ID (path parameter) | -| action | string | YES | Action to perform: `pause` or `resume` | +| id | string | 是 | 計劃 ID(路徑參數) | +| action | string | 是 | 執行操作:`pause`(暫停)或 `resume`(恢復) | ### Request Example - - - -longbridge dca pause 1225781523156889600 -longbridge dca resume 1225781523156889600 - - - ```python @@ -222,8 +214,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [update_dca_rsp](#update_dca_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [update_dca_rsp](#update_dca_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -231,4 +223,4 @@ func main() { -No response body fields. +無響應體字段。 diff --git a/docs/zh-HK/docs/account/overview.md b/docs/zh-HK/docs/account/overview.md new file mode 100644 index 00000000..1956ae9c --- /dev/null +++ b/docs/zh-HK/docs/account/overview.md @@ -0,0 +1,55 @@ +--- +sidebar_position: 0 +id: account_overview +title: 概覽 +slug: overview +--- + +# 賬戶 API 概覽 + +賬戶管理接口,涵盖组合分析、價格提醒、定投计划和股單管理。大多数接口需要交易级别的认证权限。 + +## PortfolioContext + +组合盈亏分析与外汇汇率查询。 + +| 方法 | 说明 | +|---|---| +| [profit_analysis_summary](./portfolio/profit-analysis-summary) | 组合整体盈亏汇总 | +| [profit_analysis_detail](./portfolio/profit-analysis-detail) | 按持仓明细的盈亏拆分 | +| [profit_analysis_by_market](./portfolio/profit-analysis-by-market) | 按市场分组的盈亏统计 | +| [capital_flow](./portfolio/capital-flow) | 賬戶资金流水记录 | +| [exchange_rates](./portfolio/exchange-rates) | 支持币种的当前汇率 | + +## AlertContext + +建立和管理标的價格提醒。 + +| 方法 | 说明 | +|---|---| +| [list_alerts](./alert/list-alerts) | 查看所有有效的價格提醒 | +| [create_alert](./alert/create-alert) | 建立新的價格提醒 | +| [update_alert](./alert/update-alert) | 修改已有提醒 | +| [delete_alert](./alert/delete-alert) | 刪除價格提醒 | + +## DCAContext + +管理定期定额投资(定投)计划。 + +| 方法 | 说明 | +|---|---| +| [list_dca](./dca/list-dca) | 查看所有定投计划 | +| [create_dca](./dca/create-dca) | 新建定投计划 | +| [dca_history](./dca/dca-history) | 查看定投计划的执行记录 | +| [delete_dca](./dca/delete-dca) | 取消定投计划 | + +## SharelistContext + +建立和管理社区股單(可分享给他人的自选列表)。 + +| 方法 | 说明 | +|---|---| +| [list_sharelist](./sharelist/list-sharelist) | 查看所有股單 | +| [create_sharelist](./sharelist/create-sharelist) | 新建股單 | +| [update_sharelist](./sharelist/update-sharelist) | 更新股單 | +| [delete_sharelist](./sharelist/delete-sharelist) | 刪除股單 | diff --git a/docs/zh-HK/docs/account/portfolio/_category_.json b/docs/zh-HK/docs/account/portfolio/_category_.json index c9a54593..befc825e 100644 --- a/docs/zh-HK/docs/account/portfolio/_category_.json +++ b/docs/zh-HK/docs/account/portfolio/_category_.json @@ -2,6 +2,6 @@ "position": 1, "label": "投資組合", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/account/portfolio/exchange_rates.md b/docs/zh-HK/docs/account/portfolio/exchange_rates.md index a8240224..e69eaddf 100644 --- a/docs/zh-HK/docs/account/portfolio/exchange_rates.md +++ b/docs/zh-HK/docs/account/portfolio/exchange_rates.md @@ -33,18 +33,11 @@ longbridge exchange-rate | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| base | string | NO | Base currency, e.g. `USD`. Omit for all pairs. | +| base | string | 否 | 基礎貨幣,例如 `USD`,不傳則返回所有貨幣對 | ### Request Example - - - -longbridge exchange-rate - - - ```python @@ -228,8 +221,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [exchange_rates_rsp](#exchange_rates_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [exchange_rates_rsp](#exchange_rates_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -239,8 +232,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Exchange rate list | -| ∟ pair | string | true | Currency pair, e.g. `HKD/USD` | -| ∟ bid_rate | string | true | Bid rate | -| ∟ offer_rate | string | true | Offer rate | -| ∟ average_rate | string | true | Average rate | +| list | object[] | true | 匯率列表 | +| ∟ pair | string | true | 貨幣對,例如 `HKD/USD` | +| ∟ bid_rate | string | true | 買入匯率 | +| ∟ offer_rate | string | true | 賣出匯率 | +| ∟ average_rate | string | true | 中間匯率 | diff --git a/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md index 6a224ccd..47597c61 100644 --- a/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_by_market.md @@ -34,20 +34,12 @@ longbridge profit-analysis --start 2026-01-01 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | -| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | +| start_date | string | 否 | 分析開始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 分析結束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge profit-analysis --format json -longbridge profit-analysis --start 2026-01-01 - - - ```python @@ -239,8 +231,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_by_market_rsp](#profit_analysis_by_market_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -250,9 +242,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | P&L by market list | -| ∟ market | string | true | Market code | -| ∟ pnl | string | true | P&L for this market | -| ∟ pnl_pct | string | true | P&L percentage | -| ∟ market_value | string | false | Market value | -| ∟ currency | string | true | Settlement currency | +| list | object[] | true | 按市場盈虧列表 | +| ∟ market | string | true | 市場代碼 | +| ∟ pnl | string | true | 該市場盈虧金額 | +| ∟ pnl_pct | string | true | 盈虧百分比 | +| ∟ market_value | string | false | 市值 | +| ∟ currency | string | true | 結算貨幣 | diff --git a/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md index c6790ad3..05f73f17 100644 --- a/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_detail.md @@ -34,21 +34,13 @@ longbridge profit-analysis detail AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `TSLA.US` | -| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | -| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | +| symbol | string | 是 | 證券代碼,例如 `TSLA.US` | +| start_date | string | 否 | 分析開始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 分析結束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge profit-analysis detail TSLA.US -longbridge profit-analysis detail AAPL.US - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_detail_rsp](#profit_analysis_detail_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -242,10 +234,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | true | Security symbol | -| name | string | true | Security name | -| pnl | string | true | Total P&L | -| pnl_pct | string | true | P&L percentage | -| cost | string | true | Total cost basis | -| market_value | string | false | Current market value | -| currency | string | true | Currency | +| symbol | string | true | 證券代碼 | +| name | string | true | 證券名稱 | +| pnl | string | true | 總盈虧金額 | +| pnl_pct | string | true | 盈虧百分比 | +| cost | string | true | 總成本 | +| market_value | string | false | 當前市值 | +| currency | string | true | 貨幣 | diff --git a/docs/zh-HK/docs/account/portfolio/capital_flow.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_flows.md similarity index 74% rename from docs/zh-HK/docs/account/portfolio/capital_flow.md rename to docs/zh-HK/docs/account/portfolio/profit_analysis_flows.md index 3291a532..d0afa066 100644 --- a/docs/zh-HK/docs/account/portfolio/capital_flow.md +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_flows.md @@ -1,6 +1,6 @@ --- -slug: capital-flow -title: 資金流水 +slug: profit-analysis-flows +title: 盈虧流水 sidebar_position: 5 language_tabs: false toc_footers: [] @@ -10,21 +10,21 @@ highlight_theme: '' headingLevel: 2 --- -查詢賬戶資金流水歷史,包含入金、出金、分紅和結算等。 +查詢賬戶資金流水歷史,包含入金、出金、股息和結算等。 longbridge cash-flow longbridge cash-flow --format json - + ## Request - +
HTTP MethodGET
HTTP URL/v1/account/capital_flow
HTTP URL/v1/account/profit_analysis/flows
@@ -34,24 +34,14 @@ longbridge cash-flow --format json | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_time | integer | NO | Start time as Unix timestamp (seconds) | -| end_time | integer | NO | End time as Unix timestamp (seconds) | -| business_type | integer | NO | Business type filter. Omit for all types. | -| symbol | string | NO | Filter by security symbol | -| page | integer | NO | Page number (1-based, default: 1) | -| size | integer | NO | Records per page (default: 20) | +| symbol | string | YES | 證券代碼 | +| page | integer | NO | 頁碼(預設 1) | +| size | integer | NO | 每頁數量(預設 20) | +| derivative | boolean | NO | 是否包含衍生品倉位 | ### Request Example - - - -longbridge cash-flow -longbridge cash-flow --format json - - - ```python @@ -61,7 +51,7 @@ oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) config = Config.from_oauth(oauth) ctx = PortfolioContext(config) -resp = ctx.capital_flow() +resp = ctx.profit_analysis_flows() print(resp) ``` @@ -77,7 +67,7 @@ async def main() -> None: config = Config.from_oauth(oauth) ctx = AsyncPortfolioContext.create(config) - resp = await ctx.capital_flow() + resp = await ctx.profit_analysis_flows() print(resp) if __name__ == "__main__": @@ -96,7 +86,7 @@ async function main() { }) const config = Config.fromOAuth(oauth) const ctx = PortfolioContext.new(config) - const resp = await ctx.capital_flow() + const resp = await ctx.profit_analysis_flows() console.log(resp) } main().catch(console.error) @@ -114,7 +104,7 @@ class Main { try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); Config config = Config.fromOAuth(oauth); PortfolioContext ctx = PortfolioContext.create(config)) { - var resp = ctx.getCapitalFlow().get(); + var resp = ctx.getProfitAnalysisFlows().get(); System.out.println(resp); } } @@ -133,7 +123,7 @@ 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 = PortfolioContext::new(config); - let resp = ctx.capital_flow().await?; + let resp = ctx.profit_analysis_flows().await?; println!("{:?}", resp); Ok(()) } @@ -156,7 +146,7 @@ int main() { if (!res) return; Config config = Config::from_oauth(*res); PortfolioContext ctx = PortfolioContext::create(config); - ctx.capital_flow([](auto resp) { + ctx.profit_analysis_flows([](auto resp) { if (resp) std::cout << "OK" << std::endl; }); }); @@ -195,7 +185,7 @@ func main() { log.Fatal(err) } defer c.Close() - resp, err := c.CapitalFlow(context.Background()) + resp, err := c.ProfitAnalysisFlows(context.Background()) if err != nil { log.Fatal(err) } @@ -238,22 +228,22 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [capital_flow_rsp](#capital_flow_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_flows_rsp](#profit_analysis_flows_rsp) | +| 400 | 請求錯誤 | None | ## Schemas -### capital_flow_rsp +### profit_analysis_flows_rsp - + | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Cash flow records | -| ∟ transaction_flow_name | string | true | Flow type description | -| ∟ direction | int32 | true | `1` = inflow, `-1` = outflow | -| ∟ business_type | int32 | true | Business type code | -| ∟ balance | string | true | Amount | -| ∟ currency | string | true | Currency | -| ∟ business_time | string | true | Transaction time as Unix timestamp | -| ∟ symbol | string | false | Associated security symbol | +| list | object[] | true | 資金流水記錄 | +| ∟ transaction_flow_name | string | true | 流水類型描述 | +| ∟ direction | int32 | true | `1` 表示入賬,`-1` 表示出賬 | +| ∟ business_type | int32 | true | 業務類型編碼 | +| ∟ balance | string | true | 金額 | +| ∟ currency | string | true | 貨幣 | +| ∟ business_time | string | true | 交易時間,Unix 時間戳 | +| ∟ symbol | string | false | 關聯證券代碼 | diff --git a/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md b/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md index 83f8890e..29560a84 100644 --- a/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md +++ b/docs/zh-HK/docs/account/portfolio/profit_analysis_summary.md @@ -34,20 +34,12 @@ longbridge profit-analysis --start 2026-01-01 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| start_date | string | NO | Analysis start date in `YYYY-MM-DD` format | -| end_date | string | NO | Analysis end date in `YYYY-MM-DD` format | +| start_date | string | 否 | 分析開始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 分析結束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge profit-analysis -longbridge profit-analysis --start 2026-01-01 - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [profit_analysis_summary_rsp](#profit_analysis_summary_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -243,12 +235,12 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| currency | string | true | Settlement currency | -| total_asset | string | true | Total asset value | -| invest_amount | string | true | Total invested amount | -| total_pnl | string | true | Total P&L | -| simple_yield | string | true | Simple yield ratio | -| twr | string | true | Time-weighted return | -| stocks_traded | int32 | true | Number of stocks traded | -| start_date | string | true | Analysis start date | -| end_date | string | true | Analysis end date | +| currency | string | true | 結算貨幣 | +| total_asset | string | true | 總資產價值 | +| invest_amount | string | true | 總投入金額 | +| total_pnl | string | true | 總盈虧金額 | +| simple_yield | string | true | 簡單收益率 | +| twr | string | true | 時間加權收益率 | +| stocks_traded | int32 | true | 已交易股票數量 | +| start_date | string | true | 分析開始日期 | +| end_date | string | true | 分析結束日期 | diff --git a/docs/zh-HK/docs/account/sharelist/_category_.json b/docs/zh-HK/docs/account/sharelist/_category_.json index 50b9e927..47a6469e 100644 --- a/docs/zh-HK/docs/account/sharelist/_category_.json +++ b/docs/zh-HK/docs/account/sharelist/_category_.json @@ -2,6 +2,6 @@ "position": 4, "label": "自選股", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/account/sharelist/add_securities.md b/docs/zh-HK/docs/account/sharelist/add_securities.md new file mode 100644 index 00000000..e645eaca --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/add_securities.md @@ -0,0 +1,185 @@ +--- +slug: add-securities +title: 新增標的到股單 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +向股單中新增一個或多個標的。 + + +longbridge sharelist add 123 TSLA.US AAPL.US + + + + +## Request + + + + + + +
HTTP MethodPOST
HTTP URL/v1/sharelist/{id}/securities
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股單 ID | +| symbols | string[] | 是 | 待新增的標的代碼 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.add_securities(123, ["TSLA.US", "AAPL.US"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.add_securities(123, ["TSLA.US", "AAPL.US"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.addSecurities(123, ['TSLA.US', 'AAPL.US']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.addSecurities(123, Arrays.asList("TSLA.US", "AAPL.US")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.add_securities(123, vec!["TSLA.US".into(), "AAPL.US".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.AddSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/sharelist/create_sharelist.md b/docs/zh-HK/docs/account/sharelist/create_sharelist.md index 526865a6..5655020c 100644 --- a/docs/zh-HK/docs/account/sharelist/create_sharelist.md +++ b/docs/zh-HK/docs/account/sharelist/create_sharelist.md @@ -1,6 +1,6 @@ --- slug: create-sharelist -title: 建立自選列表 +title: 創建自選列表 sidebar_position: 2 language_tabs: false toc_footers: [] @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -建立新的社群自選股列表,可選擇預設初始證券。 +創建新的社區自選股列表,可選擇預設初始證券。 longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" @@ -33,20 +33,13 @@ longbridge sharelist create --name "AI Picks" --description "Top AI infrastructu | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| name | string | YES | Sharelist name | -| description | string | NO | Description | -| securities | string[] | NO | Initial list of security symbols, e.g. `["AAPL.US", "NVDA.US"]` | +| name | string | 是 | 股單名稱 | +| description | string | 否 | 描述 | +| securities | string[] | 否 | 初始證券代碼列表,例如 `["AAPL.US", "NVDA.US"]` | ### Request Example - - - -longbridge sharelist create --name "AI Picks" --description "Top AI infrastructure stocks" - - - ```python @@ -223,8 +216,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [create_sharelist_rsp](#create_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [create_sharelist_rsp](#create_sharelist_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -234,4 +227,4 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | true | ID of the newly created sharelist | +| id | int64 | true | 新創建股單的 ID | diff --git a/docs/zh-HK/docs/account/sharelist/delete_sharelist.md b/docs/zh-HK/docs/account/sharelist/delete_sharelist.md index 7aed322a..ac847a2e 100644 --- a/docs/zh-HK/docs/account/sharelist/delete_sharelist.md +++ b/docs/zh-HK/docs/account/sharelist/delete_sharelist.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -永久刪除您建立的自選股列表,此操作不可撤銷。 +永久刪除您創建的自選股列表,此操作不可撤銷。 longbridge sharelist delete 15921 @@ -33,18 +33,11 @@ longbridge sharelist delete 15921 | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Sharelist ID (path parameter) | +| id | int64 | 是 | 股單 ID(路徑參數) | ### Request Example - - - -longbridge sharelist delete 15921 - - - ```python @@ -219,8 +212,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [delete_sharelist_rsp](#delete_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [delete_sharelist_rsp](#delete_sharelist_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -228,4 +221,4 @@ func main() { -No response body fields. +無響應體字段。 diff --git a/docs/zh-HK/docs/account/sharelist/list_sharelist.md b/docs/zh-HK/docs/account/sharelist/list_sharelist.md index a986c389..034e6b1b 100644 --- a/docs/zh-HK/docs/account/sharelist/list_sharelist.md +++ b/docs/zh-HK/docs/account/sharelist/list_sharelist.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -獲取當前用戶建立的或訂閱的所有社群自選股列表。 +獲取當前用戶創建的或訂閱的所有社區自選股列表。 longbridge sharelist @@ -34,19 +34,11 @@ longbridge sharelist --format json | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| type | string | NO | Filter: `mine` or `subscribed`. Omit for both. | +| type | string | 否 | 篩選:`mine`(我創建的)或 `subscribed`(我訂閱的),不傳則返回兩者 | ### Request Example - - - -longbridge sharelist -longbridge sharelist --format json - - - ```python @@ -233,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [list_sharelist_rsp](#list_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [list_sharelist_rsp](#list_sharelist_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -244,11 +236,11 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| mine | object[] | true | Sharelists created by the user | -| subscribed | object[] | true | Sharelists subscribed by the user | -| ∟ id | int64 | true | Sharelist ID | -| ∟ name | string | true | Sharelist name | -| ∟ type | string | true | Type: `Regular`, `Official` | -| ∟ day_change | string | false | Day change percentage | -| ∟ ytd_change | string | false | Year-to-date change | -| ∟ subscribers | int32 | false | Subscriber count | +| mine | object[] | true | 用戶創建的股單 | +| subscribed | object[] | true | 用戶訂閱的股單 | +| ∟ id | int64 | true | 股單 ID | +| ∟ name | string | true | 股單名稱 | +| ∟ type | string | true | 類型:`Regular`(普通)、`Official`(官方) | +| ∟ day_change | string | false | 當日漲跌幅 | +| ∟ ytd_change | string | false | 年初至今漲跌幅 | +| ∟ subscribers | int32 | false | 訂閱人數 | diff --git a/docs/zh-HK/docs/account/sharelist/popular_sharelist.md b/docs/zh-HK/docs/account/sharelist/popular_sharelist.md new file mode 100644 index 00000000..48f33c61 --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/popular_sharelist.md @@ -0,0 +1,212 @@ +--- +slug: popular-sharelist +title: 熱門股單 +sidebar_position: 6 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取社區熱門股單列表。 + + +longbridge sharelist popular --count 10 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/sharelist/popular
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| count | integer | 否 | 返回數量上限,默認 20 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.popular(10) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.popular(10) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.popular(10) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.popular(10).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.popular(10).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Popular(context.Background(), 10) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { "id": 123, "name": "AI Picks", "description": "Top AI infrastructure stocks" }, + { "id": 456, "name": "EV Leaders", "description": "Electric vehicle sector leaders" } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [SharelistList](#SharelistList) | +| 400 | 請求錯誤 | None | + +## Schemas + +### SharelistList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | SharelistItem[] | true | 股單列表 | + +### SharelistItem + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | 股單 ID | +| name | string | true | 股單名稱 | +| description | string | false | 描述 | diff --git a/docs/zh-HK/docs/account/sharelist/remove_securities.md b/docs/zh-HK/docs/account/sharelist/remove_securities.md new file mode 100644 index 00000000..8b3e2858 --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/remove_securities.md @@ -0,0 +1,185 @@ +--- +slug: remove-securities +title: 從股單移除標的 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +從股單中移除一個或多個標的。 + + +longbridge sharelist remove 123 TSLA.US + + + + +## Request + + + + + + +
HTTP MethodDELETE
HTTP URL/v1/sharelist/{id}/securities
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股單 ID | +| symbols | string[] | 是 | 待移除的標的代碼 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.remove_securities(123, ["TSLA.US"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.remove_securities(123, ["TSLA.US"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.removeSecurities(123, ['TSLA.US']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.removeSecurities(123, Arrays.asList("TSLA.US")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.remove_securities(123, vec!["TSLA.US".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.RemoveSecurities(context.Background(), 123, []string{"TSLA.US"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/sharelist/sharelist_detail.md b/docs/zh-HK/docs/account/sharelist/sharelist_detail.md new file mode 100644 index 00000000..bc44d4d8 --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/sharelist_detail.md @@ -0,0 +1,207 @@ +--- +slug: sharelist-detail +title: 股單詳情 +sidebar_position: 5 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取股單詳情,包括名稱、描述及成分股列表。 + + +longbridge sharelist detail 123 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/sharelist/{id}
+ +### Parameters + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股單 ID | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +resp = ctx.detail(123) +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + resp = await ctx.detail(123) + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + const resp = await ctx.detail(123) + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + var resp = ctx.detail(123).get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + let resp = ctx.detail(123).await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.Detail(context.Background(), 123) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "id": 123, + "name": "AI Picks", + "description": "Top AI infrastructure stocks", + "securities": ["AAPL.US", "NVDA.US"] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [SharelistDetail](#SharelistDetail) | +| 400 | 請求錯誤 | None | + +## Schemas + +### SharelistDetail + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | int64 | true | 股單 ID | +| name | string | true | 股單名稱 | +| description | string | false | 描述 | +| securities | string[] | true | 標的代碼列表 | diff --git a/docs/zh-HK/docs/account/sharelist/sort_securities.md b/docs/zh-HK/docs/account/sharelist/sort_securities.md new file mode 100644 index 00000000..a47fa7fd --- /dev/null +++ b/docs/zh-HK/docs/account/sharelist/sort_securities.md @@ -0,0 +1,185 @@ +--- +slug: sort-securities +title: 股單標的排序 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +對股單中的標的重新排序。傳入的標的代碼列表即為新順序。 + + +longbridge sharelist sort 123 TSLA.US AAPL.US 700.HK + + + + +## Request + + + + + + +
HTTP MethodPUT
HTTP URL/v1/sharelist/{id}/securities/sort
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| id | integer | 是 | 股單 ID | +| symbols | string[] | 是 | 按期望順序排列的標的代碼 | + +### Request Example + + + + +```python +from longbridge.openapi import SharelistContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = SharelistContext(config) + +ctx.sort_securities(123, ["TSLA.US", "AAPL.US", "700.HK"]) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncSharelistContext, 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 = AsyncSharelistContext.create(config) + + await ctx.sort_securities(123, ["TSLA.US", "AAPL.US", "700.HK"]) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, SharelistContext, 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 = SharelistContext.new(config) + await ctx.sortSecurities(123, ['TSLA.US', 'AAPL.US', '700.HK']) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.sharelist.*; +import java.util.Arrays; + +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); + SharelistContext ctx = SharelistContext.create(config)) { + ctx.sortSecurities(123, Arrays.asList("TSLA.US", "AAPL.US", "700.HK")).get(); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, 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 = SharelistContext::new(config); + ctx.sort_securities(123, vec!["TSLA.US".into(), "AAPL.US".into(), "700.HK".into()]).await?; + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/sharelist" +) + +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 := sharelist.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + if err := c.SortSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US", "700.HK"}); err != nil { + log.Fatal(err) + } +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success" +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | None | +| 400 | 請求錯誤 | None | diff --git a/docs/zh-HK/docs/account/sharelist/update_sharelist.md b/docs/zh-HK/docs/account/sharelist/update_sharelist.md index 93f9171d..34a0cc6e 100644 --- a/docs/zh-HK/docs/account/sharelist/update_sharelist.md +++ b/docs/zh-HK/docs/account/sharelist/update_sharelist.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -在自選股列表中新增、移除或重排證券,或對列表重新命名。 +在自選股列表中添加、移除或重排證券,或對列表重命名。 longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US @@ -34,22 +34,14 @@ longbridge sharelist remove 15921 AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| id | int64 | YES | Sharelist ID (path parameter) | -| name | string | NO | New name. Omit to keep existing. | -| mode | string | NO | Operation mode for securities: `add`, `remove`, or `replace` | -| securities | string[] | NO | Security symbols affected by the operation | +| id | int64 | 是 | 股單 ID(路徑參數) | +| name | string | 否 | 新名稱,不傳則保持原名 | +| mode | string | 否 | 證券操作模式:`add`(添加)、`remove`(移除)或 `replace`(替換) | +| securities | string[] | 否 | 受操作影響的證券代碼列表 | ### Request Example - - - -longbridge sharelist add 15921 TSLA.US NVDA.US AAPL.US -longbridge sharelist remove 15921 AAPL.US - - - ```python @@ -224,8 +216,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [update_sharelist_rsp](#update_sharelist_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [update_sharelist_rsp](#update_sharelist_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -233,4 +225,4 @@ func main() { -No response body fields. +無響應體字段。 diff --git a/docs/zh-HK/docs/fundamental/_category_.json b/docs/zh-HK/docs/fundamental/_category_.json index ffe0f326..73c73235 100644 --- a/docs/zh-HK/docs/fundamental/_category_.json +++ b/docs/zh-HK/docs/fundamental/_category_.json @@ -2,6 +2,7 @@ "position": 5, "label": "基本面", "collapsible": true, - "collapsed": false, - "link": null + "collapsed": true, + "link": null, + "icon": "book-open" } diff --git a/docs/zh-HK/docs/fundamental/calendar/_category_.json b/docs/zh-HK/docs/fundamental/calendar/_category_.json index 6347b088..ddae6b89 100644 --- a/docs/zh-HK/docs/fundamental/calendar/_category_.json +++ b/docs/zh-HK/docs/fundamental/calendar/_category_.json @@ -2,6 +2,6 @@ "position": 3, "label": "日曆", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md b/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md index c7313c3b..424213ee 100644 --- a/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md +++ b/docs/zh-HK/docs/fundamental/calendar/dividend_calendar.md @@ -1,6 +1,6 @@ --- slug: dividend-calendar -title: 分紅日曆 +title: 股息日曆 sidebar_position: 2 language_tabs: false toc_footers: [] @@ -10,21 +10,21 @@ highlight_theme: '' headingLevel: 2 --- -獲取即將到來和歷史分紅事件,包含除息日、派息日和分紅金額。 +獲取即將到來和歷史股息事件,包含除息日、派息日和股息金額。 longbridge finance-calendar dividend longbridge finance-calendar dividend --filter positions - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/dividends
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar dividend --filter positions | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 開始日期,格式 YYYY-MM-DD | +| end | string | YES | 結束日期,格式 YYYY-MM-DD | +| market | string | NO | 市場篩選:US、HK、SH、SZ,不填則返回所有市場 | ### Request Example - - - -longbridge finance-calendar dividend -longbridge finance-calendar dividend --filter positions - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [dividend_calendar_rsp](#dividend_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [dividend_calendar_rsp](#dividend_calendar_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Dividend event list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Company name | -| ∟ ex_date | string | true | Ex-dividend date | -| ∟ pay_date | string | false | Payment date | -| ∟ amount | string | true | Dividend amount per share | -| ∟ currency | string | true | Currency | +| list | object[] | 是 | 股息事件列表 | +| ∟ symbol | string | 是 | 證券代碼 | +| ∟ name | string | 是 | 公司名稱 | +| ∟ ex_date | string | 是 | 除息日 | +| ∟ pay_date | string | 否 | 派息日 | +| ∟ amount | string | 是 | 每股股息金額 | +| ∟ currency | string | 是 | 貨幣 | diff --git a/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md b/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md index 664df449..25d04306 100644 --- a/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md +++ b/docs/zh-HK/docs/fundamental/calendar/earnings_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar report longbridge finance-calendar report --market US
- + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/earnings
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar report --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter: `US`, `HK`, `SH`, `SZ`. Omit for all. | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 開始日期,格式 YYYY-MM-DD | +| end | string | YES | 結束日期,格式 YYYY-MM-DD | +| market | string | NO | 市場篩選:US、HK、SH、SZ,不填則返回所有市場 | ### Request Example - - - -longbridge finance-calendar report -longbridge finance-calendar report --market US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [earnings_calendar_rsp](#earnings_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [earnings_calendar_rsp](#earnings_calendar_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Earnings event list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Company name | -| ∟ report_date | string | true | Expected report date | -| ∟ eps_estimate | string | false | EPS estimate | -| ∟ eps_actual | string | false | Actual EPS (null if not yet reported) | -| ∟ revenue_estimate | string | false | Revenue estimate | +| list | object[] | 是 | 財報事件列表 | +| ∟ symbol | string | 是 | 證券代碼 | +| ∟ name | string | 是 | 公司名稱 | +| ∟ report_date | string | 是 | 預計發布日期 | +| ∟ eps_estimate | string | 否 | EPS 預期值 | +| ∟ eps_actual | string | 否 | EPS 實際值(未發布時為 null) | +| ∟ revenue_estimate | string | 否 | 營收預期值 | diff --git a/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md b/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md index a4d7871c..0a5bc3a1 100644 --- a/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md +++ b/docs/zh-HK/docs/fundamental/calendar/ipo_calendar.md @@ -10,21 +10,21 @@ highlight_theme: '' headingLevel: 2 --- -獲取即將上市和近期 IPO 資訊,包含預計發行價和上市日期。 +獲取即將上市和近期 IPO 信息,包含預計發行價和上市日期。 longbridge finance-calendar ipo longbridge finance-calendar ipo --market US - + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/ipos
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar ipo --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 開始日期,格式 YYYY-MM-DD | +| end | string | YES | 結束日期,格式 YYYY-MM-DD | +| market | string | NO | 市場篩選:US、HK、SH、SZ,不填則返回所有市場 | ### Request Example - - - -longbridge finance-calendar ipo -longbridge finance-calendar ipo --market US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [ipo_calendar_rsp](#ipo_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [ipo_calendar_rsp](#ipo_calendar_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | IPO event list | -| ∟ symbol | string | false | Security symbol (assigned after listing) | -| ∟ name | string | true | Company name | -| ∟ listing_date | string | true | Expected listing date | -| ∟ offer_price | string | false | IPO offer price | -| ∟ currency | string | false | Currency | -| ∟ market | string | true | Market code | +| list | object[] | 是 | IPO 事件列表 | +| ∟ symbol | string | 否 | 證券代碼(上市後分配) | +| ∟ name | string | 是 | 公司名稱 | +| ∟ listing_date | string | 是 | 預計上市日期 | +| ∟ offer_price | string | 否 | 新股發行價 | +| ∟ currency | string | 否 | 貨幣 | +| ∟ market | string | 是 | 市場代碼 | diff --git a/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md b/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md index f35be62c..93dbf3c6 100644 --- a/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md +++ b/docs/zh-HK/docs/fundamental/calendar/macro_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar macrodata longbridge finance-calendar macrodata --market US
- + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/macro
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar macrodata --market US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| country | string | NO | Country code: `US`, `CN`, `EU`, `JP`. Omit for global. | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 開始日期,格式 YYYY-MM-DD | +| end | string | YES | 結束日期,格式 YYYY-MM-DD | +| market | string | NO | 市場篩選:US、HK、SH、SZ,不填則返回所有市場 | ### Request Example - - - -longbridge finance-calendar macrodata -longbridge finance-calendar macrodata --market US - - - ```python @@ -235,8 +227,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [macro_calendar_rsp](#macro_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [macro_calendar_rsp](#macro_calendar_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -246,11 +238,11 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Macro event list | -| ∟ event | string | true | Event name | -| ∟ country | string | true | Country code | -| ∟ release_date | string | true | Release date | -| ∟ actual | string | false | Actual value (null if not yet released) | -| ∟ forecast | string | false | Consensus forecast | -| ∟ previous | string | false | Previous period value | -| ∟ importance | string | false | Importance level: `High`, `Medium`, `Low` | +| list | object[] | 是 | 宏觀事件列表 | +| ∟ event | string | 是 | 事件名稱 | +| ∟ country | string | 是 | 國家/地區代碼 | +| ∟ release_date | string | 是 | 發布日期 | +| ∟ actual | string | 否 | 實際值(未發布時為 null) | +| ∟ forecast | string | 否 | 市場預期值 | +| ∟ previous | string | 否 | 前期值 | +| ∟ importance | string | 否 | 重要程度:`High`(高)、`Medium`(中)、`Low`(低) | diff --git a/docs/zh-HK/docs/fundamental/calendar/split_calendar.md b/docs/zh-HK/docs/fundamental/calendar/split_calendar.md index 984fde78..d7ffbfbc 100644 --- a/docs/zh-HK/docs/fundamental/calendar/split_calendar.md +++ b/docs/zh-HK/docs/fundamental/calendar/split_calendar.md @@ -17,14 +17,14 @@ longbridge finance-calendar split longbridge finance-calendar split --market HK
- + ## Request - +
HTTP MethodGET
HTTP URL/v1/calendar/splits
HTTP URL/v1/quote/finance_calendar
@@ -34,21 +34,13 @@ longbridge finance-calendar split --market HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market filter | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| start | string | YES | 開始日期,格式 YYYY-MM-DD | +| end | string | YES | 結束日期,格式 YYYY-MM-DD | +| market | string | NO | 市場篩選:US、HK、SH、SZ,不填則返回所有市場 | ### Request Example - - - -longbridge finance-calendar split -longbridge finance-calendar split --market HK - - - ```python @@ -233,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [split_calendar_rsp](#split_calendar_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [split_calendar_rsp](#split_calendar_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -244,9 +236,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Split event list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Company name | -| ∟ date | string | true | Effective date | -| ∟ ratio | string | true | Split ratio, e.g. `10:1` | -| ∟ type | string | true | `Split` or `ReverseSplit` | +| list | object[] | 是 | 拆股事件列表 | +| ∟ symbol | string | 是 | 證券代碼 | +| ∟ name | string | 是 | 公司名稱 | +| ∟ date | string | 是 | 生效日期 | +| ∟ ratio | string | 是 | 拆股比例,例如 `10:1` | +| ∟ type | string | 是 | `Split`(拆股)或 `ReverseSplit`(合股) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/_category_.json b/docs/zh-HK/docs/fundamental/fundamental/_category_.json index 616f59cd..fd94b8dd 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/_category_.json +++ b/docs/zh-HK/docs/fundamental/fundamental/_category_.json @@ -2,6 +2,6 @@ "position": 1, "label": "基本面數據", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/fundamental/fundamental/buyback.md b/docs/zh-HK/docs/fundamental/fundamental/buyback.md new file mode 100644 index 00000000..201ca0fd --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/buyback.md @@ -0,0 +1,239 @@ +--- +slug: buyback +title: 回購數據 +sidebar_position: 20 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取股票回購數據,包括歷史回購金額及回購比例。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/buyback
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.buyback("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.buyback("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.buyback('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.getBuyback("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.buyback("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.buyback("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.Buyback(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "period": "FY2023", + "buyback_amount": 77550000000, + "buyback_shares": 430000000, + "buyback_ratio": 0.0278, + "currency": "USD" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [BuybackData](#BuybackData) | +| 400 | 請求錯誤 | None | + +## Schemas + +### BuybackData + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| list | object[] | 是 | 回購記錄列表 | +| list[].period | string | 否 | 財報期(如 FY2023、Q3 2024) | +| list[].buyback_amount | int64 | 否 | 回購總金額 | +| list[].buyback_shares | int64 | 否 | 回購股份數量 | +| list[].buyback_ratio | double | 否 | 回購佔總股本比例 | +| list[].currency | string | 否 | 貨幣代碼 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/company_profile.md b/docs/zh-HK/docs/fundamental/fundamental/company_profile.md index 115f7584..25c4ace9 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/company_profile.md +++ b/docs/zh-HK/docs/fundamental/fundamental/company_profile.md @@ -34,19 +34,11 @@ longbridge company AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | ### Request Example - - - -longbridge company TSLA.US -longbridge company AAPL.US - - - ```python @@ -229,8 +221,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [company_profile_rsp](#company_profile_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [company_profile_rsp](#company_profile_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -240,10 +232,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| name | string | true | Company name | -| symbol | string | true | Security symbol | -| founded | string | false | Founding year | -| ceo | string | false | Current CEO | -| employees | int32 | false | Number of employees | -| website | string | false | Company website | -| description | string | false | Business description | +| name | string | 是 | 公司名稱 | +| symbol | string | 是 | 證券代碼 | +| founded | string | 否 | 成立年份 | +| ceo | string | 否 | 現任 CEO | +| employees | int32 | 否 | 員工人數 | +| website | string | 否 | 公司官網 | +| description | string | 否 | 業務描述 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/consensus.md b/docs/zh-HK/docs/fundamental/fundamental/consensus.md new file mode 100644 index 00000000..7226edae --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/consensus.md @@ -0,0 +1,244 @@ +--- +slug: consensus +title: 機構共識 +sidebar_position: 14 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取機構共識預測,包括營收、EPS 和淨利潤預測。 + + +longbridge consensus TSLA.US +longbridge consensus AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/consensus
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `TSLA.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.consensus("TSLA.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.consensus("TSLA.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.consensus('TSLA.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.getConsensus("TSLA.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.consensus("TSLA.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.consensus("TSLA.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.Consensus(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "list": [ + { + "period": "FY2024", + "revenue": 105000000000, + "eps": 3.12, + "net_income": 10500000000, + "analyst_count": 35 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [FinancialConsensus](#FinancialConsensus) | +| 400 | 請求錯誤 | None | + +## Schemas + +### FinancialConsensus + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| list | object[] | 是 | 共識預測期列表 | +| list[].period | string | 否 | 財報期(如 FY2024) | +| list[].revenue | int64 | 否 | 共識營收預測 | +| list[].eps | double | 否 | 共識 EPS 預測 | +| list[].net_income | int64 | 否 | 共識淨利潤預測 | +| list[].analyst_count | int32 | 否 | 參與預測的分析師數量 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md b/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md index 519ff22d..24bedd09 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md +++ b/docs/zh-HK/docs/fundamental/fundamental/corporate_actions.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -獲取指定證券的公司行動歷史,包括拆股、合併、分拆和配股等。 +獲取指定證券的公司行動歷史,包括拆股、合並、分拆和配股等。 longbridge corp-action TSLA.US @@ -34,21 +34,13 @@ longbridge corp-action AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| start_date | string | 否 | 開始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 結束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge corp-action TSLA.US -longbridge corp-action AAPL.US - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [corporate_actions_rsp](#corporate_actions_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [corporate_actions_rsp](#corporate_actions_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -243,8 +235,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Corporate action list | -| ∟ type | string | true | Action type: `Split`, `Merger`, `Spinoff`, `Rights` | -| ∟ date | string | true | Effective date | -| ∟ ratio | string | false | Split/merge ratio | -| ∟ description | string | false | Action description | +| list | object[] | 是 | 公司行動列表 | +| ∟ type | string | 是 | 行動類型:`Split`(拆股)、`Merger`(合並)、`Spinoff`(分拆)、`Rights`(配股) | +| ∟ date | string | 是 | 生效日期 | +| ∟ ratio | string | 否 | 拆股/合並比例 | +| ∟ description | string | 否 | 行動描述 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/dividend_detail.md b/docs/zh-HK/docs/fundamental/fundamental/dividend_detail.md new file mode 100644 index 00000000..e867ae05 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/dividend_detail.md @@ -0,0 +1,243 @@ +--- +slug: dividend-detail +title: 分紅詳情 +sidebar_position: 12 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取詳細分紅資訊,包括宣告日、除息日和派發日。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/dividend_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.dividend_detail("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.dividend_detail("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.dividendDetail('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.getDividendDetail("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.dividend_detail("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.dividend_detail("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.DividendDetail(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "AAPL.US", + "dividend_type": "cash", + "amount": 0.24, + "currency": "USD", + "declared_date": "2024-02-01", + "ex_date": "2024-02-09", + "record_date": "2024-02-12", + "payment_date": "2024-02-15" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [DividendList](#DividendList) | +| 400 | 請求錯誤 | None | + +## Schemas + +### DividendList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | 是 | 分紅記錄列表 | +| list[].symbol | string | 是 | 證券代碼 | +| list[].dividend_type | string | 否 | 分紅類型(如 cash 現金、stock 股票) | +| list[].amount | double | 否 | 每股分紅金額 | +| list[].currency | string | 否 | 貨幣代碼 | +| list[].declared_date | string | 否 | 宣告日(YYYY-MM-DD) | +| list[].ex_date | string | 否 | 除息日(YYYY-MM-DD) | +| list[].record_date | string | 否 | 股權登記日(YYYY-MM-DD) | +| list[].payment_date | string | 否 | 派發日(YYYY-MM-DD) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/dividends.md b/docs/zh-HK/docs/fundamental/fundamental/dividends.md index e559bb33..c68a7773 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/dividends.md +++ b/docs/zh-HK/docs/fundamental/fundamental/dividends.md @@ -1,6 +1,6 @@ --- slug: dividends -title: 分紅歷史 +title: 股息歷史 sidebar_position: 3 language_tabs: false toc_footers: [] @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -獲取指定證券的分紅歷史及即將公布的分紅資訊。 +獲取指定證券的股息歷史及即將公布的股息信息。 longbridge dividend TSLA.US @@ -34,21 +34,13 @@ longbridge dividend AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| start_date | string | NO | Start date in `YYYY-MM-DD` format | -| end_date | string | NO | End date in `YYYY-MM-DD` format | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| start_date | string | 否 | 開始日期,格式 `YYYY-MM-DD` | +| end_date | string | 否 | 結束日期,格式 `YYYY-MM-DD` | ### Request Example - - - -longbridge dividend TSLA.US -longbridge dividend AAPL.US - - - ```python @@ -233,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [dividends_rsp](#dividends_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [dividends_rsp](#dividends_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -244,9 +236,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Dividend records | -| ∟ ex_date | string | true | Ex-dividend date | -| ∟ pay_date | string | false | Payment date | -| ∟ amount | string | true | Dividend amount per share | -| ∟ currency | string | true | Currency | -| ∟ type | string | true | Dividend type, e.g. `Cash`, `Stock` | +| list | object[] | 是 | 股息記錄列表 | +| ∟ ex_date | string | 是 | 除息日 | +| ∟ pay_date | string | 否 | 派息日 | +| ∟ amount | string | 是 | 每股股息金額 | +| ∟ currency | string | 是 | 貨幣 | +| ∟ type | string | 是 | 股息類型,例如 `Cash`(現金)、`Stock`(股票) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/executives.md b/docs/zh-HK/docs/fundamental/fundamental/executives.md index 8221f35d..c920fbd6 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/executives.md +++ b/docs/zh-HK/docs/fundamental/fundamental/executives.md @@ -34,19 +34,11 @@ longbridge executive AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | ### Request Example - - - -longbridge executive TSLA.US -longbridge executive AAPL.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [executives_rsp](#executives_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [executives_rsp](#executives_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -241,8 +233,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Executive list | -| ∟ name | string | true | Executive name | -| ∟ title | string | true | Job title | -| ∟ age | int32 | false | Age | -| ∟ since | string | false | Year appointed | +| list | object[] | 是 | 高管列表 | +| ∟ name | string | 是 | 高管姓名 | +| ∟ title | string | 是 | 職位 | +| ∟ age | int32 | 否 | 年齡 | +| ∟ since | string | 否 | 任職年份 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/financial_report.md b/docs/zh-HK/docs/fundamental/fundamental/financial_report.md index 67581315..d59d68dd 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/financial_report.md +++ b/docs/zh-HK/docs/fundamental/fundamental/financial_report.md @@ -34,21 +34,13 @@ longbridge financial-report AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| kind | string | NO | Statement type: `IS` (income), `BS` (balance sheet), `CF` (cash flow), `ALL` (default) | -| report | string | NO | Reporting period: `af` (annual), `saf` (semi-annual), `qf` (quarterly) | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| kind | string | 否 | 報表類型:`IS`(利潤表)、`BS`(資產負債表)、`CF`(現金流量表)、`ALL`(默認) | +| report | string | 否 | 報告期:`af`(年報)、`saf`(半年報)、`qf`(季報) | ### Request Example - - - -longbridge financial-report TSLA.US --kind IS -longbridge financial-report AAPL.US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [financial_report_rsp](#financial_report_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [financial_report_rsp](#financial_report_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -245,10 +237,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | List of financial statement records | -| ∟ type | string | true | Statement type: `IS`, `BS`, `CF` | -| ∟ period | string | true | Reporting period label | -| ∟ eps | string | false | Earnings per share | -| ∟ revenue | string | false | Total revenue | -| ∟ net_income | string | false | Net income | -| ∟ gross_margin | string | false | Gross margin ratio | +| list | object[] | 是 | 財務報表記錄列表 | +| ∟ type | string | 是 | 報表類型:`IS`、`BS`、`CF` | +| ∟ period | string | 是 | 報告期標簽 | +| ∟ eps | string | 否 | 每股收益 | +| ∟ revenue | string | 否 | 總營收 | +| ∟ net_income | string | 否 | 凈利潤 | +| ∟ gross_margin | string | 否 | 毛利率 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/forecast_eps.md b/docs/zh-HK/docs/fundamental/fundamental/forecast_eps.md new file mode 100644 index 00000000..dc191f81 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/forecast_eps.md @@ -0,0 +1,244 @@ +--- +slug: forecast-eps +title: EPS 預測 +sidebar_position: 13 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取 EPS 預測及分析師共識估值。 + + +longbridge forecast-eps TSLA.US +longbridge forecast-eps AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/forecast_eps
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `TSLA.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.forecast_eps("TSLA.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.forecast_eps("TSLA.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.forecastEps('TSLA.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.getForecastEps("TSLA.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.forecast_eps("TSLA.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.forecast_eps("TSLA.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.ForecastEps(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "list": [ + { + "period": "FY2024", + "consensus_eps": 3.12, + "high_eps": 4.50, + "low_eps": 2.10, + "analyst_count": 35 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [ForecastEps](#ForecastEps) | +| 400 | 請求錯誤 | None | + +## Schemas + +### ForecastEps + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| list | object[] | 是 | EPS 預測期列表 | +| list[].period | string | 否 | 財報期(如 FY2024、Q1 2024) | +| list[].consensus_eps | double | 否 | 共識 EPS 估值 | +| list[].high_eps | double | 否 | 最高 EPS 估值 | +| list[].low_eps | double | 否 | 最低 EPS 估值 | +| list[].analyst_count | int32 | 否 | 參與估值的分析師數量 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md b/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md index 6be61d22..abbdc8fd 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md +++ b/docs/zh-HK/docs/fundamental/fundamental/fund_holdings.md @@ -34,19 +34,11 @@ longbridge fund-holder AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | ### Request Example - - - -longbridge fund-holder TSLA.US -longbridge fund-holder AAPL.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [fund_holdings_rsp](#fund_holdings_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [fund_holdings_rsp](#fund_holdings_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -241,8 +233,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Fund holder list | -| ∟ fund_name | string | true | Fund name | -| ∟ shares | string | true | Number of shares held | -| ∟ percentage | string | true | Ownership percentage | -| ∟ date | string | false | Report date | +| list | object[] | 是 | 基金持有人列表 | +| ∟ fund_name | string | 是 | 基金名稱 | +| ∟ shares | string | 是 | 持股數量 | +| ∟ percentage | string | 是 | 持股比例 | +| ∟ date | string | 否 | 報告日期 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/industry_valuation.md b/docs/zh-HK/docs/fundamental/fundamental/industry_valuation.md new file mode 100644 index 00000000..0f9e4ef1 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/industry_valuation.md @@ -0,0 +1,248 @@ +--- +slug: industry-valuation +title: 行業估值對比 +sidebar_position: 16 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取同行業內的同類公司估值對比數據。 + + +longbridge industry-valuation TSLA.US +longbridge industry-valuation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/industry_valuation
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `TSLA.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.industry_valuation("TSLA.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_valuation("TSLA.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.industryValuation('TSLA.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.getIndustryValuation("TSLA.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_valuation("TSLA.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_valuation("TSLA.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.IndustryValuation(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "industry": "Automobiles", + "list": [ + { + "symbol": "TSLA.US", + "name": "Tesla Inc.", + "pe": 55.2, + "pb": 12.1, + "ps": 6.8, + "market_cap": 700000000000 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryValuationList](#IndustryValuationList) | +| 400 | 請求錯誤 | None | + +## Schemas + +### IndustryValuationList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| industry | string | 否 | 行業分類 | +| list | object[] | 是 | 同行公司列表 | +| list[].symbol | string | 否 | 同行證券代碼 | +| list[].name | string | 否 | 公司名稱 | +| list[].pe | double | 否 | 市盈率 | +| list[].pb | double | 否 | 市淨率 | +| list[].ps | double | 否 | 市銷率 | +| list[].market_cap | int64 | 否 | 市值 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/industry_valuation_dist.md b/docs/zh-HK/docs/fundamental/fundamental/industry_valuation_dist.md new file mode 100644 index 00000000..71a69bdb --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/industry_valuation_dist.md @@ -0,0 +1,238 @@ +--- +slug: industry-valuation-dist +title: 行業估值分佈 +sidebar_position: 17 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取該證券所在行業的估值分佈直方圖。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/industry_valuation_dist
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.industry_valuation_dist("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.industry_valuation_dist("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.industryValuationDist('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.getIndustryValuationDist("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.industry_valuation_dist("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.industry_valuation_dist("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.IndustryValuationDist(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "metric": "pe", + "symbol_value": 28.5, + "buckets": [ + { "range_start": 0, "range_end": 10, "count": 5 }, + { "range_start": 10, "range_end": 20, "count": 18 }, + { "range_start": 20, "range_end": 30, "count": 22 }, + { "range_start": 30, "range_end": 50, "count": 12 } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [IndustryValuationDist](#IndustryValuationDist) | +| 400 | 請求錯誤 | None | + +## Schemas + +### IndustryValuationDist + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| metric | string | 否 | 估值指標(如 pe、pb、ps) | +| symbol_value | double | 否 | 該證券自身的估值指標數值 | +| buckets | object[] | 否 | 分佈直方圖區間列表 | +| buckets[].range_start | double | 否 | 區間下界 | +| buckets[].range_end | double | 否 | 區間上界 | +| buckets[].count | int32 | 否 | 該區間內的公司數量 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/institution_rating.md b/docs/zh-HK/docs/fundamental/fundamental/institution_rating.md new file mode 100644 index 00000000..dc783986 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/institution_rating.md @@ -0,0 +1,243 @@ +--- +slug: institution-rating +title: 機構評級 +sidebar_position: 10 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取分析師機構評級快照(評級分佈及平均目標價)。 + + +longbridge institution-rating TSLA.US +longbridge institution-rating AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/institution_rating
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `TSLA.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("TSLA.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("TSLA.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.institutionRating('TSLA.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.getInstitutionRating("TSLA.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("TSLA.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("TSLA.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.InstitutionRating(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "TSLA.US", + "buy": 18, + "outperform": 5, + "hold": 12, + "underperform": 3, + "sell": 2, + "total": 40, + "avg_target_price": 285.50 + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InstitutionRating](#InstitutionRating) | +| 400 | 請求錯誤 | None | + +## Schemas + +### InstitutionRating + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| buy | int32 | 否 | 買入評級數量 | +| outperform | int32 | 否 | 跑贏大市評級數量 | +| hold | int32 | 否 | 持有評級數量 | +| underperform | int32 | 否 | 跑輸大市評級數量 | +| sell | int32 | 否 | 賣出評級數量 | +| total | int32 | 否 | 評級總數 | +| avg_target_price | double | 否 | 平均目標價 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/institution_rating_detail.md b/docs/zh-HK/docs/fundamental/fundamental/institution_rating_detail.md new file mode 100644 index 00000000..a36fc2f6 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/institution_rating_detail.md @@ -0,0 +1,244 @@ +--- +slug: institution-rating-detail +title: 機構評級詳情 +sidebar_position: 11 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取歷史分析師評級及目標價詳情。 + + +longbridge institution-rating detail TSLA.US +longbridge institution-rating detail AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/institution_rating_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `TSLA.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_detail("TSLA.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_detail("TSLA.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.institutionRatingDetail('TSLA.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.getInstitutionRatingDetail("TSLA.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_detail("TSLA.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_detail("TSLA.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.InstitutionRatingDetail(context.Background(), "TSLA.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "list": [ + { + "symbol": "TSLA.US", + "broker": "Goldman Sachs", + "analyst": "Mark Delaney", + "rating": "Buy", + "target_price": 320.00, + "date": "2024-03-15" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InstitutionRatingDetail](#InstitutionRatingDetail) | +| 400 | 請求錯誤 | None | + +## Schemas + +### InstitutionRatingDetail + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| list | object[] | 是 | 評級詳情列表 | +| list[].symbol | string | 是 | 證券代碼 | +| list[].broker | string | 否 | 券商名稱 | +| list[].analyst | string | 否 | 分析師姓名 | +| list[].rating | string | 否 | 評級(如 Buy、Hold、Sell) | +| list[].target_price | double | 否 | 目標價 | +| list[].date | string | 否 | 評級日期(YYYY-MM-DD) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/invest_relation.md b/docs/zh-HK/docs/fundamental/fundamental/invest_relation.md new file mode 100644 index 00000000..ab2b99a5 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/invest_relation.md @@ -0,0 +1,250 @@ +--- +slug: invest-relation +title: 投資關係 +sidebar_position: 18 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取投資關係數據,包括母公司、子公司及主要持股。 + + +longbridge invest-relation 700.HK +longbridge invest-relation AAPL.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/invest_relation
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `700.HK` | + +### 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.invest_relation("700.HK") +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.invest_relation("700.HK") + 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.investRelation('700.HK') + 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.getInvestRelation("700.HK").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.invest_relation("700.HK").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.invest_relation("700.HK", [](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.InvestRelation(context.Background(), "700.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "parent": { + "symbol": "", + "name": "" + }, + "subsidiaries": [ + { "symbol": "TCEHY.US", "name": "Tencent Holdings ADR", "holding_ratio": 1.0 } + ], + "holdings": [ + { "symbol": "SE.US", "name": "Sea Limited", "holding_ratio": 18.7 } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [InvestRelations](#InvestRelations) | +| 400 | 請求錯誤 | None | + +## Schemas + +### InvestRelations + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| parent | object | 否 | 母公司資訊 | +| parent.symbol | string | 否 | 母公司證券代碼 | +| parent.name | string | 否 | 母公司名稱 | +| subsidiaries | object[] | 否 | 子公司列表 | +| subsidiaries[].symbol | string | 否 | 子公司證券代碼 | +| subsidiaries[].name | string | 否 | 子公司名稱 | +| subsidiaries[].holding_ratio | double | 否 | 持股比例(%) | +| holdings | object[] | 否 | 主要持股列表 | +| holdings[].symbol | string | 否 | 持股證券代碼 | +| holdings[].name | string | 否 | 持股公司名稱 | +| holdings[].holding_ratio | double | 否 | 持股比例(%) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/operating.md b/docs/zh-HK/docs/fundamental/fundamental/operating.md new file mode 100644 index 00000000..0e066da1 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/operating.md @@ -0,0 +1,251 @@ +--- +slug: operating +title: 經營數據 +sidebar_position: 19 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +按財報期獲取經營數據及核心財務指標摘要。 + + +longbridge operating AAPL.US +longbridge operating TSLA.US + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/operating
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| period | string | 否 | 財報期篩選,如 `q1`、`q2`、`q3`、`q4`、`annual` | + +### 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.operating("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.operating("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.operating('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.getOperating("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.operating("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.operating("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.Operating(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "period": "Q1 2024", + "revenue": 119575000000, + "gross_profit": 54856000000, + "operating_income": 40372000000, + "net_income": 33916000000, + "gross_margin": 0.4588, + "operating_margin": 0.3377, + "net_margin": 0.2837 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [OperatingList](#OperatingList) | +| 400 | 請求錯誤 | None | + +## Schemas + +### OperatingList + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| list | object[] | 是 | 經營數據記錄列表 | +| list[].period | string | 否 | 財報期(如 Q1 2024、Annual 2023) | +| list[].revenue | int64 | 否 | 總營收 | +| list[].gross_profit | int64 | 否 | 毛利潤 | +| list[].operating_income | int64 | 否 | 營業利潤 | +| list[].net_income | int64 | 否 | 淨利潤 | +| list[].gross_margin | double | 否 | 毛利率 | +| list[].operating_margin | double | 否 | 營業利潤率 | +| list[].net_margin | double | 否 | 淨利潤率 | diff --git a/docs/zh-HK/docs/fundamental/fundamental/ratings.md b/docs/zh-HK/docs/fundamental/fundamental/ratings.md index 42510fff..3f01251b 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/ratings.md +++ b/docs/zh-HK/docs/fundamental/fundamental/ratings.md @@ -34,19 +34,11 @@ longbridge institution-rating AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | ### Request Example - - - -longbridge institution-rating TSLA.US -longbridge institution-rating AAPL.US - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [ratings_rsp](#ratings_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [ratings_rsp](#ratings_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -242,9 +234,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | List of analyst ratings | -| ∟ broker_name | string | true | Institution name | -| ∟ rating | string | true | Rating: `Buy`, `Hold`, `Sell` | -| ∟ target_price | string | false | Target price | -| ∟ currency | string | false | Currency | -| ∟ date | string | true | Rating date in `YYYY-MM-DD` format | +| list | object[] | 是 | 分析師評級列表 | +| ∟ broker_name | string | 是 | 機構名稱 | +| ∟ rating | string | 是 | 評級:`Buy`(買入)、`Hold`(持有)、`Sell`(賣出) | +| ∟ target_price | string | 否 | 目標價 | +| ∟ currency | string | 否 | 貨幣 | +| ∟ date | string | 是 | 評級日期,格式 `YYYY-MM-DD` | diff --git a/docs/zh-HK/docs/fundamental/fundamental/shareholders.md b/docs/zh-HK/docs/fundamental/fundamental/shareholders.md index de16a358..db54128d 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/shareholders.md +++ b/docs/zh-HK/docs/fundamental/fundamental/shareholders.md @@ -34,19 +34,11 @@ longbridge shareholder AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | ### Request Example - - - -longbridge shareholder TSLA.US -longbridge shareholder AAPL.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [shareholders_rsp](#shareholders_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [shareholders_rsp](#shareholders_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -241,8 +233,8 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Shareholder list | -| ∟ name | string | true | Shareholder name | -| ∟ shares | string | true | Number of shares held | -| ∟ percentage | string | true | Ownership percentage | -| ∟ type | string | false | `Institution` or `Individual` | +| list | object[] | 是 | 股東列表 | +| ∟ name | string | 是 | 股東名稱 | +| ∟ shares | string | 是 | 持股數量 | +| ∟ percentage | string | 是 | 持股比例 | +| ∟ type | string | 否 | `Institution`(機構)或 `Individual`(個人) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/valuation_history.md b/docs/zh-HK/docs/fundamental/fundamental/valuation_history.md new file mode 100644 index 00000000..cc4de0b9 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/fundamental/valuation_history.md @@ -0,0 +1,239 @@ +--- +slug: valuation-history +title: 估值歷史 +sidebar_position: 15 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取歷史估值指標時間序列(市盈率、市淨率、市銷率、股息率)。 + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/fundamental/valuation_history
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| 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.valuation_history("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.valuation_history("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.valuationHistory('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.getValuationHistory("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.valuation_history("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.valuation_history("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.ValuationHistory(context.Background(), "AAPL.US") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "AAPL.US", + "list": [ + { + "date": "2024-03-31", + "pe": 28.5, + "pb": 46.2, + "ps": 7.8, + "dividend_yield": 0.55 + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [ValuationHistoryResponse](#ValuationHistoryResponse) | +| 400 | 請求錯誤 | None | + +## Schemas + +### ValuationHistoryResponse + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 證券代碼 | +| list | object[] | 是 | 歷史估值數據點列表 | +| list[].date | string | 否 | 日期(YYYY-MM-DD) | +| list[].pe | double | 否 | 市盈率(PE) | +| list[].pb | double | 否 | 市淨率(PB) | +| list[].ps | double | 否 | 市銷率(PS) | +| list[].dividend_yield | double | 否 | 股息率(%) | diff --git a/docs/zh-HK/docs/fundamental/fundamental/valuations.md b/docs/zh-HK/docs/fundamental/fundamental/valuations.md index 0453fa76..1968469c 100644 --- a/docs/zh-HK/docs/fundamental/fundamental/valuations.md +++ b/docs/zh-HK/docs/fundamental/fundamental/valuations.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -獲取當前估值指標(市盈率、市淨率、市銷率、股息率)及 5 年歷史區間數據。 +獲取當前估值指標(市盈率、市凈率、市銷率、股息率)及 5 年歷史區間數據。 longbridge valuation TSLA.US --indicator pe @@ -34,20 +34,12 @@ longbridge valuation AAPL.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `AAPL.US` | -| indicator | string | NO | Indicator filter: `pe`, `pb`, `ps`, `dvd_yld` | +| symbol | string | 是 | 證券代碼,例如 `AAPL.US` | +| indicator | string | 否 | 指標篩選:`pe`、`pb`、`ps`、`dvd_yld` | ### Request Example - - - -longbridge valuation TSLA.US --indicator pe -longbridge valuation AAPL.US - - - ```python @@ -227,8 +219,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [valuations_rsp](#valuations_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [valuations_rsp](#valuations_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -238,9 +230,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| metrics | object | true | Valuation metrics map | -| ∟ pe | object | false | P/E ratio data | -| ∟∟ current | string | true | Current value | -| ∟∟ high | string | true | 5-year high | -| ∟∟ low | string | true | 5-year low | -| ∟∟ median | string | true | 5-year median | +| metrics | object | 是 | 估值指標映射 | +| ∟ pe | object | 否 | 市盈率數據 | +| ∟∟ current | string | 是 | 當前值 | +| ∟∟ high | string | 是 | 5 年最高值 | +| ∟∟ low | string | 是 | 5 年最低值 | +| ∟∟ median | string | 是 | 5 年中位值 | diff --git a/docs/zh-HK/docs/fundamental/market/_category_.json b/docs/zh-HK/docs/fundamental/market/_category_.json index 3a419436..20657f67 100644 --- a/docs/zh-HK/docs/fundamental/market/_category_.json +++ b/docs/zh-HK/docs/fundamental/market/_category_.json @@ -2,6 +2,6 @@ "position": 2, "label": "市場", "collapsible": true, - "collapsed": false, + "collapsed": true, "link": null -} +} \ No newline at end of file diff --git a/docs/zh-HK/docs/fundamental/market/ah_premium.md b/docs/zh-HK/docs/fundamental/market/ah_premium.md index d07ef63d..5a5f1291 100644 --- a/docs/zh-HK/docs/fundamental/market/ah_premium.md +++ b/docs/zh-HK/docs/fundamental/market/ah_premium.md @@ -34,19 +34,11 @@ longbridge ah-premium 0939.HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | H-share symbol of a dual-listed stock, e.g. `939.HK` | +| symbol | string | 是 | A+H 兩地上市股票的 H 股代碼,例如 `939.HK` | ### Request Example - - - -longbridge ah-premium 939.HK -longbridge ah-premium 0939.HK - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [ah_premium_rsp](#ah_premium_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [ah_premium_rsp](#ah_premium_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -242,9 +234,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | A/H premium records | -| ∟ date | string | true | Date in `YYYY-MM-DD` format | -| ∟ a_price | string | true | A-share price in CNY | -| ∟ h_price | string | true | H-share price in HKD | -| ∟ premium | string | true | A/H premium ratio | -| ∟ fx_rate | string | true | CNH/HKD exchange rate | +| list | object[] | 是 | A/H 溢價記錄列表 | +| ∟ date | string | 是 | 日期,格式 `YYYY-MM-DD` | +| ∟ a_price | string | 是 | A 股價格(人民幣) | +| ∟ h_price | string | 是 | H 股價格(港幣) | +| ∟ premium | string | 是 | A/H 溢價比率 | +| ∟ fx_rate | string | 是 | CNH/HKD 匯率 | diff --git a/docs/zh-HK/docs/fundamental/market/ah_premium_intraday.md b/docs/zh-HK/docs/fundamental/market/ah_premium_intraday.md new file mode 100644 index 00000000..9acb8046 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/ah_premium_intraday.md @@ -0,0 +1,212 @@ +--- +slug: ah-premium-intraday +title: A/H 溢價盤中數據 +sidebar_position: 9 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取兩地上市證券的盤中 A/H 溢價時間序列數據。 + + +longbridge ah-premium intraday 939.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/ah_premium_intraday
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 兩地上市股票的港股代碼,例如 `939.HK` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.ah_premium_intraday("939.HK") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.ah_premium_intraday("939.HK") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.ahPremiumIntraday('939.HK') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getAhPremiumIntraday("939.HK").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.ah_premium_intraday("939.HK").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.AhPremiumIntraday(context.Background(), "939.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "939.HK", + "timeseries": [ + { + "timestamp": "1774310400", + "premium": "2.35" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [ah_premium_intraday_rsp](#ah_premium_intraday_rsp) | +| 400 | 請求錯誤 | None | + +## Schemas + +### ah_premium_intraday_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代碼 | +| timeseries | object[] | 是 | 盤中 A/H 溢價時間序列 | +| ∟ timestamp | string | 是 | Unix 時間戳 | +| ∟ premium | string | 是 | A/H 溢價百分比 | diff --git a/docs/zh-HK/docs/fundamental/market/broker_holding_daily.md b/docs/zh-HK/docs/fundamental/market/broker_holding_daily.md new file mode 100644 index 00000000..bcac8b1b --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/broker_holding_daily.md @@ -0,0 +1,217 @@ +--- +slug: broker-holding-daily +title: 經紀商每日持倉歷史 +sidebar_position: 8 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取某一經紀商在港股上市證券中的每日持倉歷史記錄。 + + +longbridge broker-holding daily 700.HK --broker B01224 + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_holding_daily
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代碼,例如 `700.HK` | +| broker_id | string | 是 | 經紀商參與者 ID,例如 `B01224` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_holding_daily("700.HK", "B01224") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_holding_daily("700.HK", "B01224") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.brokerHoldingDaily('700.HK', 'B01224') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerHoldingDaily("700.HK", "B01224").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_holding_daily("700.HK", "B01224").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerHoldingDaily(context.Background(), "700.HK", "B01224") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "broker_id": "B01224", + "broker_name": "HSBC Securities", + "history": [ + { + "date": "2024-01-15", + "holding_qty": "500000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [broker_holding_daily_rsp](#broker_holding_daily_rsp) | +| 400 | 請求錯誤 | None | + +## Schemas + +### broker_holding_daily_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代碼 | +| broker_id | string | 是 | 經紀商參與者 ID | +| broker_name | string | 是 | 經紀商名稱 | +| history | object[] | 是 | 每日持倉歷史 | +| ∟ date | string | 是 | 日期(YYYY-MM-DD) | +| ∟ holding_qty | string | 是 | 當日持倉數量 | diff --git a/docs/zh-HK/docs/fundamental/market/broker_holding_detail.md b/docs/zh-HK/docs/fundamental/market/broker_holding_detail.md new file mode 100644 index 00000000..5802cc29 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/market/broker_holding_detail.md @@ -0,0 +1,216 @@ +--- +slug: broker-holding-detail +title: 經紀商持倉詳情 +sidebar_position: 7 +language_tabs: false +toc_footers: [] +includes: [] +search: true +highlight_theme: '' +headingLevel: 2 +--- + +獲取港股上市證券的完整經紀商持倉詳情列表(所有經紀商及其持倉數量)。 + + +longbridge broker-holding detail 700.HK + + + + +## Request + + + + + + +
HTTP MethodGET
HTTP URL/v1/market/broker_holding_detail
+ +### Parameters + +> Content-Type: application/json; charset=utf-8 + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代碼,例如 `700.HK` | + +### Request Example + + + + +```python +from longbridge.openapi import MarketContext, Config, OAuthBuilder + +oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url)) +config = Config.from_oauth(oauth) +ctx = MarketContext(config) + +resp = ctx.broker_holding_detail("700.HK") +print(resp) +``` + + + + +```python +import asyncio +from longbridge.openapi import AsyncMarketContext, Config, OAuthBuilder + +async def main() -> None: + oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url)) + config = Config.from_oauth(oauth) + ctx = AsyncMarketContext.create(config) + + resp = await ctx.broker_holding_detail("700.HK") + print(resp) + +if __name__ == "__main__": + asyncio.run(main()) +``` + + + + +```javascript +const { Config, MarketContext, OAuth } = require('longbridge') + +async function main() { + const oauth = await OAuth.build('your-client-id', (_, url) => { + console.log('Open this URL to authorize: ' + url) + }) + const config = Config.fromOAuth(oauth) + const ctx = MarketContext.new(config) + const resp = await ctx.brokerHoldingDetail('700.HK') + console.log(resp) +} +main().catch(console.error) +``` + + + + +```java +import com.longbridge.*; +import com.longbridge.market.*; + +class Main { + public static void main(String[] args) throws Exception { + try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get(); + Config config = Config.fromOAuth(oauth); + MarketContext ctx = MarketContext.create(config)) { + var resp = ctx.getBrokerHoldingDetail("700.HK").get(); + System.out.println(resp); + } + } +} +``` + + + + +```rust +use std::sync::Arc; +use longbridge::{oauth::OAuthBuilder, market::MarketContext, 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 = MarketContext::new(config); + let resp = ctx.broker_holding_detail("700.HK").await?; + println!("{:?}", resp); + Ok(()) +} +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/longbridge/openapi-go/config" + "github.com/longbridge/openapi-go/oauth" + "github.com/longbridge/openapi-go/market" +) + +func main() { + o := oauth.New("your-client-id"). + OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) }) + if err := o.Build(context.Background()); err != nil { + log.Fatal(err) + } + conf, err := config.New(config.WithOAuthClient(o)) + if err != nil { + log.Fatal(err) + } + c, err := market.NewFromCfg(conf) + if err != nil { + log.Fatal(err) + } + defer c.Close() + resp, err := c.BrokerHoldingDetail(context.Background(), "700.HK") + if err != nil { + log.Fatal(err) + } + fmt.Printf("%+v\n", resp) +} +``` + + + + +## Response + +### Response Headers + +- Content-Type: application/json + +### Response Example + +```json +{ + "code": 0, + "message": "success", + "data": { + "symbol": "700.HK", + "updated_at": "1774310400", + "brokers": [ + { + "broker_id": "B01224", + "broker_name": "HSBC Securities", + "holding_qty": "500000" + } + ] + } +} +``` + +### Response Status + +| Status | Description | Schema | +| ------ | ----------- | ------ | +| 200 | 成功 | [broker_holding_detail_rsp](#broker_holding_detail_rsp) | +| 400 | 請求錯誤 | None | + +## Schemas + +### broker_holding_detail_rsp + + + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | +| symbol | string | 是 | 港股代碼 | +| updated_at | string | 是 | 最後更新的 Unix 時間戳 | +| brokers | object[] | 是 | 經紀商持倉列表 | +| ∟ broker_id | string | 是 | 經紀商參與者 ID | +| ∟ broker_name | string | 是 | 經紀商名稱 | +| ∟ holding_qty | string | 是 | 持倉數量 | diff --git a/docs/zh-HK/docs/fundamental/market/broker_positions.md b/docs/zh-HK/docs/fundamental/market/broker_positions.md index 6c21bb6b..e325d70a 100644 --- a/docs/zh-HK/docs/fundamental/market/broker_positions.md +++ b/docs/zh-HK/docs/fundamental/market/broker_positions.md @@ -34,19 +34,11 @@ longbridge broker-holding 9988.HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | HK security symbol, e.g. `700.HK` | +| symbol | string | 是 | 港股證券代碼,例如 `700.HK` | ### Request Example - - - -longbridge broker-holding 700.HK -longbridge broker-holding 9988.HK - - - ```python @@ -232,8 +224,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [broker_positions_rsp](#broker_positions_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [broker_positions_rsp](#broker_positions_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -243,10 +235,10 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| updated_at | string | true | Last updated Unix timestamp | -| participants | object[] | true | Broker position list | -| ∟ broker_id | int32 | true | Broker ID | -| ∟ broker_name | string | true | Broker name | -| ∟ buy_qty | string | true | Buy quantity | -| ∟ sell_qty | string | true | Sell quantity | -| ∟ net_qty | string | true | Net quantity (buy - sell) | +| updated_at | string | 是 | 最後更新的 Unix 時間戳 | +| participants | object[] | 是 | 經紀商持倉列表 | +| ∟ broker_id | int32 | 是 | 經紀商 ID | +| ∟ broker_name | string | 是 | 經紀商名稱 | +| ∟ buy_qty | string | 是 | 買入數量 | +| ∟ sell_qty | string | 是 | 賣出數量 | +| ∟ net_qty | string | 是 | 凈持倉數量(買入 - 賣出) | diff --git a/docs/zh-HK/docs/fundamental/market/index_components.md b/docs/zh-HK/docs/fundamental/market/index_components.md index 00bae998..b5220ba4 100644 --- a/docs/zh-HK/docs/fundamental/market/index_components.md +++ b/docs/zh-HK/docs/fundamental/market/index_components.md @@ -34,19 +34,11 @@ longbridge constituent SPY.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Index or ETF symbol, e.g. `HSI.HK`, `SPY.US` | +| symbol | string | 是 | 指數或 ETF 代碼,例如 `HSI.HK`、`SPY.US` | ### Request Example - - - -longbridge constituent HSI.HK -longbridge constituent SPY.US - - - ```python @@ -234,8 +226,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [index_components_rsp](#index_components_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [index_components_rsp](#index_components_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -245,12 +237,12 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| total | int32 | true | Total number of components | -| rise | int32 | true | Number of rising components | -| fall | int32 | true | Number of falling components | -| flat | int32 | true | Number of flat components | -| components | object[] | true | Component list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Security name | -| ∟ price | string | false | Current price | -| ∟ change_pct | string | false | Percentage change | +| total | int32 | 是 | 成分股總數 | +| rise | int32 | 是 | 上漲成分股數量 | +| fall | int32 | 是 | 下跌成分股數量 | +| flat | int32 | 是 | 平盤成分股數量 | +| components | object[] | 是 | 成分股列表 | +| ∟ symbol | string | 是 | 證券代碼 | +| ∟ name | string | 是 | 證券名稱 | +| ∟ price | string | 否 | 當前價格 | +| ∟ change_pct | string | 否 | 漲跌幅 | diff --git a/docs/zh-HK/docs/fundamental/market/market_status.md b/docs/zh-HK/docs/fundamental/market/market_status.md index 5158ee1e..8d7eacba 100644 --- a/docs/zh-HK/docs/fundamental/market/market_status.md +++ b/docs/zh-HK/docs/fundamental/market/market_status.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -獲取各交易所當前的開市/收市狀態。 +獲取各交易所當前的開市/休市狀態。 longbridge market-status @@ -33,18 +33,11 @@ longbridge market-status | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | NO | Market code: `US`, `HK`, `SH`, `SZ`, `SG`. Omit for all markets. | +| market | string | 否 | 市場代碼:`US`、`HK`、`SH`、`SZ`、`SG`。不填則返回全部市場。 | ### Request Example - - - -longbridge market-status - - - ```python @@ -232,8 +225,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [market_status_rsp](#market_status_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [market_status_rsp](#market_status_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -243,7 +236,7 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Market status list | -| ∟ market | string | true | Market code | -| ∟ status | string | true | Status: `normal_trading`, `closed`, `pre_trading`, `after_trading` | -| ∟ trade_session | string | false | Current trading session | +| list | object[] | 是 | 市場狀態列表 | +| ∟ market | string | 是 | 市場代碼 | +| ∟ status | string | 是 | 狀態:`normal_trading`(正常交易)、`closed`(已收市)、`pre_trading`(盤前)、`after_trading`(盤後) | +| ∟ trade_session | string | 否 | 當前交易時段 | diff --git a/docs/zh-HK/docs/fundamental/market/trading_stats.md b/docs/zh-HK/docs/fundamental/market/trading_stats.md index 4b3b0c7a..1e409fed 100644 --- a/docs/zh-HK/docs/fundamental/market/trading_stats.md +++ b/docs/zh-HK/docs/fundamental/market/trading_stats.md @@ -10,7 +10,7 @@ highlight_theme: '' headingLevel: 2 --- -獲取指定證券的成交統計數據,展示成交量的價格分佈。 +獲取指定證券的成交統計數據,展示成交量的價格分布。 longbridge trade-stats 700.HK @@ -34,19 +34,11 @@ longbridge trade-stats TSLA.US | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| symbol | string | YES | Security symbol, e.g. `700.HK` | +| symbol | string | 是 | 證券代碼,例如 `700.HK` | ### Request Example - - - -longbridge trade-stats 700.HK -longbridge trade-stats TSLA.US - - - ```python @@ -230,8 +222,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [trading_stats_rsp](#trading_stats_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [trading_stats_rsp](#trading_stats_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -241,12 +233,12 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| prev_close | string | true | Previous close price | -| avg_price | string | true | Average trading price | -| trades | int32 | true | Number of trades | -| volume | string | true | Total volume | -| turnover | string | true | Total turnover | -| distribution | object[] | true | Price-volume distribution | -| ∟ price | string | true | Price level | -| ∟ volume | string | true | Volume at this price | -| ∟ pct | string | true | Percentage of total volume | +| prev_close | string | 是 | 前收盤價 | +| avg_price | string | 是 | 平均成交價 | +| trades | int32 | 是 | 成交筆數 | +| volume | string | 是 | 總成交量 | +| turnover | string | 是 | 總成交額 | +| distribution | object[] | 是 | 價格-成交量分布 | +| ∟ price | string | 是 | 價格檔位 | +| ∟ volume | string | 是 | 該價格的成交量 | +| ∟ pct | string | 是 | 占總成交量的百分比 | diff --git a/docs/zh-HK/docs/fundamental/market/unusual_items.md b/docs/zh-HK/docs/fundamental/market/unusual_items.md index 1907b18a..2c4362a1 100644 --- a/docs/zh-HK/docs/fundamental/market/unusual_items.md +++ b/docs/zh-HK/docs/fundamental/market/unusual_items.md @@ -34,19 +34,11 @@ longbridge anomaly --market HK | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| market | string | YES | Market code: `US`, `HK`, `SH`, `SZ`, `SG` | +| market | string | 是 | 市場代碼:`US`、`HK`、`SH`、`SZ`、`SG` | ### Request Example - - - -longbridge anomaly --market US -longbridge anomaly --market HK - - - ```python @@ -231,8 +223,8 @@ func main() { | Status | Description | Schema | | ------ | ----------- | ------ | -| 200 | Success | [unusual_items_rsp](#unusual_items_rsp) | -| 400 | Bad request | None | +| 200 | 成功 | [unusual_items_rsp](#unusual_items_rsp) | +| 400 | 請求錯誤 | None | ## Schemas @@ -242,9 +234,9 @@ func main() { | Name | Type | Required | Description | | ---- | ---- | -------- | ----------- | -| list | object[] | true | Unusual item list | -| ∟ symbol | string | true | Security symbol | -| ∟ name | string | true | Security name | -| ∟ alert | string | true | Alert description | -| ∟ emotion | string | false | Market sentiment: `Bullish`, `Bearish` | -| ∟ time | string | true | Alert time as Unix timestamp | +| list | object[] | 是 | 異動列表 | +| ∟ symbol | string | 是 | 證券代碼 | +| ∟ name | string | 是 | 證券名稱 | +| ∟ alert | string | 是 | 異動描述 | +| ∟ emotion | string | 否 | 市場情緒:`Bullish`(看多)、`Bearish`(看空) | +| ∟ time | string | 是 | 異動時間(Unix 時間戳) | diff --git a/docs/zh-HK/docs/fundamental/overview.md b/docs/zh-HK/docs/fundamental/overview.md new file mode 100644 index 00000000..6ece9427 --- /dev/null +++ b/docs/zh-HK/docs/fundamental/overview.md @@ -0,0 +1,51 @@ +--- +sidebar_position: 0 +id: fundamental_overview +title: 概覽 +slug: overview +--- + +# 基本面 API 概覽 + +研究与市场数据接口,涵盖公司基本面、市场结构和財經日历。所有接口均为只读,通过 SDK 调用。 + +## FundamentalContext + +公司層面的財務數據与企業信息。 + +| 方法 | 说明 | +|---|---| +| [company_profile](./fundamental/company-profile) | 公司概況、行业及基本信息 | +| [financial_report](./fundamental/financial-report) | 利润表、资产负债表和现金流量表 | +| [valuations](./fundamental/valuations) | PE、PB、PS、EV/EBITDA 等估值指标 | +| [ratings](./fundamental/ratings) | 機構评级与目标价 | +| [dividends](./fundamental/dividends) | 歷史分红记录 | +| [fund_holdings](./fundamental/fund-holdings) | 機構及基金持仓 | +| [shareholders](./fundamental/shareholders) | 主要股东 | +| [executives](./fundamental/executives) | 管理層与董事会成员 | +| [corporate_actions](./fundamental/corporate-actions) | 拆股、送股、配股等公司行動 | + +## MarketContext + +市场層面数据,包括指数成分、經紀商持仓和异动扫描。 + +| 方法 | 说明 | +|---|---| +| [market_status](./market/market-status) | 各市场当前交易状态 | +| [trading_stats](./market/trading-stats) | 标的盘中交易统计 | +| [index_components](./market/index-components) | 指数成分股列表 | +| [ah_premium](./market/ah-premium) | 两地上市股票的 A/H 股溢价率 | +| [broker_positions](./market/broker-positions) | 港股經紀商持仓(中央结算) | +| [unusual_items](./market/unusual-items) | 异常價格或成交量异动 | + +## CalendarContext + +財經事件日历,用于跟踪财报、分红和宏觀数据發布。 + +| 方法 | 说明 | +|---|---| +| [earnings_calendar](./calendar/earnings-calendar) | 即将發布和近期的财报日期 | +| [dividend_calendar](./calendar/dividend-calendar) | 除权除息日和派息日 | +| [ipo_calendar](./calendar/ipo-calendar) | 新股認購和上市日期 | +| [split_calendar](./calendar/split-calendar) | 股票拆分生效日期 | +| [macro_calendar](./calendar/macro-calendar) | 宏觀经济数据發布计划 | From 75a0bc57ce7fcd5742663440ff2a131b0c5f7328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sat, 9 May 2026 16:39:36 +0800 Subject: [PATCH 04/18] fix(build): resolve OOM and mark.js ESM issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add srcExclude for superpowers/** (fixes Vue parse error in local files) - Add buildConcurrency: 10 and manualChunks to reduce build memory - Add mark.js to ssr.noExternal to fix Tailwind v4 ESM loader conflict - Add GC plugin (fire global.gc() between client/server bundles) - Add --expose-gc to CI workflow NODE_OPTIONS for GC plugin to work - Fix skill install URL/package name: developers.longbridge.com → open.longbridge.com, longbridge/developers → longbridge/skills Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .github/workflows/build.yml | 2 ++ .github/workflows/canary.yml | 1 + docs/.vitepress/config.mts | 26 ++++++++++++++++++++++++-- package.json | 6 +++--- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9eb74891..8709d5a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,3 +28,5 @@ jobs: - name: Build for canary run: | bun run build:canary + env: + NODE_OPTIONS: --max-old-space-size=6144 --expose-gc diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 23b69cf5..6f549d5b 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -37,6 +37,7 @@ jobs: run: bun run build:canary env: VITE_PORTAL_GATEWAY_BASE_URL: 'https://m.longbridge.xyz' + NODE_OPTIONS: --max-old-space-size=6144 --expose-gc - name: Upload to Aliyun OSS run: | diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 8919cbc9..6e8056fc 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -38,8 +38,9 @@ export default defineConfig( metaChunk: true, ignoreDeadLinks: true, base: '/', + buildConcurrency: 10, - srcExclude: ['README.md', ...regionSrcExclude], + srcExclude: ['README.md', 'superpowers/**', ...regionSrcExclude], rewrites: rewriteMarkdownPath, markdown: markdownConfig, transformHtml(code) { @@ -180,7 +181,7 @@ export default defineConfig( vite: { ssr: { - noExternal: ['vue-i18n'], + noExternal: ['vue-i18n', 'mark.js'], }, server: { port: 8000, @@ -203,6 +204,18 @@ export default defineConfig( }, build: { chunkSizeWarningLimit: 1000, + rollupOptions: { + output: { + manualChunks(id) { + if (id.includes('node_modules')) { + if (id.includes('shiki') || id.includes('shikiji')) return 'shiki' + if (id.includes('@vue') || id.includes('vue-demi')) return 'vue-vendor' + if (id.includes('unocss') || id.includes('@unocss')) return 'unocss' + return 'vendor' + } + }, + }, + }, }, resolve: { alias: [ @@ -217,6 +230,15 @@ export default defineConfig( ], }, plugins: [ + { + name: 'gc-between-bundles', + buildEnd() { + if (typeof global.gc === 'function') { + global.gc() + console.log('✓ GC triggered after bundle') + } + }, + }, { name: 'yaml-transform', transform(src: string, id: string) { diff --git a/package.json b/package.json index 6a162ab6..45fc94d4 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,9 @@ "dev": "cross-env VITE_API_BASE_URL=https://openapi.longbridge.xyz npx vitepress dev docs", "dev:prod": "cross-env VITE_API_BASE_URL=https://openapi.longbridge.com npx vitepress dev docs", "dev:cn": "cross-env VITE_REGION=cn VITE_API_BASE_URL=https://openapi.longbridge.cn VITE_SITE_HOSTNAME=https://open.longbridge.cn npx vitepress dev docs", - "build:canary": "cross-env NODE_OPTIONS=--max-old-space-size=6144 VITE_API_BASE_URL=https://openapi.longbridge.xyz npx vitepress build docs && bun run build:llms && bun run build:copy-routes", - "build:release": "cross-env NODE_OPTIONS=--max-old-space-size=6144 VITE_API_BASE_URL=https://openapi.longbridge.com npx vitepress build docs && bun run build:llms && bun run build:copy-routes", - "build:cn": "cross-env NODE_OPTIONS=--max-old-space-size=6144 VITE_REGION=cn VITE_API_BASE_URL=https://openapi.longbridge.cn VITE_PORTAL_GATEWAY_BASE_URL=https://m.lbkrs.com VITE_SITE_HOSTNAME=https://open.longbridge.cn npx vitepress build docs && bun run build:llms && bun run build:copy-routes", + "build:canary": "cross-env \"NODE_OPTIONS=--max-old-space-size=6144 --expose-gc\" VITE_API_BASE_URL=https://openapi.longbridge.xyz npx vitepress build docs && bun run build:llms && bun run build:copy-routes", + "build:release": "cross-env \"NODE_OPTIONS=--max-old-space-size=6144 --expose-gc\" VITE_API_BASE_URL=https://openapi.longbridge.com npx vitepress build docs && bun run build:llms && bun run build:copy-routes", + "build:cn": "cross-env \"NODE_OPTIONS=--max-old-space-size=6144 --expose-gc\" VITE_REGION=cn VITE_API_BASE_URL=https://openapi.longbridge.cn VITE_PORTAL_GATEWAY_BASE_URL=https://m.lbkrs.com VITE_SITE_HOSTNAME=https://open.longbridge.cn npx vitepress build docs && bun run build:llms && bun run build:copy-routes", "build:llms": "bun run scripts/normalize_md.ts && bun run scripts/generate-llms.ts", "build:copy-routes": "bun run scripts/copy-routes.ts", "preview": "vitepress preview docs", From 5832d8ed6585ef570052bbcfc42f33972cf1af6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sun, 10 May 2026 11:22:28 +0800 Subject: [PATCH 05/18] fix(autocorrect): add spaces around dash in trading_stats Co-Authored-By: Claude Sonnet 4.6 (1M context) --- docs/zh-CN/docs/fundamental/market/trading_stats.md | 2 +- docs/zh-HK/docs/fundamental/market/trading_stats.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh-CN/docs/fundamental/market/trading_stats.md b/docs/zh-CN/docs/fundamental/market/trading_stats.md index 8583961b..f81944e4 100644 --- a/docs/zh-CN/docs/fundamental/market/trading_stats.md +++ b/docs/zh-CN/docs/fundamental/market/trading_stats.md @@ -238,7 +238,7 @@ func main() { | trades | int32 | 是 | 成交笔数 | | volume | string | 是 | 总成交量 | | turnover | string | 是 | 总成交额 | -| distribution | object[] | 是 | 价格-成交量分布 | +| distribution | object[] | 是 | 价格 - 成交量分布 | | ∟ price | string | 是 | 价格档位 | | ∟ volume | string | 是 | 该价格的成交量 | | ∟ pct | string | 是 | 占总成交量的百分比 | diff --git a/docs/zh-HK/docs/fundamental/market/trading_stats.md b/docs/zh-HK/docs/fundamental/market/trading_stats.md index 1e409fed..bca3cb78 100644 --- a/docs/zh-HK/docs/fundamental/market/trading_stats.md +++ b/docs/zh-HK/docs/fundamental/market/trading_stats.md @@ -238,7 +238,7 @@ func main() { | trades | int32 | 是 | 成交筆數 | | volume | string | 是 | 總成交量 | | turnover | string | 是 | 總成交額 | -| distribution | object[] | 是 | 價格-成交量分布 | +| distribution | object[] | 是 | 價格 - 成交量分布 | | ∟ price | string | 是 | 價格檔位 | | ∟ volume | string | 是 | 該價格的成交量 | | ∟ pct | string | 是 | 占總成交量的百分比 | From 86e0ed125f9545095c8a02bbe46fc2578b20fe70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sun, 10 May 2026 11:23:57 +0800 Subject: [PATCH 06/18] fix(config): remove local-only superpowers exclude from srcExclude Co-Authored-By: Claude Sonnet 4.6 (1M context) --- docs/.vitepress/config.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 6e8056fc..f466d247 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -40,7 +40,7 @@ export default defineConfig( base: '/', buildConcurrency: 10, - srcExclude: ['README.md', 'superpowers/**', ...regionSrcExclude], + srcExclude: ['README.md', ...regionSrcExclude], rewrites: rewriteMarkdownPath, markdown: markdownConfig, transformHtml(code) { From a92b3864398f3120c0b4d4bd8b3db87429f14290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sun, 10 May 2026 11:26:25 +0800 Subject: [PATCH 07/18] chore: remove .temp from tracking and add to gitignore Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .gitignore | 1 + docs/.vitepress/.temp/assets/ai.svg | 121 ------------------ docs/.vitepress/.temp/assets/bar.svg | 15 --- docs/.vitepress/.temp/assets/code.svg | 112 ---------------- docs/.vitepress/.temp/assets/icon-cloud.svg | 10 -- docs/.vitepress/.temp/assets/icon-code.svg | 27 ---- docs/.vitepress/.temp/assets/icon-lanuch.svg | 10 -- docs/.vitepress/.temp/assets/quote.svg | 52 -------- docs/.vitepress/.temp/assets/sdk.svg | 97 -------------- docs/.vitepress/.temp/assets/trade.svg | 56 -------- .../.temp/longbridge-terminal/install | 67 ---------- .../.temp/longbridge-terminal/install.ps1 | 78 ----------- 12 files changed, 1 insertion(+), 645 deletions(-) delete mode 100644 docs/.vitepress/.temp/assets/ai.svg delete mode 100644 docs/.vitepress/.temp/assets/bar.svg delete mode 100644 docs/.vitepress/.temp/assets/code.svg delete mode 100644 docs/.vitepress/.temp/assets/icon-cloud.svg delete mode 100644 docs/.vitepress/.temp/assets/icon-code.svg delete mode 100644 docs/.vitepress/.temp/assets/icon-lanuch.svg delete mode 100644 docs/.vitepress/.temp/assets/quote.svg delete mode 100644 docs/.vitepress/.temp/assets/sdk.svg delete mode 100644 docs/.vitepress/.temp/assets/trade.svg delete mode 100755 docs/.vitepress/.temp/longbridge-terminal/install delete mode 100644 docs/.vitepress/.temp/longbridge-terminal/install.ps1 diff --git a/.gitignore b/.gitignore index e299a36c..71016c25 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ docs/superpowers # generated at build time by fetch-mcp-tools plugin docs/.vitepress/data/mcp-tools.json +docs/.vitepress/.temp/ diff --git a/docs/.vitepress/.temp/assets/ai.svg b/docs/.vitepress/.temp/assets/ai.svg deleted file mode 100644 index 9934fda1..00000000 --- a/docs/.vitepress/.temp/assets/ai.svg +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/bar.svg b/docs/.vitepress/.temp/assets/bar.svg deleted file mode 100644 index 8aefcabc..00000000 --- a/docs/.vitepress/.temp/assets/bar.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/code.svg b/docs/.vitepress/.temp/assets/code.svg deleted file mode 100644 index f665ee45..00000000 --- a/docs/.vitepress/.temp/assets/code.svg +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/icon-cloud.svg b/docs/.vitepress/.temp/assets/icon-cloud.svg deleted file mode 100644 index f5c2e0bd..00000000 --- a/docs/.vitepress/.temp/assets/icon-cloud.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/icon-code.svg b/docs/.vitepress/.temp/assets/icon-code.svg deleted file mode 100644 index 1d1a78e3..00000000 --- a/docs/.vitepress/.temp/assets/icon-code.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/icon-lanuch.svg b/docs/.vitepress/.temp/assets/icon-lanuch.svg deleted file mode 100644 index 6523d152..00000000 --- a/docs/.vitepress/.temp/assets/icon-lanuch.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/quote.svg b/docs/.vitepress/.temp/assets/quote.svg deleted file mode 100644 index d548172e..00000000 --- a/docs/.vitepress/.temp/assets/quote.svg +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/sdk.svg b/docs/.vitepress/.temp/assets/sdk.svg deleted file mode 100644 index cc8d1abc..00000000 --- a/docs/.vitepress/.temp/assets/sdk.svg +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/.vitepress/.temp/assets/trade.svg b/docs/.vitepress/.temp/assets/trade.svg deleted file mode 100644 index 9b1c3a1f..00000000 --- a/docs/.vitepress/.temp/assets/trade.svg +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/.vitepress/.temp/longbridge-terminal/install b/docs/.vitepress/.temp/longbridge-terminal/install deleted file mode 100755 index 2d8eec88..00000000 --- a/docs/.vitepress/.temp/longbridge-terminal/install +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env sh -set -eu -type curl > /dev/null || { echo "curl: not found"; exit 1; } - -repo='longbridge/longbridge-terminal' - -get_latest_release() { - tag=$(curl --silent "https://open.longbridge.cn/$repo/releases/latest") - if [ -z "$tag" ]; then - echo "Failed to fetch the latest release." >&2 - return 1 - fi - echo "$tag" -} - -version=$(get_latest_release) || exit 1 - -echo "Latest release: $version" - -bin_name='longbridge' -package_name='longbridge-terminal' - - -platform="$(uname | tr "[A-Z]" "[a-z]")" # Linux => linux -arch="$(uname -m)" # x86_64, arm64, aarch64, etc. - -# Normalize architecture names -case "$arch" in - x86_64) - arch="amd64" - ;; - aarch64) - arch="arm64" - ;; - arm64) - arch="arm64" - ;; -esac - -echo "Downloading $package_name@$version ..." - -# Always use the musl build on Linux – it is statically linked and works on any -# Linux system regardless of the glibc version (avoids segfaults on glibc -# systems where the binary was compiled against a different glibc version). -libc='' -if [ "$platform" = "linux" ]; then - libc='-musl' -fi - -download_url=https://open.longbridge.com/github/release/longbridge-terminal/$version/$package_name-$platform$libc-$arch.tar.gz -echo $download_url - -tmp_dir=$(mktemp -d) -trap 'rm -rf "$tmp_dir"' EXIT - -curl -Lo "$tmp_dir/$bin_name.tar.gz" $download_url -tar zxf "$tmp_dir/$bin_name.tar.gz" -C "$tmp_dir" - -if test $(id -u) -eq 0; then - mv "$tmp_dir/$bin_name" /usr/local/bin/$bin_name -else - sudo mv "$tmp_dir/$bin_name" /usr/local/bin/$bin_name -fi -echo "Longbridge CLI $version has installed successfully." -echo "" -echo "You can use \`longbridge -h\` to get help." -echo "" diff --git a/docs/.vitepress/.temp/longbridge-terminal/install.ps1 b/docs/.vitepress/.temp/longbridge-terminal/install.ps1 deleted file mode 100644 index 60529804..00000000 --- a/docs/.vitepress/.temp/longbridge-terminal/install.ps1 +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env pwsh -# Longbridge Terminal CLI installer for Windows -# Usage: iwr https://open.longbridge.com/longbridge/longbridge-terminal/install.ps1 | iex - -$ErrorActionPreference = 'Stop' - -$repo = 'longbridge/longbridge-terminal' -$binName = 'longbridge' -$packageName = 'longbridge-terminal' -$installDir = Join-Path $env:LOCALAPPDATA 'Programs\longbridge' - -# ── Resolve latest release version ─────────────────────────────────────────── - -Write-Host "Fetching latest release..." - -try { - $version = (Invoke-WebRequest -Uri "https://open.longbridge.com/$repo/releases/latest" -UseBasicParsing -TimeoutSec 15).Content.Trim() - if (-not $version) { - throw "Failed to fetch the latest release." - } -} catch { - throw "Failed to fetch the latest release: $_" -} - -Write-Host "Latest release: $version" - -# ── Download ────────────────────────────────────────────────────────────────── - -$downloadUrl = "https://open.longbridge.com/github/release/longbridge-terminal/$version/$packageName-windows-amd64.zip" - -Write-Host "Downloading $packageName@$version ..." -Write-Host $downloadUrl - -$tmpDir = Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName()) -$zipPath = Join-Path $tmpDir "$binName.zip" - -New-Item -ItemType Directory -Path $tmpDir | Out-Null - -try { - $wc = New-Object System.Net.WebClient - $wc.DownloadFile($downloadUrl, $zipPath) - $wc.Dispose() - - # ── Extract ─────────────────────────────────────────────────────────────── - - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $tmpDir) - - # ── Install ─────────────────────────────────────────────────────────────── - - if (-not (Test-Path $installDir)) { - New-Item -ItemType Directory -Path $installDir | Out-Null - } - - $srcExe = Join-Path $tmpDir "$binName.exe" - $destExe = Join-Path $installDir "$binName.exe" - Move-Item -Path $srcExe -Destination $destExe -Force - -} finally { - Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue -} - -# ── Add to user PATH if needed ──────────────────────────────────────────────── - -$userPath = [Environment]::GetEnvironmentVariable('PATH', 'User') -if ($userPath -notlike "*$installDir*") { - $newPath = ($userPath.TrimEnd(';') + ";$installDir").TrimStart(';') - [Environment]::SetEnvironmentVariable('PATH', $newPath, 'User') - Write-Host "" - Write-Host "Added $installDir to your PATH." - Write-Host "Restart your terminal for the PATH change to take effect." -} - -Write-Host "" -Write-Host "Longbridge CLI $version has been installed successfully." -Write-Host "" -Write-Host "Run 'longbridge auth login' to authenticate, then 'longbridge -h' for help." -Write-Host "" From 5a0fd53534b0fabb8e43b2d86225ef10396c7804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sun, 10 May 2026 11:40:51 +0800 Subject: [PATCH 08/18] chore(build): increase Node.js heap limit to 10GB Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .github/workflows/build.yml | 2 +- .github/workflows/canary.yml | 2 +- package.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8709d5a3..4dd88102 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,4 +29,4 @@ jobs: run: | bun run build:canary env: - NODE_OPTIONS: --max-old-space-size=6144 --expose-gc + NODE_OPTIONS: --max-old-space-size=10240 --expose-gc diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 6f549d5b..a23c5759 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -37,7 +37,7 @@ jobs: run: bun run build:canary env: VITE_PORTAL_GATEWAY_BASE_URL: 'https://m.longbridge.xyz' - NODE_OPTIONS: --max-old-space-size=6144 --expose-gc + NODE_OPTIONS: --max-old-space-size=10240 --expose-gc - name: Upload to Aliyun OSS run: | diff --git a/package.json b/package.json index 45fc94d4..83060280 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,9 @@ "dev": "cross-env VITE_API_BASE_URL=https://openapi.longbridge.xyz npx vitepress dev docs", "dev:prod": "cross-env VITE_API_BASE_URL=https://openapi.longbridge.com npx vitepress dev docs", "dev:cn": "cross-env VITE_REGION=cn VITE_API_BASE_URL=https://openapi.longbridge.cn VITE_SITE_HOSTNAME=https://open.longbridge.cn npx vitepress dev docs", - "build:canary": "cross-env \"NODE_OPTIONS=--max-old-space-size=6144 --expose-gc\" VITE_API_BASE_URL=https://openapi.longbridge.xyz npx vitepress build docs && bun run build:llms && bun run build:copy-routes", - "build:release": "cross-env \"NODE_OPTIONS=--max-old-space-size=6144 --expose-gc\" VITE_API_BASE_URL=https://openapi.longbridge.com npx vitepress build docs && bun run build:llms && bun run build:copy-routes", - "build:cn": "cross-env \"NODE_OPTIONS=--max-old-space-size=6144 --expose-gc\" VITE_REGION=cn VITE_API_BASE_URL=https://openapi.longbridge.cn VITE_PORTAL_GATEWAY_BASE_URL=https://m.lbkrs.com VITE_SITE_HOSTNAME=https://open.longbridge.cn npx vitepress build docs && bun run build:llms && bun run build:copy-routes", + "build:canary": "cross-env \"NODE_OPTIONS=--max-old-space-size=10240 --expose-gc\" VITE_API_BASE_URL=https://openapi.longbridge.xyz npx vitepress build docs && bun run build:llms && bun run build:copy-routes", + "build:release": "cross-env \"NODE_OPTIONS=--max-old-space-size=10240 --expose-gc\" VITE_API_BASE_URL=https://openapi.longbridge.com npx vitepress build docs && bun run build:llms && bun run build:copy-routes", + "build:cn": "cross-env \"NODE_OPTIONS=--max-old-space-size=10240 --expose-gc\" VITE_REGION=cn VITE_API_BASE_URL=https://openapi.longbridge.cn VITE_PORTAL_GATEWAY_BASE_URL=https://m.lbkrs.com VITE_SITE_HOSTNAME=https://open.longbridge.cn npx vitepress build docs && bun run build:llms && bun run build:copy-routes", "build:llms": "bun run scripts/normalize_md.ts && bun run scripts/generate-llms.ts", "build:copy-routes": "bun run scripts/copy-routes.ts", "preview": "vitepress preview docs", From b1d22487cfe19628f3a313740581f0c00db446c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Sun, 10 May 2026 11:49:20 +0800 Subject: [PATCH 09/18] fix(ssr): guard document access in PlatformStats with onMounted document is not available during SSR; move dark-mode color detection into onMounted so it only runs in the browser. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- .../components/NewHomePage/PlatformStats.vue | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/.vitepress/theme/components/NewHomePage/PlatformStats.vue b/docs/.vitepress/theme/components/NewHomePage/PlatformStats.vue index f7b24a12..db00342f 100644 --- a/docs/.vitepress/theme/components/NewHomePage/PlatformStats.vue +++ b/docs/.vitepress/theme/components/NewHomePage/PlatformStats.vue @@ -1,15 +1,19 @@