Skip to content

fix(longbridge): use native Decimal for order writes#704

Open
fanfpy wants to merge 3 commits into
TraderAlice:devfrom
fanfpy:fix/longbridge-native-decimal
Open

fix(longbridge): use native Decimal for order writes#704
fanfpy wants to merge 3 commits into
TraderAlice:devfrom
fanfpy:fix/longbridge-native-decimal

Conversation

@fanfpy

@fanfpy fanfpy commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • convert OpenAlice decimal.js values to the Longbridge SDK's native Decimal at submit/replace write boundaries
  • cover quantity, limit price, trigger price, and trailing percent without converting through JavaScript number
  • add regression tests that assert SDK Decimal class identity and exact decimal strings

Root cause

Order uses decimal.js, while Longbridge 4.0.5 N-API write options require instances of longbridge.Decimal. The previous as unknown as never casts only suppressed TypeScript errors, so the native binding failed to unwrap SubmitOrderOptions.submittedQuantity at runtime.

Verification

  • pnpm vitest run services/uta/src/domain/trading/brokers/longbridge/LongbridgeBroker.spec.ts — 71/71 passed
  • npx tsc --noEmit — passed
  • pnpm -F @traderalice/uta-broker-longbridge typecheck — passed
  • real native-binding probe — decimal.js source was not native; converted value was instanceof longbridge.Decimal; 123.4567890123456789 round-tripped exactly
  • pnpm test — environment-blocked: 3253 passed, 62 unrelated failures under Node 25.8.1 from invalid localStorage support, missing Dugite embedded Git after download timeout, and Windows symlink EPERM
  • live-paper — not run: no independently verified Longbridge paper account was available

Boundary touch

  • trading

This external contribution targets dev as a proposal per CONTRIBUTING.md.

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the luokerenx4's Team Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant