From 8cbb2b8ce8ed34976859f289d5c41bcdf592645b Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 20 May 2026 19:03:15 +0800 Subject: [PATCH] docs: document SecurityCalcIndex Greeks normalization (theta/vega/rho) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The raw API values for theta, vega, and rho in SecurityCalcIndex differ from the values displayed by the Longbridge app: - theta: raw is annualized (×252); divide by 252 for per-trading-day - vega: raw is scaled by 100; divide by 100 for per-1%-IV-change - rho: raw is scaled by 100; divide by 100 for per-1%-rate-change Adds doc comments explaining the normalization to Rust, Python, and Node.js bindings. Fixes longbridge/developers#1014. Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 1 + nodejs/index.d.ts | 82 ++++++++- nodejs/index.js | 255 ++++++++++++++++++++++++---- nodejs/src/quote/types.rs | 14 ++ python/pysrc/longbridge/openapi.pyi | 14 ++ python/src/quote/types.rs | 14 ++ rust/src/quote/types.rs | 14 ++ 7 files changed, 356 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51b4a34559..33e2a7babf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Added +- **Rust, Python, Node.js:** Document normalization formulas for `SecurityCalcIndex` Greeks fields: `theta` (divide by 252 for per-trading-day), `vega` and `rho` (divide by 100 for per-unit change). The raw API values differ from Longbridge app display values by these factors. - **Rust:** `Config::header(key, value)` builder method to inject custom headers into every HTTP request and WebSocket upgrade request. - **Rust, Python:** `ContentContext` adds three new methods: - `topic_detail(topic_id)` — get detail of a single topic. diff --git a/nodejs/index.d.ts b/nodejs/index.d.ts index 920a5052a3..d0f3746e42 100644 --- a/nodejs/index.d.ts +++ b/nodejs/index.d.ts @@ -30,6 +30,16 @@ export declare class AccountBalance { get frozenTransactionFees(): Array } +/** Asset context */ +export declare class AssetContext { + /** Create a new `AssetContext` */ + static new(config: Config): AssetContext + /** Get statement data list */ + statements(req?: GetStatementListRequest | undefined | null): Promise + /** Get statement data download URL */ + statementDownloadUrl(req: GetStatementDownloadUrlRequest): Promise +} + /** Brokers */ export declare class Brokers { toString(): string @@ -1917,11 +1927,31 @@ export declare class SecurityCalcIndex { get delta(): Decimal | null /** Gamma */ get gamma(): Decimal | null - /** Theta */ + /** + * Theta + * + * The raw value returned by the API is annualized (scaled by 252 trading + * days per year). To obtain the standard per-calendar-day theta, divide + * by 252: `theta / 252`. + */ get theta(): Decimal | null - /** Vega */ + /** + * Vega + * + * The raw value returned by the API is expressed per 1 percentage-point + * change in implied volatility (i.e. the value has been multiplied by + * 100). To obtain the standard vega (per unit change in IV), divide by + * 100: `vega / 100`. + */ get vega(): Decimal | null - /** Rho */ + /** + * Rho + * + * The raw value returned by the API is expressed per 1 percentage-point + * change in the risk-free rate (i.e. the value has been multiplied by + * 100). To obtain the standard rho (per unit change in rate), divide by + * 100: `rho / 100`. + */ get rho(): Decimal | null } @@ -2614,6 +2644,8 @@ export declare class WatchlistSecurity { get watchedPrice(): Decimal | null /** Watched time */ get watchedAt(): Date + /** Whether the security is pinned to the top of the group */ + get isPinned(): boolean } /** Candlestick adjustment type */ @@ -2908,6 +2940,34 @@ export interface GetHistoryOrdersOptions { endAt?: Date } +/** Options for getting a statement download URL */ +export interface GetStatementDownloadUrlRequest { + /** File key obtained from the list statements endpoint */ + fileKey: string +} + +/** Response for get statement download URL */ +export interface GetStatementDownloadUrlResponse { + /** Presigned download URL */ + url: string +} + +/** Options for listing statements */ +export interface GetStatementListRequest { + /** Statement type: Daily (1) or Monthly (2) */ + statementType?: StatementType + /** Start date for pagination */ + startDate?: number + /** Number of results (default 20) */ + limit?: number +} + +/** Response for get statement list */ +export interface GetStatementListResponse { + /** List of statement items */ + list: Array +} + /** Options for get today executions request */ export interface GetTodayExecutionsOptions { /** Security symbol */ @@ -3268,6 +3328,22 @@ export declare const enum SortOrderType { Descending = 1 } +/** Statement item */ +export interface StatementItem { + /** Statement date (integer, e.g. 20250301) */ + dt: number + /** File key used to request the download URL */ + fileKey: string +} + +/** Statement type enum */ +export declare const enum StatementType { + /** Daily statement */ + Daily = 1, + /** Monthly statement */ + Monthly = 2 +} + /** Options for submit order request */ export interface SubmitOrderOptions { /** Security code */ diff --git a/nodejs/index.js b/nodejs/index.js index d8c0ed6090..09086cf5bc 100644 --- a/nodejs/index.js +++ b/nodejs/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -66,7 +63,7 @@ const isMuslFromChildProcess = () => { function requireNative() { if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { try { - nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); } catch (err) { loadErrors.push(err) } @@ -78,7 +75,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-android-arm64') + const binding = require('longbridge-android-arm64') + const bindingPackageVersion = require('longbridge-android-arm64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -89,7 +91,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-android-arm-eabi') + const binding = require('longbridge-android-arm-eabi') + const bindingPackageVersion = require('longbridge-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -98,16 +105,39 @@ function requireNative() { } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./longbridge.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('longbridge-win32-x64-gnu') + const bindingPackageVersion = require('longbridge-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./longbridge.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('longbridge-win32-x64-msvc') + const binding = require('longbridge-win32-x64-msvc') + const bindingPackageVersion = require('longbridge-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } + } } else if (process.arch === 'ia32') { try { return require('./longbridge.win32-ia32-msvc.node') @@ -115,7 +145,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-win32-ia32-msvc') + const binding = require('longbridge-win32-ia32-msvc') + const bindingPackageVersion = require('longbridge-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -126,7 +161,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-win32-arm64-msvc') + const binding = require('longbridge-win32-arm64-msvc') + const bindingPackageVersion = require('longbridge-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -140,7 +180,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-darwin-universal') + const binding = require('longbridge-darwin-universal') + const bindingPackageVersion = require('longbridge-darwin-universal/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -151,7 +196,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-darwin-x64') + const binding = require('longbridge-darwin-x64') + const bindingPackageVersion = require('longbridge-darwin-x64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -162,7 +212,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-darwin-arm64') + const binding = require('longbridge-darwin-arm64') + const bindingPackageVersion = require('longbridge-darwin-arm64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -177,7 +232,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-freebsd-x64') + const binding = require('longbridge-freebsd-x64') + const bindingPackageVersion = require('longbridge-freebsd-x64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -188,7 +248,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-freebsd-arm64') + const binding = require('longbridge-freebsd-arm64') + const bindingPackageVersion = require('longbridge-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -204,7 +269,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-x64-musl') + const binding = require('longbridge-linux-x64-musl') + const bindingPackageVersion = require('longbridge-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -215,7 +285,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-x64-gnu') + const binding = require('longbridge-linux-x64-gnu') + const bindingPackageVersion = require('longbridge-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -228,7 +303,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-arm64-musl') + const binding = require('longbridge-linux-arm64-musl') + const bindingPackageVersion = require('longbridge-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -239,7 +319,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-arm64-gnu') + const binding = require('longbridge-linux-arm64-gnu') + const bindingPackageVersion = require('longbridge-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -252,7 +337,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-arm-musleabihf') + const binding = require('longbridge-linux-arm-musleabihf') + const bindingPackageVersion = require('longbridge-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -263,7 +353,46 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-arm-gnueabihf') + const binding = require('longbridge-linux-arm-gnueabihf') + const bindingPackageVersion = require('longbridge-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./longbridge.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('longbridge-linux-loong64-musl') + const bindingPackageVersion = require('longbridge-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./longbridge.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('longbridge-linux-loong64-gnu') + const bindingPackageVersion = require('longbridge-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -276,7 +405,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-riscv64-musl') + const binding = require('longbridge-linux-riscv64-musl') + const bindingPackageVersion = require('longbridge-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -287,7 +421,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-riscv64-gnu') + const binding = require('longbridge-linux-riscv64-gnu') + const bindingPackageVersion = require('longbridge-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -299,7 +438,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-ppc64-gnu') + const binding = require('longbridge-linux-ppc64-gnu') + const bindingPackageVersion = require('longbridge-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -310,7 +454,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('longbridge-linux-s390x-gnu') + const binding = require('longbridge-linux-s390x-gnu') + const bindingPackageVersion = require('longbridge-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -320,34 +469,49 @@ function requireNative() { } else if (process.platform === 'openharmony') { if (process.arch === 'arm64') { try { - return require('./longbridge.linux-arm64-ohos.node') + return require('./longbridge.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('longbridge-linux-arm64-ohos') + const binding = require('longbridge-openharmony-arm64') + const bindingPackageVersion = require('longbridge-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } } else if (process.arch === 'x64') { try { - return require('./longbridge.linux-x64-ohos.node') + return require('./longbridge.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('longbridge-linux-x64-ohos') + const binding = require('longbridge-openharmony-x64') + const bindingPackageVersion = require('longbridge-openharmony-x64/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } } else if (process.arch === 'arm') { try { - return require('./longbridge.linux-arm-ohos.node') + return require('./longbridge.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('longbridge-linux-arm-ohos') + const binding = require('longbridge-openharmony-arm') + const bindingPackageVersion = require('longbridge-openharmony-arm/package.json').version + if (bindingPackageVersion !== '0.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 0.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -362,22 +526,36 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./longbridge.wasi.cjs') + wasiBinding = require('./longbridge.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } - if (!nativeBinding) { + if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { try { - nativeBinding = require('longbridge-wasm32-wasi') + wasiBinding = require('longbridge-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + if (!wasiBindingError) { + wasiBindingError = err + } else { + wasiBindingError.cause = err + } loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { @@ -386,7 +564,12 @@ if (!nativeBinding) { `Cannot find native binding. ` + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', - { cause: loadErrors } + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, ) } throw new Error(`Failed to load native binding`) @@ -394,6 +577,7 @@ if (!nativeBinding) { module.exports = nativeBinding module.exports.AccountBalance = nativeBinding.AccountBalance +module.exports.AssetContext = nativeBinding.AssetContext module.exports.Brokers = nativeBinding.Brokers module.exports.Candlestick = nativeBinding.Candlestick module.exports.CapitalDistribution = nativeBinding.CapitalDistribution @@ -497,6 +681,7 @@ module.exports.SecuritiesUpdateMode = nativeBinding.SecuritiesUpdateMode module.exports.SecurityBoard = nativeBinding.SecurityBoard module.exports.SecurityListCategory = nativeBinding.SecurityListCategory module.exports.SortOrderType = nativeBinding.SortOrderType +module.exports.StatementType = nativeBinding.StatementType module.exports.SubType = nativeBinding.SubType module.exports.TimeInForceType = nativeBinding.TimeInForceType module.exports.TopicType = nativeBinding.TopicType diff --git a/nodejs/src/quote/types.rs b/nodejs/src/quote/types.rs index 74fcdb6c14..029901de63 100644 --- a/nodejs/src/quote/types.rs +++ b/nodejs/src/quote/types.rs @@ -1325,12 +1325,26 @@ pub struct SecurityCalcIndex { #[js(opt)] gamma: Option, /// Theta + /// + /// The raw value returned by the API is annualized (scaled by 252 trading + /// days per year). To obtain the standard per-calendar-day theta, divide + /// by 252: `theta / 252`. #[js(opt)] theta: Option, /// Vega + /// + /// The raw value returned by the API is expressed per 1 percentage-point + /// change in implied volatility (i.e. the value has been multiplied by + /// 100). To obtain the standard vega (per unit change in IV), divide by + /// 100: `vega / 100`. #[js(opt)] vega: Option, /// Rho + /// + /// The raw value returned by the API is expressed per 1 percentage-point + /// change in the risk-free rate (i.e. the value has been multiplied by + /// 100). To obtain the standard rho (per unit change in rate), divide by + /// 100: `rho / 100`. #[js(opt)] rho: Option, } diff --git a/python/pysrc/longbridge/openapi.pyi b/python/pysrc/longbridge/openapi.pyi index 01ddc78a26..e65733e974 100644 --- a/python/pysrc/longbridge/openapi.pyi +++ b/python/pysrc/longbridge/openapi.pyi @@ -2739,16 +2739,30 @@ class SecurityCalcIndex: theta: Optional[Decimal] """ Theta + + The raw value returned by the API is annualized (scaled by 252 trading + days per year). To obtain the standard per-calendar-day theta, divide + by 252: ``theta / 252``. """ vega: Optional[Decimal] """ Vega + + The raw value returned by the API is expressed per 1 percentage-point + change in implied volatility (i.e. the value has been multiplied by + 100). To obtain the standard vega (per unit change in IV), divide by + 100: ``vega / 100``. """ rho: Optional[Decimal] """ Rho + + The raw value returned by the API is expressed per 1 percentage-point + change in the risk-free rate (i.e. the value has been multiplied by + 100). To obtain the standard rho (per unit change in rate), divide by + 100: ``rho / 100``. """ class QuotePackageDetail: diff --git a/python/src/quote/types.rs b/python/src/quote/types.rs index c38da77055..a3c9de0cfe 100644 --- a/python/src/quote/types.rs +++ b/python/src/quote/types.rs @@ -1288,12 +1288,26 @@ pub(crate) struct SecurityCalcIndex { #[py(opt)] gamma: Option, /// Theta + /// + /// The raw value returned by the API is annualized (scaled by 252 trading + /// days per year). To obtain the standard per-calendar-day theta, divide + /// by 252: `theta / 252`. #[py(opt)] theta: Option, /// Vega + /// + /// The raw value returned by the API is expressed per 1 percentage-point + /// change in implied volatility (i.e. the value has been multiplied by + /// 100). To obtain the standard vega (per unit change in IV), divide by + /// 100: `vega / 100`. #[py(opt)] vega: Option, /// Rho + /// + /// The raw value returned by the API is expressed per 1 percentage-point + /// change in the risk-free rate (i.e. the value has been multiplied by + /// 100). To obtain the standard rho (per unit change in rate), divide by + /// 100: `rho / 100`. #[py(opt)] rho: Option, } diff --git a/rust/src/quote/types.rs b/rust/src/quote/types.rs index 0d028c9577..ed7fd92003 100644 --- a/rust/src/quote/types.rs +++ b/rust/src/quote/types.rs @@ -1730,10 +1730,24 @@ pub struct SecurityCalcIndex { /// Gamma pub gamma: Option, /// Theta + /// + /// The raw value returned by the API is annualized (scaled by 252 trading + /// days per year). To obtain the standard per-calendar-day theta, divide + /// by 252: `theta / 252`. pub theta: Option, /// Vega + /// + /// The raw value returned by the API is expressed per 1 percentage-point + /// change in implied volatility (i.e. the value has been multiplied by + /// 100). To obtain the standard vega (per unit change in IV), divide by + /// 100: `vega / 100`. pub vega: Option, /// Rho + /// + /// The raw value returned by the API is expressed per 1 percentage-point + /// change in the risk-free rate (i.e. the value has been multiplied by + /// 100). To obtain the standard rho (per unit change in rate), divide by + /// 100: `rho / 100`. pub rho: Option, }