Skip to content

Commit 3c995f5

Browse files
huacnleecodex
andauthored
fix: align market trade status codes (#547)
## Summary - Align Rust market TradeStatus codes with the phase/status definition, including code 2001. - Correct display names for status codes 123, 1009, and 1010 while keeping existing Rust variant names compatible. - Refresh SDK comments/generated bindings for market trade status fields. ## Test Plan - cargo +nightly fmt --all -- --check - cargo test -p longbridge market_trade_status_ --lib - RUSTC_WRAPPER= cargo clippy --all --all-features - PATH=/opt/homebrew/bin:/usr/local/bin:$PATH RUSTC_WRAPPER= npm run build:debug - RUSTC_WRAPPER= cargo build -p longbridge-c Co-authored-by: Codex <codex@openai.com>
1 parent 1dac793 commit 3c995f5

9 files changed

Lines changed: 108 additions & 66 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010

1111
- **Rust:** `market::TradeStatus` models `/v1/quote/market-status` trade status codes, including engine-compatible normalization and display helpers.
12+
13+
### Fixed
14+
15+
- **All languages:** corrected market trade status documentation and aligned `market::TradeStatus` with the status definition table, including code `2001` and the `123`/`1009`/`1010` display names.
16+
1217
## [4.3.2] - 2026-06-13
1318

1419
### Added

c/csrc/include/longbridge.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,15 +4575,16 @@ typedef struct lb_market_time_item_t {
45754575
*/
45764576
enum lb_market_t market;
45774577
/**
4578-
* Current trade status code for the market.
4578+
* Current market trade status code. See the market status definition for
4579+
* the complete code table.
45794580
*/
45804581
int32_t trade_status;
45814582
/**
45824583
* Timestamp of the current trade status as an ISO-8601 string.
45834584
*/
45844585
const char *timestamp;
45854586
/**
4586-
* Delayed trade status code for the market.
4587+
* Delayed market trade status code.
45874588
*/
45884589
int32_t delay_trade_status;
45894590
/**

c/src/market_context/types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ use crate::types::{CMarket, CString, CVec, ToFFI};
1818
pub struct CMarketTimeItem {
1919
/// Market identifier.
2020
pub market: CMarket,
21-
/// Current trade status code for the market.
21+
/// Current market trade status code. See the market status definition for
22+
/// the complete code table.
2223
pub trade_status: i32,
2324
/// Timestamp of the current trade status as an ISO-8601 string.
2425
pub timestamp: *const c_char,
25-
/// Delayed trade status code for the market.
26+
/// Delayed market trade status code.
2627
pub delay_trade_status: i32,
2728
/// Timestamp of the delayed trade status as an ISO-8601 string.
2829
pub delay_timestamp: *const c_char,

java/javasrc/src/main/java/com/longbridge/market/MarketTimeItem.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ public class MarketTimeItem {
55
/** Market. */
66
public com.longbridge.Market market;
77
/**
8-
* Raw trade status code.
9-
* 101=PreOpen, 102/103/105=Trading, 104=LunchBreak, 106=PostTrading,
10-
* 108=Closed, 201=PreMarket, 204=PostMarket.
8+
* Raw market trade status code.
9+
* See the market status definition for the complete code table.
1110
*/
1211
public int tradeStatus;
1312
/** Current market time (unix timestamp string). */
1413
public String timestamp;
15-
/** Delayed-quote trade status code. */
14+
/** Delayed-quote market trade status code. */
1615
public int delayTradeStatus;
1716
/** Delayed-quote market time (unix timestamp string). */
1817
public String delayTimestamp;
1918
/** Sub-status code. */
2019
public int subStatus;
2120
/** Delayed-quote sub-status code. */
2221
public int delaySubStatus;
23-
}
22+
}

