Skip to content

Commit 14201e4

Browse files
committed
Merge branch 'main' into release
2 parents f4b7246 + 87567c5 commit 14201e4

409 files changed

Lines changed: 51561 additions & 1717 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-mcp.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ build
1212

1313

1414
.DS_Store
15-
*/.DS_Store
15+
*/.DS_Store
16+
*.dylib
17+
*.so
18+
*.node
19+
.venv/
20+
python/.venv/

AGENTS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ cargo make protoc
3838
The generated `*.rs` files under `rust/crates/proto/src/` are **auto-generated** — never edit
3939
them by hand.
4040

41+
## After modifying the Python SDK API (`python/`)
42+
43+
`python/pysrc/longbridge/openapi.pyi` is a **manually maintained** type-stub
44+
file that provides type hints and docstrings for the native Rust/PyO3 extension
45+
module. IDEs and type checkers (mypy/pyright) rely on it for autocompletion and
46+
static analysis.
47+
48+
When you add, remove, or change any `#[pyclass]`/`#[pymethods]` definitions in
49+
`python/src/`, you **must** update `openapi.pyi` accordingly — keeping
50+
signatures, type annotations, and docstrings in sync with the Rust
51+
implementation.
52+
4153
## After modifying the C SDK (`c/`)
4254

4355
`c/csrc/include/longbridge.h` is **auto-generated** by `cbindgen` during the
@@ -46,3 +58,12 @@ build — never edit it by hand. Rebuild the C crate to update it:
4658
```bash
4759
cargo build -p longbridge-c
4860
```
61+
62+
## After any change
63+
64+
Update `CHANGELOG.md` in the workspace root to document notable changes. The
65+
format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Add an
66+
entry under the `[Unreleased]` section in the appropriate subsection (`Added`,
67+
`Changed`, `Fixed`, `Breaking changes`, etc.). If the `[Unreleased]` section
68+
does not yet exist, create it at the top of the changelog (above the latest
69+
versioned block).

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,48 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# [4.0.6]
8+
9+
## Added
10+
11+
- **All languages (Rust, Python, Node.js, Java, C, C++):** Seven new context types covering all major data APIs:
12+
- `FundamentalContext` — financial reports, analyst ratings, dividends, EPS forecasts, consensus estimates, valuation (PE/PB/PS), industry valuation, company overview, executives, shareholders, fund holders, corporate actions, investor relations, operating reports, buyback data, stock ratings.
13+
- `MarketContext` — market status, broker holding (top/detail/daily), A/H premium (klines/intraday), trade statistics, market anomalies, index constituents.
14+
- `CalendarContext` — finance calendar (earnings, dividends, splits, IPOs, macro data, market closures, meetings, mergers).
15+
- `PortfolioContext` — exchange rates, P&L analysis (summary/detail/by-market/flows).
16+
- `AlertContext` — price alert management (list/add/delete/enable/disable).
17+
- `DCAContext` — dollar-cost-averaging plan management (list/create/update/pause/resume/stop/history/stats/check-support/calc-date/set-reminder).
18+
- `SharelistContext` — community sharelist management (list/detail/popular/create/delete/add-securities/remove-securities/sort-securities).
19+
- **All languages:** `QuoteContext` gains `short_positions`, `option_volume`, `option_volume_daily`, and `update_pinned`.
20+
- **All languages:** `ContentContext` gains `topic_detail`, `list_topic_replies`, and `create_topic_reply`.
21+
- **Rust:** `Config::header(key, value)` builder method for injecting custom HTTP/WebSocket headers.
22+
- **All languages (Rust, Python, Node.js, Java, C, C++):** Restore `Config::refresh_access_token` (and `refresh_access_token_blocking` in Rust). Refreshes the access token via the Longbridge token-refresh API. Only available with **Legacy API Key** authentication (`Config::from_apikey`); not supported in OAuth 2.0 mode.
23+
24+
## Changed
25+
26+
- **All languages:** Method parameters now use typed enums instead of raw integers: `DCAFrequency`, `DCAStatus`, `AlertCondition`, `AlertFrequency`, `CalendarCategory`, `FinancialReportKind`, `FinancialReportPeriod`, `BrokerHoldingPeriod`, `AhPremiumPeriod`.
27+
- **All languages:** Response struct fields are typed enums where applicable: `DcaPlan.status` / `invest_frequency` / `market`, `MarketTimeItem.market`, `FlowItem.direction`, `ProfitSummaryInfo.asset_type`, `InstitutionRatingSummary.recommend`.
28+
- **All languages:** All SDK responses are fully typed structs — no method returns a raw JSON string.
29+
- **All languages:** Monetary/numeric fields use `Decimal`/`Option<Decimal>` (Rust) or `BigDecimal` (Java). Non-parseable values such as `""` or `"--"` deserialize as `None`/`null`.
30+
31+
## Fixed
32+
33+
- **Rust:** Fix incorrect cache expiry checks in `QuoteContext`.
34+
35+
# [4.0.6]
36+
37+
## Added
38+
39+
- **All bindings:** `ContentContext` adds two new methods (Rust, Go, C, C++, Java, Python, Node.js):
40+
- `my_topics(opts)` — get topics created by the current authenticated user, with optional page/size/topic_type filtering.
41+
- `create_topic(opts)` — create a new topic; returns the topic ID (`String`) on success.
42+
- **All bindings:** New types `OwnedTopic`, `MyTopicsOptions`, and `CreateTopicOptions` to support the above methods.
43+
- **Python:** Added type stubs (`openapi.pyi`) for `ContentContext`, `AsyncContentContext`, `OwnedTopic`, `TopicReply`, `TopicAuthor`, and `TopicImage`.
44+
45+
## Fixed
46+
47+
- **C++:** `create_topic` callback now correctly yields `std::string` (topic ID) instead of `OwnedTopic`.
48+
749
# [4.0.5]
850

