-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathopenapi.yaml
More file actions
2811 lines (2654 loc) · 99.4 KB
/
openapi.yaml
File metadata and controls
2811 lines (2654 loc) · 99.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: Longbridge OpenAPI
description: |
Longbridge OpenAPI provides programmatic access to market data, trading, account management,
watchlist management, and content queries for the Longbridge trading platform.
version: '1.0.0'
x-pages:
- id: overview
title: Overview
x-title-zh: 概览
x-icon: book
content: |
This page is reorganized as a practical **OAuth 2.0 access flow** for new integrations.
> **Tip:** Prefer using SDKs for faster integration: https://open.longbridge.com/sdk
## Notes
| Precautions | Reference |
| -------------------------------------------- | --------------------------------------------------------------------- |
| Prefer SDKs over raw HTTP when possible | [SDK Quick Start](/docs/getting-started) |
| Enable required OpenAPI services first | [How to enable OpenAPI](/docs/#how-to-enable-openapi) |
| Understand permissions and restrictions | [Permissions and restrictions](/docs/#permissions-and-restrictions) |
| Check common error codes for troubleshooting | [Error Codes](/docs/error-codes) |
## OAuth 2.0 (Default)
For new integrations, OAuth 2.0 is the default path.
API-key signature mode can remain as a fallback for legacy compatibility, but it is not the default.
### Discovery endpoints
- Production: `https://openapi.longbridge.com/.well-known/oauth-authorization-server`
- China: `https://openapi.longbridge.cn/.well-known/oauth-authorization-server`
Supported grant types (from discovery):
- `authorization_code`
- `refresh_token`
## OAuth 2.0 flow (step-by-step)
### 1) Register OAuth client
If there is no UI for client creation in your environment, register dynamically:
```shell
curl -X POST https://openapi.longbridge.com/oauth2/register \
-H "Content-Type: application/json" \
-d '{
"client_name": "my-openapi-app",
"redirect_uris": ["https://your-app.com/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"]
}'
```
> Registration may return only `client_id` (public client, no `client_secret`). In this case, use PKCE and do not send `client_secret` in token requests.
### 2) Build authorization URL and get `code`
```text
https://openapi.longbridge.com/oauth2/authorize
?response_type=code
&client_id=YOUR_CLIENT_ID
&redirect_uri=YOUR_REDIRECT_URI
&scope=3
&state=YOUR_RANDOM_STATE
&code_challenge=YOUR_CODE_CHALLENGE
&code_challenge_method=S256
```
After user consent, callback receives:
```text
YOUR_REDIRECT_URI?code=AUTH_CODE&state=YOUR_RANDOM_STATE
```
### 3) Exchange `code` for `access_token`
```shell
curl -X POST https://openapi.longbridge.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code" \
-d "client_id=YOUR_CLIENT_ID" \
-d "redirect_uri=YOUR_REDIRECT_URI" \
-d "code=AUTH_CODE" \
-d "code_verifier=YOUR_CODE_VERIFIER"
# only when your client has secret:
# -d "client_secret=YOUR_CLIENT_SECRET"
```
### 4) Call API with Bearer token (TSLA.US example)
```shell
curl -X GET "https://openapi.longbridge.com/v1/quote/get_security_list?market=US&category=Overnight" \
-H "Authorization: Bearer ACCESS_TOKEN"
```
Real response (excerpt, keeping `TSLA.US` row):
```json
{
"code": 0,
"message": "success",
"data": {
"list": [
{
"symbol": "TSLA.US",
"name_cn": "特斯拉",
"name_hk": "",
"name_en": ""
}
]
}
}
```
### 5) Refresh token
Use OAuth token endpoint for refresh (details in Refresh Token section below):
```bash
curl -X POST https://openapi.longbridge.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "client_id=YOUR_CLIENT_ID" \
-d "refresh_token=REFRESH_TOKEN"
# only when your client has secret:
# -d "client_secret=YOUR_CLIENT_SECRET"
```
## Relationship with legacy docs
- This page: OAuth 2.0 main flow for new integrations.
- Refresh Token section below: refresh step details only, to avoid duplication.
---
# Refresh Token (OAuth 2.0)
This page focuses only on the OAuth 2.0 **refresh token** step.
- If you have not completed the full flow yet, read the Authentication section above first.
- This page does not repeat client registration / authorization code steps.
## Recommended refresh method (OAuth 2.0)
Use OAuth token endpoint:
- `POST https://openapi.longbridge.com/oauth2/token`
- or China: `POST https://openapi.longbridge.cn/oauth2/token`
### Request parameters (`application/x-www-form-urlencoded`)
| Name | Required | Description |
| --- | --- | --- |
| grant_type | Yes | Must be `refresh_token` |
| client_id | Yes | OAuth client id |
| refresh_token | Yes | Previously issued refresh token |
| client_secret | Optional | Required only for confidential clients; omit for public clients |
### Refresh example
```bash
curl -X POST https://openapi.longbridge.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "client_id=YOUR_CLIENT_ID" \
-d "refresh_token=YOUR_REFRESH_TOKEN"
# only when your client has secret:
# -d "client_secret=YOUR_CLIENT_SECRET"
```
### Response example
```json
{
"access_token": "...",
"refresh_token": "...",
"expires_in": 2592000,
"token_type": "Bearer"
}
```
## Compatibility note
Legacy `/v1/token/refresh` remains for backward compatibility.
For new integrations, use OAuth 2.0 token endpoint as default.
x-content-zh: |
本页按 **OAuth 2.0 实际接入流程** 重新整理,用于新接入用户快速走通。
> **提示:** 优先使用 SDK,接入更简单:https://open.longbridge.com/sdk
## API 须知
| 注意事项 | 参考文档 |
| -------------------------------------------- | ------------------------------------------------- |
| 推荐使用各自语言的 SDK,而不是调用原生的接口 | [SDK 快速开始页面](/docs/getting-started) |
| 阅读 OpenAPI 介绍中开通相应服务 | [OpenAPI 如何开通](/docs/#如何开通) |
| 阅读 OpenAPI 介绍中使用权限及限制 | [OpenAPI 使用权限及限制](/docs/#使用权限及限制) |
| 了解通用错误码,便于查找调用接口出错的原因 | [通用错误码](/docs/error-codes) |
## OAuth 2.0(推荐方案)
新接入默认使用 OAuth 2.0。API Key 签名方式作为备选兼容方案可保留(例如在 SDK/历史实现中),但不作为默认接入方式。
### Discovery 地址
- 生产环境:`https://openapi.longbridge.com/.well-known/oauth-authorization-server`
- 中国内地:`https://openapi.longbridge.cn/.well-known/oauth-authorization-server`
支持授权类型(以 Discovery 返回为准):
- `authorization_code`
- `refresh_token`
## OAuth 2.0 接入流程(一步一步)
### 1)注册 OAuth 客户端
如果没有可视化后台入口,可通过接口动态注册:
```bash
curl -X POST https://openapi.longbridge.com/oauth2/register \
-H "Content-Type: application/json" \
-d '{
"client_name": "my-openapi-app",
"redirect_uris": ["https://your-app.com/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"]
}'
```
> 注册返回可能仅包含 `client_id`(public client,不返回 `client_secret`)。这种情况下请使用 PKCE,并在 token 请求里不传 `client_secret`。
### 2)构造授权链接并获取 code
```text
https://openapi.longbridge.com/oauth2/authorize
?response_type=code
&client_id=YOUR_CLIENT_ID
&redirect_uri=YOUR_REDIRECT_URI
&scope=3
&state=YOUR_RANDOM_STATE
&code_challenge=YOUR_CODE_CHALLENGE
&code_challenge_method=S256
```
用户授权后,回调地址会收到:
```text
YOUR_REDIRECT_URI?code=AUTH_CODE&state=YOUR_RANDOM_STATE
```
### 3)用 code 换 access_token
```bash
curl -X POST https://openapi.longbridge.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code" \
-d "client_id=YOUR_CLIENT_ID" \
-d "redirect_uri=YOUR_REDIRECT_URI" \
-d "code=AUTH_CODE" \
-d "code_verifier=YOUR_CODE_VERIFIER"
# 仅当客户端有 secret 时再加:
# -d "client_secret=YOUR_CLIENT_SECRET"
```
### 4)用 Bearer token 调 API(TSLA.US 实例)
```bash
curl -X GET "https://openapi.longbridge.com/v1/quote/get_security_list?market=US&category=Overnight" \
-H "Authorization: Bearer ACCESS_TOKEN"
```
实际返回(节选,保留 `TSLA.US` 项):
```json
{
"code": 0,
"message": "success",
"data": {
"list": [
{
"symbol": "TSLA.US",
"name_cn": "特斯拉",
"name_hk": "",
"name_en": ""
}
]
}
}
```
### 5)刷新 token
通过 OAuth token endpoint 刷新(详见下方"刷新 Token"部分):
```bash
curl -X POST https://openapi.longbridge.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "client_id=YOUR_CLIENT_ID" \
-d "refresh_token=REFRESH_TOKEN"
# 仅当客户端有 secret 时再加:
# -d "client_secret=YOUR_CLIENT_SECRET"
```
## 与旧文档的关系
- 本页:只讲 **OAuth 2.0 主流程**(新接入默认看这里)。
- 下方"刷新 Token"部分:只讲刷新步骤细节与常见问题,避免重复。
---
# 刷新 Token(OAuth 2.0)
本页仅说明 OAuth 2.0 的 **refresh token** 刷新步骤。
- 如果你还没走完完整授权流程,请先看上方认证部分。
- 本页不重复注册 client / 获取 code 的流程,只关注"刷新"这一步
## 推荐刷新方式(OAuth 2.0)
使用 OAuth token endpoint:
- `POST https://openapi.longbridge.com/oauth2/token`
- 或中国内地:`POST https://openapi.longbridge.cn/oauth2/token`
### 请求参数(`application/x-www-form-urlencoded`)
| 名称 | 必须 | 说明 |
| ------------- | ---- | ---- |
| grant_type | 是 | 固定为 `refresh_token` |
| client_id | 是 | OAuth client id |
| refresh_token | 是 | 上一次签发的 refresh token |
| client_secret | 否 | 仅机密客户端需要;public client 不传 |
### 刷新示例
```bash
curl -X POST https://openapi.longbridge.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "client_id=YOUR_CLIENT_ID" \
-d "refresh_token=YOUR_REFRESH_TOKEN"
# 仅当你的客户端有 secret 时再加:
# -d "client_secret=YOUR_CLIENT_SECRET"
```
### 响应示例
```json
{
"access_token": "...",
"refresh_token": "...",
"expires_in": 2592000,
"token_type": "Bearer"
}
```
## 兼容说明
历史接口 `/v1/token/refresh` 属于旧方案兼容路径,不建议新接入继续采用。新接入请统一使用 OAuth 2.0 token endpoint。
- id: real-time-data
title: Real-Time Market Data
x-title-zh: 实时行情
x-icon: activity
content: |
> **Note:** Real-time market data is **not** part of this HTTP REST API. Quotes, price feeds, order book depth, broker queues, and trade ticks are delivered via **WebSocket / TCP long connection** through a dedicated quote gateway — see the [Socket Feed](/docs/socket/hosts) documentation.
## Overview
The HTTP REST API (documented on this page) covers trading operations, account management, and historical/snapshot data queries. Real-time streaming data — all market quote subscriptions and push feeds — is a separate system:
| Data Type | Access Method |
|-----------|---------------|
| Trading orders, account info, watchlist | HTTP REST API (this page) |
| Real-time quotes, depth, trade ticks | WebSocket / TCP Socket Feed |
## Connecting to the Quote Gateway
Connect to Longbridge's quote gateway directly via WebSocket or TCP:
**WebSocket:** `wss://openapi-quote.longbridge.com`
**TCP:** `openapi-quote.longbridge.com:2020`
> Mainland China users: `wss://openapi-quote.longbridge.cn` / `openapi-quote.longbridge.cn:2020`
## Subscribing to Market Data
After connecting, authenticate with your API credentials, then send a subscribe command specifying symbols and subscription types (price, depth, broker queue, trade ticks). The server will then push real-time data as it arrives.
The SDK handles connection lifecycle and subscriptions automatically — for most integrations the SDK is the recommended approach: https://open.longbridge.com/sdk
## Further Reading
- [Socket Feed endpoints](/docs/socket/hosts)
- [Subscribe to market data](/docs/socket/subscribe_quote)
- [Protocol overview](/docs/socket/protocol/overview)
x-content-zh: |
> **注意:** 实时行情数据**不**属于本 HTTP REST API 的范围。报价、价格推送、盘口、经纪队列及成交明细通过专用行情网关以 **WebSocket / TCP 长连接**方式推送,详见 [Socket 实时推送](/docs/socket/hosts) 文档。
## 概述
本 HTTP REST API(即本页面记录的接口)涵盖交易操作、账户管理及历史/快照数据查询。实时流式数据——所有行情订阅与推送——属于独立的系统:
| 数据类型 | 接入方式 |
|----------|----------|
| 交易委托、账户信息、自选股 | HTTP REST API(本页) |
| 实时报价、盘口、成交明细 | WebSocket / TCP Socket Feed |
## 连接行情网关
通过 WebSocket 或 TCP 直连 Longbridge 行情网关:
**WebSocket:** `wss://openapi-quote.longbridge.com`
**TCP:** `openapi-quote.longbridge.com:2020`
> 中国大陆用户:`wss://openapi-quote.longbridge.cn` / `openapi-quote.longbridge.cn:2020`
## 订阅行情
连接后,使用 API 凭证完成鉴权,然后发送订阅指令,指定标的和订阅类型(价格、盘口、经纪队列、成交明细)。服务端将实时推送订阅的行情数据。
SDK 已完整实现连接生命周期管理与订阅功能,推荐大多数接入场景直接使用 SDK:https://open.longbridge.com/sdk
## 相关文档
- [Socket 实时推送接入地址](/docs/socket/hosts)
- [订阅行情推送](/docs/socket/subscribe_quote)
- [协议概览](/docs/socket/protocol/overview)
- id: error-codes
title: Error Codes
x-title-zh: 错误码
x-icon: alert-circle
content: |
## Error Codes
| HTTP Status | Code | Message | Description |
| ----------- | ------ | ---------------------- | ------------------------------------------------------------------ |
| 403 | 403201 | signature invalid | signature is invalid |
| 403 | 403202 | duplicate request | Repeat request, same request without replacement `x-timestamp` |
| 403 | 403203 | apikey illegal | `App Key` is illegal |
| 403 | 403205 | ip is not allowed | IP address is not authorized to access |
| 401 | 401003 | token expired | Access token expired. Legacy API Key: obtain a new token from [https://open.longbridge.com/](https://open.longbridge.com/). OAuth: use the refresh token flow. |
| 429 | 429001 | ip request ratelimit | Too frequent requests as a same IP address, please try again later |
| 429 | 429002 | api request is limited | Too frequent requests on an API, please try again later |
| 500 | 500000 | internal error | server internal error, please contact customer support |
x-content-zh: |
## 错误码
| HTTP Status | code | message | 说明 |
| ----------- | ------ | ---------------------- | ---------------------------------------- |
| 403 | 403201 | signature invalid | 签名无效 |
| 403 | 403202 | duplicate request | 重复请求,同一个请求没有更换 X-Timestamp |
| 403 | 403203 | apikey illegal | App Key 无效 |
| 403 | 403205 | ip is not allowed | IP 地址无权访问 |
| 401 | 401003 | token expired | Access Token 已过期。旧版 API Key:请在 [https://open.longbridge.com/](https://open.longbridge.com/) 重新获取;OAuth:请使用 refresh token 流程刷新。 |
| 429 | 429001 | ip request ratelimit | IP 访问过于频繁,请稍后再试 |
| 429 | 429002 | api request is limited | 接口访问过于频繁,请稍后再试 |
| 500 | 500000 | internal error | 服务内部错误,请联系客户经理进行处理 |
servers:
- url: https://openapi.longbridge.com
description: Global
- url: https://openapi.longbridge.cn
description: China mainland
tags:
- name: Watchlist Management
x-name-zh: 自选股管理
description: Manage user watchlist groups (list/create/update/delete) and query the securities contained in each group. Supports adding, removing, or replacing securities within a group.
- name: Market Temperature
x-name-zh: 市场情绪
description: Query the Market Temperature indicator (a fear-gauge-like sentiment thermometer, scored 0–100 where higher means more bullish) across equity markets. Supports fetching the current snapshot and historical time series for sentiment measurement, trend visualization, and comparative analysis.
- name: Portfolio & Cash
x-name-zh: 持仓与资金
description: Provides read access to account asset and cash information, including fund holdings, stock holdings, account cash balance, and cash flow history for portfolio overview, position display, and reconciliation analysis.
- name: News & Filings
x-name-zh: 新闻与公告
description: Query regulatory filings, news articles, and community discussion topics for a given symbol. Suitable for investment research, news monitoring, and content aggregation.
- name: Community
x-name-zh: 社区互动
description: Interact with the Longbridge community. Supports listing your published topics with pagination and type filtering, and creating new topics (long-form articles or short posts) with associated tickers, hashtags, and license settings.
- name: Trade Execution & Order Management
x-name-zh: 交易与订单管理
description: Full order lifecycle management including order detail queries, today's and historical order queries, today's and historical execution reports, order modification, order cancellation, and pre-order maximum purchasable quantity estimation.
- name: Statement
x-name-zh: 结单
description: Query and download account statements (daily or monthly). Statements contain detailed breakdowns of assets, holdings, trades, fees, and corporate actions.
security:
- oauth2:
- openapi
paths:
/watchlist/groups:
get:
operationId: list_watchlist_groups
summary: Get Watchlists
x-summary-zh: 获取自选股分组列表
description: |
Get all watchlist groups for the current user. Each group contains an ID, name, and a list
of securities with the price and timestamp at which each security was added.
x-description-zh: 获取当前用户的所有自选股分组,每个分组包含 ID、名称及其中的证券列表(含加入价格和时间戳)。
tags:
- Watchlist Management
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge watchlist
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
groups:
- id: '2630'
name: My Watchlist
securities:
- symbol: AAPL.US
market: US
name: Apple Inc.
watched_price: '211.59'
watched_at: '1741690995'
is_pinned: true
- symbol: 700.HK
market: HK
name: 腾讯控股
watched_price: '460.00'
watched_at: '1725511157'
is_pinned: false
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
operationId: create_watchlist_group
summary: Create Watchlist
x-summary-zh: 创建自选股分组
description: |
Create a new watchlist group, optionally pre-populated with securities.
x-description-zh: 创建新的自选股分组,可选择在创建时预填充证券。
tags:
- Watchlist Management
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
properties:
name:
type: string
minLength: 1
description: Group name. Must be at least 1 character and within the system name length limit.
securities:
type: array
nullable: true
description: Optional list of security symbols to pre-populate the group on creation (e.g. `["AAPL.US", "700.HK"]`).
items:
type: string
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge watchlist create "NAME"
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
id: '4303353'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
operationId: update_watchlist_group
summary: Update Watchlist
x-summary-zh: 更新自选股分组
description: |
Update the name or member list of a watchlist group. Use `mode` to control how
`securities` are applied: `add` appends, `remove` removes, `replace` overwrites the entire list.
x-description-zh: 更新自选股分组的名称或成员列表。使用 `mode` 控制 `securities` 的操作方式:`add` 追加、`remove` 移除、`replace` 替换全部。
tags:
- Watchlist Management
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- id
properties:
id:
type: string
description: ID of the group to update (required).
name:
type: string
nullable: true
description: New group name. Omit to keep the existing name.
mode:
type: string
nullable: true
enum:
- add
- remove
- replace
description: |
Operation mode for the `securities` list. One of:
- `add` — append securities to the group
- `remove` — remove securities from the group
- `replace` — replace all securities in the group
securities:
type: array
nullable: true
description: List of security symbols affected by the operation (e.g. `["AAPL.US", "700.HK"]`).
items:
type: string
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge watchlist update <ID>
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data: {}
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
operationId: delete_watchlist_group
summary: Delete Watchlist
x-summary-zh: 删除自选股分组
description: |
Delete the specified watchlist group. Set `purge=true` to also clear all securities
from the group before deletion.
x-description-zh: 删除指定的自选股分组。设置 `purge=true` 可在删除前清空分组中的所有证券。
tags:
- Watchlist Management
parameters:
- name: id
in: query
required: true
description: ID of the group to delete.
schema:
type: string
- name: purge
in: query
required: false
description: If `true`, clears all securities from the group before deleting. Defaults to `false`.
schema:
type: boolean
nullable: true
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge watchlist delete <ID>
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data: {}
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/quote/get_security_list:
get:
operationId: list_securities
summary: Query Tradable Securities List
x-summary-zh: 查询可交易证券列表
description: |
Query the list of tradable securities filtered by market and category. Primarily used to
retrieve securities eligible for extended-hours (pre-market / after-hours) trading sessions.
Both `market` and `category` are required parameters.
x-description-zh: 按市场和类别筛选可交易证券列表,主要用于获取符合盘前/盘后延长交易时段条件的证券。`market` 和 `category` 均为必填参数。
tags:
- Watchlist Management
parameters:
- name: market
in: query
required: true
description: Market code. One of `US`, `HK`.
schema:
type: string
- name: category
in: query
required: true
description: Security category filter for the target trading session (e.g. `overnight` for US overnight-tradable securities).
schema:
type: string
nullable: true
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge security-list
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
list:
- symbol: AAPL.US
name_cn: 苹果
name_hk: 蘋果
name_en: Apple Inc.
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/quote/history_market_temperature:
get:
operationId: list_market_temperature
summary: Get Historical Market Temperature
x-summary-zh: 获取历史市场情绪
description: |
Get the historical market temperature time series for the specified market within a date range.
Each data point contains the daily temperature, valuation, and sentiment scores (all scored 0–100).
x-description-zh: 获取指定市场在日期范围内的历史市场情绪时间序列,每个数据点包含当日情绪温度、估值和情绪分项评分(均为 0–100 分制)。
tags:
- Market Temperature
parameters:
- name: market
in: query
required: true
description: |
Market code. One of:
- `HK` — Hong Kong
- `US` — United States
- `CN` — A-shares
- `SG` — Singapore
schema:
type: string
- name: start_date
in: query
required: true
description: Start date in `YYYYMMDD` format (e.g. `20250101`).
schema:
type: string
- name: end_date
in: query
required: true
description: End date in `YYYYMMDD` format (e.g. `20250110`).
schema:
type: string
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge market-temp [MARKET] --history --start YYYY-MM-DD --end YYYY-MM-DD
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
list:
- timestamp: '1735794000'
temperature: 58
valuation: 54
sentiment: 61
- timestamp: '1735880400'
temperature: 59
valuation: 56
sentiment: 63
type: day
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/quote/market_temperature:
get:
operationId: market_temperature
summary: Get Current Market Temperature
x-summary-zh: 获取当前市场情绪
description: |
Get the current sentiment temperature snapshot for the specified market.
Scores range from 0–100; a higher value indicates a more bullish market.
x-description-zh: 获取指定市场的当前情绪温度快照。评分范围 0–100,数值越高表示市场越乐观。
tags:
- Market Temperature
parameters:
- name: market
in: query
required: true
description: |
Market code. One of:
- `HK` — Hong Kong
- `US` — United States
- `CN` — A-shares
- `SG` — Singapore
schema:
type: string
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge market-temp [MARKET]
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
temperature: 70
description: 温度温暖并快速上升中
valuation: 59
sentiment: 82
updated_at: '1774317902'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/asset/cashflow:
get:
operationId: list_cash_flow
summary: Cash Flow
x-summary-zh: 资金流水查询
description: |
Query account cash flow history. Covers deposit, withdrawal, dividends, settlement,
and other business types. Supports time range and pagination.
x-description-zh: 查询账户资金流水历史,涵盖入金、出金、分红、结算等业务类型,支持时间范围筛选和分页。
tags:
- Portfolio & Cash
parameters:
- name: start_time
in: query
required: false
description: Query range start time as a Unix timestamp (seconds).
schema:
type: integer
nullable: true
- name: end_time
in: query
required: false
description: Query range end time as a Unix timestamp (seconds).
schema:
type: integer
nullable: true
- name: business_type
in: query
required: false
description: Business type filter (integer). Omit to return all types.
schema:
type: integer
nullable: true
- name: symbol
in: query
required: false
description: Filter by security symbol (e.g. `AAPL.US`). Supports multiple values.
schema:
type: array
nullable: true
items:
type: string
- name: page
in: query
required: false
description: Page number (1-based). Defaults to `1`.
schema:
type: integer
nullable: true
- name: size
in: query
required: false
description: Number of records per page. Defaults to `20`.
schema:
type: integer
nullable: true
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge cash-flow
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
list:
- transaction_flow_name: 在途分红
direction: 1
business_type: 0
balance: '13.65'
currency: USD
business_time: '1771826509'
symbol: MSFT.US
description: 'MSFT.US Cash Dividend: 0.91 USD per share(in transit)'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/asset/account:
get:
operationId: account_cash
summary: Account Cash
x-summary-zh: 账户现金
description: |
Query account cash balance, buying power, margin details, and per-currency cash breakdown.
x-description-zh: 查询账户现金余额、购买力、保证金详情及各币种资金明细。
tags:
- Portfolio & Cash
parameters:
- name: currency
in: query
required: false
description: Filter by currency code (e.g. `USD`, `HKD`). Omit to return all currencies.
schema:
type: string
nullable: true
x-codeSamples:
- lang: Shell
label: CLI
source: |
longbridge balance
responses:
'200':
description: Successful response
content:
application/json:
example:
code: 0
message: success
data:
list:
- total_cash: '456943.18'
max_finance_amount: '3200000.00'
remaining_finance_amount: '3654289.90'
risk_level: '0'
margin_call: '0'
currency: HKD
net_assets: '962678.11'
init_margin: '141090.88'
maintenance_margin: '123141.91'
buy_power: '821587.22'
frozen_transaction_fees: []
cash_infos:
- currency: USD
withdraw_cash: '-38665.68'
available_cash: '-38665.68'
frozen_cash: '332.19'