Skip to content

Commit 534dfe0

Browse files
hogan-yuanclaude
andauthored
feat(fundamental): add macroeconomic_indicators and macroeconomic methods (#540)
## Summary Two new methods on `FundamentalContext` across all language SDKs (Rust, Python, Node.js, Java): - `macroeconomic_indicators(country, offset, limit)` — `GET /v1/quote/macrodata` — list macroeconomic indicators; filter by country; response includes `count` (total matching) - `macroeconomic(indicator_code, start_date, end_date, offset, limit)` — `GET /v1/quote/macrodata/{indicator_code}` — historical data for a specific indicator; `start_date` / `end_date` accept `"YYYY-MM-DD"` strings; response includes `count` (total data points) ## New Types | Type | Description | |------|-------------| | `MultiLanguageText` | Localized text (English / Simplified Chinese / Traditional Chinese) | | `MacroeconomicCountry` | Country filter enum: `HongKong` / `China` / `UnitedStates` / `EuroZone` / `Japan` / `Singapore` (SDK accepts short codes, converts to full names for API) | | `MacroeconomicImportance` | Importance level: `Low=1` / `Medium=2` / `High=3` | | `MacroeconomicIndicator` | Indicator metadata (code, country, category, periodicity, importance, etc.) | | `MacroeconomicIndicatorListResponse` | `data: Vec<MacroeconomicIndicator>` + `count: i32` | | `Macroeconomic` | One historical data point (period, actual/previous/forecast/revised values, release timestamps, unit) | | `MacroeconomicResponse` | `info: MacroeconomicIndicator` + `data: Vec<Macroeconomic>` + `count: i32` | ## Fixes - `MacroeconomicIndicator.describe` / `name` / `MacroeconomicResponse.info`: handle `null` API responses without deserializing error ## Related - Go SDK: longbridge/openapi-go#99 --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 4300207 commit 534dfe0

24 files changed

Lines changed: 1076 additions & 1 deletion

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ 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.3.1] - 2026-06-12
8+
9+
### Added
10+
11+
- **All languages:** `FundamentalContext` gains `macroeconomic_indicators(country, offset, limit)` — list macroeconomic indicators via `GET /v1/quote/macrodata`; filter by country (`MacroeconomicCountry::HongKong / China / UnitedStates / EuroZone / Japan / Singapore`); response includes `count` (total matching)
12+
- **All languages:** `FundamentalContext` gains `macroeconomic(indicator_code, start_date, end_date, offset, limit)` — historical data for a specific indicator via `GET /v1/quote/macrodata/{indicator_code}`; `start_date` / `end_date` accept `"YYYY-MM-DD"` strings; response includes `count` (total data points)
13+
- New types: `MultiLanguageText`, `MacroeconomicCountry`, `MacroeconomicImportance`, `MacroeconomicIndicator`, `MacroeconomicIndicatorListResponse`, `Macroeconomic`, `MacroeconomicResponse`
14+
15+
### Fixed
16+
17+
- `MacroeconomicIndicator.describe` / `name` / `MacroeconomicResponse.info`: handle `null` responses from API without deserializing error
18+
719
## [4.3.0]
820

921
### Added

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "3"
33
members = ["rust", "python", "nodejs", "java", "c"]
44

55
[workspace.package]
6-
version = "4.3.0"
6+
version = "4.3.1"
77
edition = "2024"
88

99
[profile.release]

java/javasrc/src/main/java/com/longbridge/SdkNative.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,14 @@ public static native void fundamentalContextGetFinancialReportSnapshot(long cont
451451
Object opts,
452452
AsyncCallback callback);
453453

454+
public static native void fundamentalContextMacroeconomicIndicators(long context,
455+
Object country, Object offset, Object limit,
456+
AsyncCallback callback);
457+
458+
public static native void fundamentalContextMacroeconomic(long context,
459+
Object indicatorCode, Object startTime, Object endTime, Object offset, Object limit,
460+
AsyncCallback callback);
461+
454462
public static native void portfolioContextProfitAnalysisFlows(long context, Object opts,
455463
AsyncCallback callback);
456464