951
## Changed

CLAUDE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Agent Guidelines
2+
3+
## After modifying Rust code
4+
5+
Run the following commands from the workspace root:
6+
7+
```bash
8+
cargo clippy --all --all-features
9+
cargo +nightly fmt --all
10+
```
11+
12+
> **Note:** `cargo +nightly fmt` may reflow doc comments (e.g. `/// @param …`
13+
> lines). Do **not** revert those changes — they are intentional formatting
14+
> output and should be committed as-is.
15+
16+
## After modifying the Node.js SDK (`nodejs/`)
17+
18+
Build the native `.node` binary from the `nodejs/` directory:
19+
20+
```bash
21+
npm run build:debug
22+
```
23+
24+
`nodejs/index.d.ts` and `nodejs/index.js` are **auto-generated** by
25+
`npm run build:debug` — never edit them by hand.
26+
27+
## After updating the proto submodule (`rust/crates/proto/openapi-protobufs/`)
28+
29+
Run the following command from the workspace root to regenerate the Rust proto source files
30+
(e.g. `rust/crates/proto/src/longbridge.control.v1.rs`,
31+
`rust/crates/proto/src/longbridge.quote.v1.rs`,
32+
`rust/crates/proto/src/longbridge.trade.v1.rs`):
33+
34+
```bash
35+
cargo make protoc
36+
```
37+
38+
The generated `*.rs` files under `rust/crates/proto/src/` are **auto-generated** — never edit
39+
them by hand.
40+
41+
## After modifying the Python SDK API (`python/`)
42+
43+
`python/pysrc/longbridge/openapi.pyi` is a **manually maintained** type-stub
44+
file that provides type hints and docstrings for the native Rust/PyO3 extension
45+
module. IDEs and type checkers (mypy/pyright) rely on it for autocompletion and
46+
static analysis.
47+
48+
When you add, remove, or change any `#[pyclass]`/`#[pymethods]` definitions in
49+
`python/src/`, you **must** update `openapi.pyi` accordingly — keeping
50+
signatures, type annotations, and docstrings in sync with the Rust
51+
implementation.
52+
53+
## After modifying the C SDK (`c/`)
54+
55+
`c/csrc/include/longbridge.h` is **auto-generated** by `cbindgen` during the
56+
build — never edit it by hand. Rebuild the C crate to update it:
57+
58+
```bash
59+
cargo build -p longbridge-c
60+
```
61+
62+
## After any change
63+
64+
Update `CHANGELOG.md` in the workspace root to document notable changes. The
65+
format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Add an
66+
entry under the `[Unreleased]` section in the appropriate subsection (`Added`,
67+
`Changed`, `Fixed`, `Breaking changes`, etc.). If the `[Unreleased]` section
68+
does not yet exist, create it at the top of the changelog (above the latest
69+
versioned block).

Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "3"
3-
members = ["rust", "python", "nodejs", "java", "c", "mcp"]
3+
members = ["rust", "python", "nodejs", "java", "c"]
44