nodejs/index.d.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,9 @@ export declare class FundamentalContext {
619619
*/
620620
etfAssetAllocation(symbol: string): Promise<AssetAllocationResponse>
621621
/** List macroeconomic indicators */
622-
macroeconomicIndicators(country?: MacroeconomicCountry | undefined | null, offset?: number | undefined | null, limit?: number | undefined | null): Promise<MacroeconomicIndicatorListResponse>
622+
macroeconomicIndicators(country?: MacroeconomicCountry | undefined | null, keyword?: string | undefined | null, offset?: number | undefined | null, limit?: number | undefined | null): Promise<MacroeconomicIndicatorListResponse>
623623
/** Get historical data for a macroeconomic indicator */
624624
macroeconomic(indicatorCode: string, startDate?: string | undefined | null, endDate?: string | undefined | null, offset?: number | undefined | null, limit?: number | undefined | null): Promise<MacroeconomicResponse>
625-
/** List macroeconomic indicators (v2) with optional keyword filter */
626-
macroeconomicIndicatorsV2(country?: MacroeconomicCountry | undefined | null, keyword?: string | undefined | null, offset?: number | undefined | null, limit?: number | undefined | null): Promise<MacroeconomicIndicatorListResponse>
627-
/** Get historical data for a macroeconomic indicator (v2) with sort support */
628-
macroeconomicV2(indicatorCode: string, startDate?: string | undefined | null, endDate?: string | undefined | null, offset?: number | undefined | null, limit?: number | undefined | null, sort?: string | undefined | null): Promise<MacroeconomicResponse>
629625
}
630626