java/javasrc/src/main/java/com/longbridge/fundamental/FundamentalContext.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,24 @@ public CompletableFuture<ValuationComparisonResponse> getValuationComparison(Val
334334
SdkNative.fundamentalContextValuationComparison(raw, opts, callback);
335335
});
336336
}
337+
338+
/**
339+
* List macroeconomic indicators.
340+
* country: ISO country code string (e.g. "US", "CN", "EU"); pass null for all countries.
341+
*/
342+
public CompletableFuture<MacroeconomicIndicatorListResponse> getMacroeconomicIndicators(String country, Integer offset, Integer limit) throws OpenApiException {
343+
return AsyncCallback.executeTask((callback) -> {
344+
SdkNative.fundamentalContextMacroeconomicIndicators(raw, country, offset, limit, callback);
345+
});
346+
}
347+
348+
/**
349+
* Get historical data for a macroeconomic indicator.
350+
* startDate and endDate are date strings in "YYYY-MM-DD" format.
351+
*/
352+
public CompletableFuture<MacroeconomicResponse> getMacroeconomic(String indicatorCode, String startDate, String endDate, Integer offset, Integer limit) throws OpenApiException {
353+
return AsyncCallback.executeTask((callback) -> {
354+
SdkNative.fundamentalContextMacroeconomic(raw, indicatorCode, startDate, endDate, offset, limit, callback);
355+
});
356+
}
337357
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.longbridge.fundamental;
2+
3+
/** One historical data point for a macroeconomic indicator. */
4+
public class Macroeconomic {
5+
/** Statistical period (e.g. 2024-Q1, 2024-03). */
6+
public String period;
7+
public String releaseAt;
8+
public String actualValue;
9+
public String previousValue;
10+
public String forecastValue;
11+
public String revisedValue;
12+
public String nextReleaseAt;
13+
public MultiLanguageText unit;
14+
public MultiLanguageText unitPrefix;
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.longbridge.fundamental;
2+
3+
/** Metadata for one macroeconomic indicator. */
4+
public class MacroeconomicIndicator {
5+
/** External vendor code (input to getEconomicIndicator). */
6+
public String indicatorCode;
7+
public String sourceOrg;
8+
public String country;
9+
public MultiLanguageText name;
10+
public String adjustmentFactor;
11+
/** Release periodicity (e.g. monthly / quarterly). */
12+
public String periodicity;
13+
public String category;
14+
public MultiLanguageText describe;
15+
/** Importance — higher is more important. */
16+
public int importance;
17+
/** Start date of data coverage (unix timestamp string). */
18+
public String startDate;
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.longbridge.fundamental;
2+
3+
/** Response for {@link FundamentalContext#getMacroeconomicIndicators}. */
4+
public class MacroeconomicIndicatorListResponse {
5+
public MacroeconomicIndicator[] data;
6+
/** Total number of indicators matching the query. */
7+
public int count;
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.longbridge.fundamental;
2+
3+
/** Response for {@link FundamentalContext#getMacroeconomic}. */
4+
public class MacroeconomicResponse {
5+
public MacroeconomicIndicator info;
6+
public Macroeconomic[] data;
7+
/** Total number of historical data points. */
8+
public int count;
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.longbridge.fundamental;
2+
3+
/** Localized text in simplified Chinese, traditional Chinese, and English. */
4+
public class MultiLanguageText {
5+
public String english;
6+
public String simplifiedChinese;
7+
public String traditionalChinese;
8+
}

java/src/fundamental_context.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,69 @@ pub unsafe extern "system" fn Java_com_longbridge_SdkNative_fundamentalContextVa
262262
Ok(())
263263
})
264264
}
265+
266+
#[unsafe(no_mangle)]
267+
pub unsafe extern "system" fn Java_com_longbridge_SdkNative_fundamentalContextMacroeconomicIndicators(
268+
mut env: JNIEnv,
269+
_class: JClass,
270+
context: i64,
271+
country: JObject,
272+
offset: JObject,
273+
limit: JObject,
274+
callback: JObject,
275+
) {
276+
jni_result(&mut env, (), |env| {
277+
let context = &*(context as *const ContextObj);
278+
let country: Option<String> = FromJValue::from_jvalue(env, country.into())?;
279+
let country = country.and_then(|s| {
280+
use longbridge::fundamental::MacroeconomicCountry::*;
281+
match s.as_str() {
282+
"HK" | "Hong Kong SAR China" => Some(HongKong),
283+
"CN" | "China (Mainland)" => Some(China),
284+
"US" | "United States" => Some(UnitedStates),
285+
"EU" | "Euro Zone" => Some(EuroZone),
286+
"JP" | "Japan" => Some(Japan),
287+
"SG" | "Singapore" => Some(Singapore),
288+
_ => None,
289+
}
290+
});
291+
let offset: Option<i32> = FromJValue::from_jvalue(env, offset.into())?;
292+
let limit: Option<i32> = FromJValue::from_jvalue(env, limit.into())?;
293+
async_util::execute(env, callback, async move {
294+
Ok(context
295+
.ctx
296+
.macroeconomic_indicators(country, offset, limit)
297+
.await?)
298+
})?;
299+
Ok(())
300+
})
301+
}
302+
303+
#[unsafe(no_mangle)]
304+
pub unsafe extern "system" fn Java_com_longbridge_SdkNative_fundamentalContextMacroeconomic(
305+
mut env: JNIEnv,
306+
_class: JClass,
307+
context: i64,
308+
indicator_code: JObject,
309+
start_time: JObject,
310+
end_time: JObject,
311+
offset: JObject,
312+
limit: JObject,
313+
callback: JObject,
314+
) {
315+
jni_result(&mut env, (), |env| {
316+
let context = &*(context as *const ContextObj);
317+
let indicator_code: String = FromJValue::from_jvalue(env, indicator_code.into())?;
318+
let start_date: Option<String> = FromJValue::from_jvalue(env, start_time.into())?;
319+
let end_date: Option<String> = FromJValue::from_jvalue(env, end_time.into())?;
320+
let offset: Option<i32> = FromJValue::from_jvalue(env, offset.into())?;
321+
let limit: Option<i32> = FromJValue::from_jvalue(env, limit.into())?;
322+
async_util::execute(env, callback, async move {
323+
Ok(context
324+
.ctx
325+
.macroeconomic(indicator_code, start_date, end_date, offset, limit)
326+
.await?)
327+
})?;
328+
Ok(())
329+
})
330+
}

0 commit comments

Comments
 (0)