55
[workspace.package]
66
version = "4.0.5"
@@ -59,12 +59,7 @@ napi = { version = "3.8.3", default-features = false }
5959
napi-derive = "3.5.2"
6060
napi-build = "2.3.1"
6161
chrono = "0.4.41"
62-
poem-mcpserver = "0.3.1"
63-
poem-mcpserver-macros = "0.3.1"
6462
poem = "3.1.12"
65-
schemars = "1.0.4"
66-
clap = "4.5.45"
67-
dotenvy = "0.15.7"
6863
jni = "0.21.1"
6964
proc-macro2 = "1.0.101"
7065
quote = "1.0.40"

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ Longbridge OpenAPI provides programmatic quote trading interfaces for investors
2323
| Go | | https://github.com/longbridge/openapi-go |
2424
| [MCP](mcp/README.md) | | An MCP server implementation for Longbridge OpenAPI |
2525

26+
27+
## Context Types
28+
29+
| Context | Description |
30+
|---------|-------------|
31+
| `QuoteContext` | Real-time quotes, candlesticks, options, warrants, watchlists, push subscriptions |
32+
| `TradeContext` | Orders, positions, account balance, executions, cash flow |
33+
| `AssetContext` | Account statement download |
34+
| `ContentContext` | News, community topics |
35+
| `FundamentalContext` | Financial reports, analyst ratings, dividends, valuation, company overview, shareholders |
36+
| `MarketContext` | Market status, broker holdings, A/H premium, trade statistics, anomaly alerts, index constituents |
37+
| `CalendarContext` | Financial calendar (earnings, dividends, splits, IPOs, macro data, market closures) |
38+
| `PortfolioContext` | Exchange rates, portfolio P&L analysis |
39+
| `AlertContext` | Price alert management (add/enable/disable/delete) |
40+
| `DCAContext` | Dollar-cost averaging plan management |
41+
| `SharelistContext` | Community sharelist management |
42+
2643
## Quickstart
2744

2845
Pick a language SDK from the table above and follow its README for install and first request. Full reference docs: https://longbridge.github.io/openapi

c/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ longbridge.workspace = true
1818
longbridge-c-macros = { path = "crates/macros" }
1919

2020
rust_decimal = { workspace = true, features = ["maths"] }
21+
serde_json.workspace = true
2122
tokio = { workspace = true, features = ["rt-multi-thread"] }
2223
parking_lot.workspace = true
2324
time.workspace = true

c/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
`longbridge` provides an easy-to-use interface for invoking [`Longbridge OpenAPI`](https://open.longbridge.com/en/).
44

5+
6+
## Context Types
7+
8+
| Context | Description |
9+
|---------|-------------|
10+
| `QuoteContext` | Real-time quotes, candlesticks, options, warrants, watchlists, push subscriptions |
11+
| `TradeContext` | Orders, positions, account balance, executions, cash flow |
12+
| `AssetContext` | Account statement download |
13+
| `ContentContext` | News, community topics |
14+
| `FundamentalContext` | Financial reports, analyst ratings, dividends, valuation, company overview, shareholders |
15+
| `MarketContext` | Market status, broker holdings, A/H premium, trade statistics, anomaly alerts, index constituents |
16+
| `CalendarContext` | Financial calendar (earnings, dividends, splits, IPOs, macro data, market closures) |
17+
| `PortfolioContext` | Exchange rates, portfolio P&L analysis |
18+
| `AlertContext` | Price alert management (add/enable/disable/delete) |
19+
| `DCAContext` | Dollar-cost averaging plan management |
20+
| `SharelistContext` | Community sharelist management |
21+
522
## Documentation
623

724
- SDK docs: https://longbridge.github.io/openapi/c/index.html

0 commit comments

Comments
 (0)