631627
/** Fund position */
@@ -4566,13 +4562,13 @@ export interface MarketTimeItem {
45664562
/** Market */
45674563
market: Market
45684564
/**
4569-
* Raw trade status code (101=PreOpen, 102/103/105=Trading, 104=LunchBreak,
4570-
* 106=PostTrading, 108=Closed, 201=PreMarket, 204=PostMarket)
4565+
* Raw market trade status code. See the market status definition for the
4566+
* complete code table.
45714567
*/
45724568
tradeStatus: number
45734569
/** Current market time (unix timestamp string) */
45744570
timestamp: string
4575-
/** Delayed-quote trade status code */
4571+
/** Delayed-quote market trade status code */
45764572
delayTradeStatus: number
45774573
/** Delayed-quote market time (unix timestamp string) */
45784574
delayTimestamp: string

nodejs/src/market/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ impl From<lb::MarketStatusResponse> for MarketStatusResponse {
2222
pub struct MarketTimeItem {
2323
/// Market
2424
pub market: crate::types::Market,
25-
/// Raw trade status code (101=PreOpen, 102/103/105=Trading, 104=LunchBreak,
26-
/// 106=PostTrading, 108=Closed, 201=PreMarket, 204=PostMarket)
25+
/// Raw market trade status code. See the market status definition for the
26+
/// complete code table.
2727
pub trade_status: i32,
2828
/// Current market time (unix timestamp string)
2929
pub timestamp: String,
30-
/// Delayed-quote trade status code
30+
/// Delayed-quote market trade status code
3131
pub delay_trade_status: i32,
3232
/// Delayed-quote market time (unix timestamp string)
3333
pub delay_timestamp: String,

python/pysrc/longbridge/openapi.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10159,11 +10159,11 @@ class MarketTimeItem:
1015910159
market: Market
1016010160
"""Market"""
1016110161
trade_status: int
10162-
"""Raw trade status code (101=PreOpen, 102/105=Trading, 104=LunchBreak, 106=PostTrading, 108=Closed, 201=PreMarket, 204=PostMarket)"""
10162+
"""Raw market trade status code. See the market status definition for the complete code table."""
1016310163
timestamp: str
1016410164
"""Current market time (unix timestamp string)"""
1016510165
delay_trade_status: int
10166-
"""Delayed-quote trade status code"""
10166+
"""Delayed-quote market trade status code"""
1016710167
delay_timestamp: str
1016810168
"""Delayed-quote market time (unix timestamp string)"""
1016910169
sub_status: int

python/src/market/types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,12 @@ impl From<lb::MarketStatusResponse> for MarketStatusResponse {
217217
pub(crate) struct MarketTimeItem {
218218
/// Market
219219
pub market: crate::types::Market,
220-
/// Raw trade status code
220+
/// Raw market trade status code. See the market status definition for the
221+
/// complete code table.
221222
pub trade_status: i32,
222223
/// Current market time (unix timestamp string)
223224
pub timestamp: String,
224-
/// Delayed-quote trade status code
225+
/// Delayed-quote market trade status code
225226
pub delay_trade_status: i32,
226227
/// Delayed-quote time (unix timestamp string)
227228
pub delay_timestamp: String,

rust/src/market/types.rs

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,76 +35,81 @@ pub enum TradeStatus {
3535
UNKNOWN = -1,
3636
/// Quote is not registered
3737
NO_REGISTER_QUOTE = 0,
38-
/// Clearing
38+
/// Clearing before the market opens.
3939
CLEAN = 101,
40-
/// Opening auction
40+
/// Opening auction.
4141
OPEN_BID = 102,
42-
/// Morning break, currently used by VIX indexes
42+
/// Morning break, currently used by VIX indexes.
4343
MORNING_CLOSING = 103,
44-
/// Trading
44+
/// Regular trading.
4545
TRADING = 105,
46-
/// Midday break
46+
/// Midday break.
4747
NOON_CLOSING = 106,
48-
/// Closing auction
48+
/// Closing auction.
4949
CLOSE_BID = 107,
50-
/// Closed
50+
/// Market closed.
5151
CLOSING = 108,
52-
/// Dark pool waiting to open
52+
/// Dark trading waiting to open.
5353
DARK_WAIT = 110,
54-
/// Dark pool trading
54+
/// Dark trading.
5555
DARK_TRADING = 111,
56-
/// Dark pool closed
56+
/// Dark trading closed.
5757
DARK_CLOSING = 112,
58-
/// After-hours fixed-price trading
58+
/// After-hours fixed-price trading.
5959
AFTER_FIX = 120,
60-
/// Half-day market closed
60+
/// Half-day market closed. Defined by the market status table but currently
61+
/// unused.
6162
HALF_CLOSING = 121,
62-
/// Not opened
63+
/// Not opened because the exchange is waiting to open under special
64+
/// conditions.
6365
NOT_OPENED = 122,
64-
/// Realtime quotes
66+
/// Temporary intraday break. The historical variant name is kept for
67+
/// compatibility.
6568
REALTIME_QUOTE = 123,
66-
/// US pre-market
69+
/// US pre-market.
6770
US_PREV = 201,
68-
/// US regular trading
71+
/// US regular trading.
6972
US_TRADING = 202,
70-
/// US post-market
73+
/// US post-market.
7174
US_AFTER = 203,
72-
/// US closed
75+
/// US closed.
7376
US_CLOSING = 204,
74-
/// US halted
77+
/// US halted.
7578
US_STOP = 205,
76-
/// US clearing before pre-market
79+
/// US clearing plus pre-market.
7780
US_CLEAN = 206,
78-
/// US overnight trading
81+
/// US overnight trading.
7982
US_NIGHT = 207,
80-
/// US pre-market clearing
83+
/// US pre-market clearing alias returned by the quote engine.
8184
US_PREV_MARKET_CLEAN = 209,
82-
/// US post-market clearing
85+
/// US post-market clearing alias returned by the quote engine.
8386
US_AFTER_MARKET_CLEAN = 210,
84-
/// Stock refresh
87+
/// Stock refresh. Deprecated in the status definition.
8588
REFRESH = 1000,
86-
/// Delisted
89+
/// Delisted.
8790
DELIST = 1001,
88-
/// Preparing to list
91+
/// Preparing to list.
8992
PREPARE = 1002,
90-
/// Code changed
93+
/// Code changed.
9194
CODE_CHANGE = 1003,
92-
/// Halted
95+
/// Halted.
9396
STOP = 1004,
94-
/// Waiting to open
97+
/// Waiting to open, typically for a US IPO auction.
9598
WILL_OPEN = 1005,
96-
/// Split or merge suspended
99+
/// Split or merge suspended.
97100
COMMON_SUSPEND = 1006,
98-
/// Expired
101+
/// Expired.
99102
EXPIRE = 1007,
100-
/// No quote
103+
/// No quote data.
101104
NO_QUOTE = 1008,
102-
/// Not listed
105+
/// Not listed. The historical variant name is kept for compatibility.
103106
UNITED = 1009,
104-
/// Trading halted
107+
/// Terminated trading, usually for warrants.
105108
TRADING_HALT = 1010,
106-
/// Waiting to list
109+
/// Waiting to list, usually for new warrants.
107110
WAIT_LISTING = 1011,
111+
/// Fuse.
112+
FUSE = 2001,
108113
}
109114

110115
impl From<i32> for TradeStatus {
@@ -165,7 +170,7 @@ impl TradeStatus {
165170
TradeStatus::DARK_CLOSING => "Closing",
166171
TradeStatus::AFTER_FIX => "After Fix",
167172
TradeStatus::NOT_OPENED => "Not Open",
168-
TradeStatus::REALTIME_QUOTE => "Realtime Quotes",
173+
TradeStatus::REALTIME_QUOTE => "Temporary Break",
169174
TradeStatus::US_PREV | TradeStatus::US_CLEAN => "Pre-Market",
170175
TradeStatus::US_AFTER => "Post-Market",
171176
TradeStatus::US_STOP | TradeStatus::STOP => "Stop",
@@ -178,9 +183,10 @@ impl TradeStatus {
178183
TradeStatus::COMMON_SUSPEND => "Common Suspend",
179184
TradeStatus::EXPIRE => "Expire",
180185
TradeStatus::NO_QUOTE => "No Quote",
181-
TradeStatus::UNITED => "United",
182-
TradeStatus::TRADING_HALT => "Trading Halt",
186+
TradeStatus::UNITED => "Not Listed",
187+
TradeStatus::TRADING_HALT => "Terminated",
183188
TradeStatus::WAIT_LISTING => "Wait Listing",
189+
TradeStatus::FUSE => "Fuse",
184190
}
185191
}
186192

@@ -288,11 +294,12 @@ pub struct MarketStatusResponse {
288294
pub struct MarketTimeItem {
289295
/// Market code
290296
pub market: Market,
291-
/// Trade status
297+
/// Market trade status. See [`TradeStatus`] for the code table.
292298
pub trade_status: TradeStatus,
293299
/// Current market time (unix timestamp string)
294300
pub timestamp: String,
295-
/// Delayed-quote trade status
301+
/// Delayed-quote market trade status. See [`TradeStatus`] for the code
302+
/// table.
296303
pub delay_trade_status: TradeStatus,
297304
/// Delayed-quote market time (unix timestamp string)
298305
pub delay_timestamp: String,
@@ -360,10 +367,11 @@ mod tests {
360367
let cases = [
361368
(TradeStatus::MORNING_CLOSING, "Morning Break"),
362369
(TradeStatus::NOON_CLOSING, "Mid-Day Break"),
363-
(TradeStatus::REALTIME_QUOTE, "Realtime Quotes"),
370+
(TradeStatus::REALTIME_QUOTE, "Temporary Break"),
364371
(TradeStatus::US_STOP, "Stop"),
365-
(TradeStatus::TRADING_HALT, "Trading Halt"),
372+
(TradeStatus::TRADING_HALT, "Terminated"),
366373
(TradeStatus::WAIT_LISTING, "Wait Listing"),
374+
(TradeStatus::FUSE, "Fuse"),
367375
(TradeStatus::UNKNOWN, "Unknown"),
368376
(TradeStatus::NO_REGISTER_QUOTE, "Unknown"),
369377
];
@@ -373,6 +381,37 @@ mod tests {
373381
}
374382
}
375383

384+
#[test]
385+
fn market_trade_status_codes_match_phase_definition_document() {
386+
let codes = [
387+
101, 102, 103, 105, 106, 107, 108, 110, 111, 112, 120, 121, 122, 123, 201, 202, 203,
388+
204, 206, 207, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011,
389+
2001,
390+
];
391+
392+
for code in codes {
393+
assert_eq!(TradeStatus::from(code).code(), code, "status code {code}");
394+
}
395+
}
396+
397+
#[test]
398+
fn market_trade_status_names_match_phase_definition_document() {
399+
let cases = [
400+
(123, "Temporary Break"),
401+
(1009, "Not Listed"),
402+
(1010, "Terminated"),
403+
(2001, "Fuse"),
404+
];
405+
406+
for (code, expected) in cases {
407+
assert_eq!(
408+
TradeStatus::from(code).name(),
409+
expected,
410+
"status code {code}"
411+
);
412+
}
413+
}
414+
376415
#[test]
377416
fn market_time_item_uses_market_trade_status_type() {
378417
let item = serde_json::from_str::<crate::market::MarketTimeItem>(

0 commit comments

Comments
 (0)