Skip to content

CMBC (Minsheng Bank) MS

About This Page

What: CMBC BST channel-side Protobuf/SRPC protocol specification + moomoo-side adaptation logic Audience: PMs understanding integration details / developers locating code / operations understanding bank characteristics Prerequisites: BST Overview, Bank Capability MatrixReading time: 8 minutes Owner: Deposit & Withdrawal Product Team

Key takeaway: CMBC uses Protobuf/SRPC protocol in Socket mode, sharing the bidirectional link architecture with CMB but with a different serialization approach.


Capability Overview

CapabilitySupportedProtocol/ChannelCore Service
BST DepositProtobuf/SRPC (SM2 National Crypto)ms_stock_bank_transaction
BST Withdrawalauto_bs automated withdrawalms_stock_bank_transaction
eDDA Authorization
eDDI Direct Debit
FPS
Deposit Statement Matching

CMBC is the second BST bank integrated by moomoo — together with CMB, they form the dual BST channel system, but use completely different protocol stacks (Protobuf/SRPC vs binary Socket).


Core Identifiers

IdentifierValueDescription
IMPORT_BANK_ID13CMBC, unique bank ID in the system
TransType101 (BST), 204 (Standard)101 for BST transfers, 204 for standard deposits
AUTO_SETTING_ID1Auto-withdrawal configuration ID
Service Namems_stock_bank_transactionCore BST service
Code Directoryms_sb_trans_python/Service code root directory

Channel Interface Overview

DimensionDescription
Protocol TypeProtobuf serialization + SRPC framework
EncryptionSM2 National Crypto Algorithm (China's commercial cryptography standard)
Data FormatProtobuf binary serialization (not JSON/XML)
Communication ModeRPC request-response (synchronous calls)
EncodingGB18030 (Chinese name fields use bytes type)
Signature AlgorithmSM2 National Crypto signature, ensuring data integrity

Protocol Difference from CMB

CMB uses a custom binary Socket protocol, while CMBC uses Google Protobuf + a proprietary SRPC framework. Both use SM2 encryption, but the serialization differs — CMB uses manual binary encoding, CMBC uses Protobuf auto-serialization. The Protobuf approach is superior in maintainability.


Channel-Side Interface Details — 9 RPC Methods

CMBC provides 9 RPC interfaces, identified by Request ID for different business operations:

Method NameRequest IDRequest / Response TypePurpose (Direction)
OpenApproval0x01OpenApprovalReq / RspAccount opening approval (CMBC → moomoo)
SyncData0x02CrmReq / CrmRspSync customer/transaction data (CMBC → moomoo)
WithDrawApproval0x03WithDrawApprovalReq / RspWithdrawal approval (CMBC → moomoo)
Reconciliate0x04ReconciliationReq / RspDaily reconciliation (CMBC → moomoo)
ChangePassword0x05ChangePasswordReq / RspChange transaction password (CMBC → moomoo)
WithDrawAck0x06WithDrawAckReq / RspWithdrawal confirmation — bank confirms receipt (CMBC → moomoo)
LoginIn0x07LoginInReq / RspTeller login (CMBC → moomoo)
LoginOut0x08LoginOutReq / RspTeller logout (CMBC → moomoo)
CreateWithdrawFutu0x09WithdrawFutuReq / RspCreate withdrawal — moomoo-initiated (moomoo → CMBC)
Method Call Flow Summary
  1. Account Opening Flow: User signs agreement at bank → Bank calls OpenApproval → moomoo approves → Returns result
  2. Deposit Flow: User initiates at bank → Bank pushes deposit data via SyncData → moomoo processes crediting
  3. Withdrawal Flow: User initiates on moomoo → CreateWithdrawFutu sends withdrawal request → Bank processes → WithDrawAck confirms
  4. Reconciliation Flow: Bank initiates daily Reconciliate → Both parties verify transaction data → Discrepancies handled manually

Core Interface Field Details

CrmReq — Data Sync Request

The request body of the SyncData method, serving as CMBC's unified entry point for pushing various business data to moomoo:

FieldTypeDescriptionNotes
datestringData dateFormat YYYYMMDD
typeReqType enumRequest type (10 types)Determines the data category being pushed

ReqType Enum — 10 Data Types

Enum ValueNameDescriptionTrigger Timing
1OPENAccount opening dataUser completes BST authorization at bank
2OPENRESAccount opening resultmoomoo approval result returned to bank
3DEPOSITDeposit dataUser initiates deposit transfer
4WITHDRAWWithdrawal dataWithdrawal request reaches bank
5WITHDRAWRESWithdrawal resultBank returns result after processing
6CLOSEAccount closure dataUser terminates BST relationship
7OPENRCAccount opening reconciliationDaily reconciliation — single account opening
8BATCHOPENRCBatch account opening reconciliationDaily reconciliation — batch account opening
9WITHDRAWRCWithdrawal reconciliationDaily reconciliation — single withdrawal
10BATCHWITHDRAWRCBatch withdrawal reconciliationDaily reconciliation — batch withdrawal

Push vs Polling

Unlike Airstar (REST API polling), CMBC uses a push model — the bank proactively pushes data to moomoo via SyncData. moomoo does not need to poll the bank's interface.

DepositItem — Deposit Data Fields

Each deposit pushed by the bank is represented as a DepositItem:

FieldTypeDescriptionValue Range/Format
TraDatstringTransaction dateYYYYMMDD
TraTimstringTransaction timeHHMMSS
RefNostringReference numberBank-side unique identifier, key for reconciliation
SDNostringBroker numberFixed value, identifies moomoo
SecAcstringSecurities accountmoomoo account (maps to CID)
CusAcstringCustomer accountBank card number
CcystringCurrencyHKD / USD (CNH not supported)
AmtstringAmountString format, e.g. "50000.00"
AcCkDtstringReconciliation dateYYYYMMDD, used during reconciliation

WithDrawItem — Withdrawal Data Fields

FieldTypeDescriptionValue Range/Format
TraDatstringTransaction dateYYYYMMDD
RefNostringReference numberBank-side unique identifier
SDNostringBroker numberFixed value
SecAcstringSecurities accountmoomoo account
CusAcstringCustomer accountBank card number
CcystringCurrencyHKD / USD
AmtstringAmountString format
AcCkDtstringReconciliation dateYYYYMMDD
SucFlgstringSuccess flagY = success / N = failure
TraTimestringTransaction timeHHMMSS

OpenApprovalReq — Account Opening Approval Request

Bank pushes account opening approval, moomoo decides whether to approve:

FieldRequiredTypeDescription
AgrNostringAgreement number. Unique identifier for BST authorization agreement
SDNostringBroker number. Fixed value
SecAcstringSecurities account. Must exist in moomoo system
CusAcstringCustomer account. Bank card number
AprStsstringApproval status. Bank-side pre-review result
RejRsnstringRejection reason. Only has value when approval fails
CusEnmstringCustomer English name. Used for name verification
CusCnmbytesCustomer Chinese name. bytes type (GB18030 encoding)

CusCnm Uses bytes Type

The Chinese name field CusCnm is bytes rather than string type. This is because Protobuf's string requires UTF-8 encoding, but CMBC transmits Chinese using GB18030 encoding — using string type would cause decoding errors. Special attention to encoding conversion is needed during development.

WithDrawApprovalReq — Withdrawal Approval Request

FieldRequiredTypeDescription
OrgRefNostringOriginal reference number. Links to original withdrawal request
SDNostringBroker number. Fixed value
SecAcstringSecurities account. moomoo account
CusAcstringCustomer account. Bank card number
CcystringCurrency. HKD / USD
AmtstringAmount. String format
AprStsstringApproval status. Approved / Rejected
RejRsnstringRejection reason. Only filled when rejected

Key Differences from CMB

CMBC and CMB both belong to the BST system, but have significant protocol and implementation differences:

DimensionCMBCMBC MS
IMPORT_BANK_ID1213
AUTO_SETTING_ID21
ProtocolCustom binary Socket protocolProtobuf/SRPC framework
SerializationManual binary encoding/decodingProtobuf auto-serialization
Encryption AlgorithmSM2 National CryptoSM2 National Crypto
CNH SupportHK bank card holders onlyNot supported at all
Processing Hours08:40 ~ 15:5908:40 ~ 15:59
Margin Hours08:40 ~ 10:5908:40 ~ 10:59
Error Code SystemSocket response codes (0/-5/-6)Protobuf error enum (2001~2006)
Reconciliation MethodDaily file reconciliationSyncData (type=7~10) push reconciliation
Service Namecmb_stock_transms_stock_bank_transaction
Code LanguagePythonPython
Interface Count9 RPC methods

One-sentence summary: CMB uses a "raw" binary protocol (flexible but hard to maintain), CMBC uses a Protobuf standard protocol (well-structured but dependent on proto file synchronization).


CNH Restriction

CMBC does not support CNH (Renminbi) currency at all. This is a hard-coded restriction at the code level:

checkCurrency() → Detects CNH → Directly rejects → Returns error code 2001 (MsBsRejRsn::LOCK_OF_CASH)
CurrencySupportedDescription
HKDFully supported
USDFully supported
CNHcheckCurrency() directly rejects

CNH Deposits Show as "Insufficient Funds"

Since the CNH rejection uses error code 2001 (LOCK_OF_CASH = insufficient funds), users may see an "insufficient funds" error message, but the actual reason is currency not supported. Operations should note this distinction when troubleshooting.

Comparison:

  • CMB: CNH limited to HK bank card holders only (conditional support)
  • Airstar: Full support for HKD / USD / CNH
  • CMBC: CNH completely unsupported

Error Code System

CMBC-Specific Error Codes (MsBsRejRsn Enum)

Error CodeEnum NameMeaningHandling
2001LOCK_OF_CASHInsufficient funds / Currency not supported. Account balance insufficient, or CNH deposit blockedNotify user to check balance/currency
2002ACCOUNT_ABNORMALAccount status abnormal. Account frozen, closed, etc.Contact CMBC to confirm account status
2003OTHER_REJECTIONOther rejection reasons. Bank-side risk control interception, etc.Manual investigation, contact bank for details
2004NSS_ISSUENSS issue. Network security subsystem errorTechnical investigation of network/certificate configuration
2005GDCA_ISSUEGDCA issue. Guangdong Digital Certificate Authority errorKYC/certificate-related investigation
2006INVALID_BANKCARDInvalid bank card. Card number incorrect, cancelled, or inactiveGuide user to re-bind card

Mapping to Generic BST Error Codes

CMBC Error CodeCorresponding Generic StatusUser-Facing Display
2001FAILED (deposit failed)"Insufficient funds, please check your bank account balance"
2002FAILED (account abnormal)"Bank account status abnormal, please contact your bank"
2003FAILED (rejected)"Bank rejected processing, please contact customer service"
2004FAILED (system error)"System error, please try again later"
2005FAILED (KYC error)"Identity verification error, please contact customer service"
2006FAILED (invalid card)"Bank card invalid, please use a different bank card"

Deposit Flow

CMBC BST Deposit Flow

CMBC deposits are bank-initiated — users initiate BST transfers from CMBC Bank App/counter to their securities account:

Deposit Time Restrictions

PeriodTime RangeAllowed Operations
Normal Trading Hours08:40 ~ 15:59Deposit + Withdrawal
Margin Deposit Hours08:40 ~ 10:59Margin-type deposits only
Non-Trading Hours16:00 ~ next day 08:39No deposit/withdrawal requests accepted

Off-Hours Deposits

Deposit requests initiated by CMBC during non-trading hours will be rejected by the moomoo side. Unlike Airstar (which queues requests until trading hours), CMBC requires users to re-initiate during trading hours.


Withdrawal Flow

Standard Withdrawal Flow

CMBC withdrawals support two modes:

ModeTrigger MethodInterfaceDescription
moomoo-initiatedUser clicks withdrawal in moomoo AppCreateWithdrawFutu (0x09)moomoo proactively calls bank interface
Bank-initiatedBank pushes withdrawal requestWithDrawApproval (0x03)CMBC pushes, moomoo approves

moomoo-Initiated Withdrawal Flow

Bank-Initiated Withdrawal Approval Flow

When a user initiates withdrawal from the CMBC bank side:

  1. Bank sends WithDrawApproval (0x03) to moomoo
  2. moomoo performs risk control checks (balance, limits, blacklist, etc.)
  3. Approved: Returns AprSts = Approved → Bank executes transfer
  4. Rejected: Returns AprSts = Rejected + RejRsn (rejection reason)

auto_bs Automated Withdrawal

CMBC withdrawals use the auto_bs automated withdrawal channel, AUTO_SETTING_ID = 1. Automated withdrawal requires all of the following conditions:

ConditionDescription
Account status normalNot frozen, not closed
Not blacklistedWithdrawal blacklist check passed
Single transaction within limitAmount within limit range
Daily circuit breaker not triggeredDaily cumulative hasn't triggered circuit breaker
Within trading hours08:40 ~ 15:59
Currency supportedHKD or USD (not CNH)

If any condition is not met, it falls through to manual approval.


Reconciliation Mechanism

Daily Reconciliation Flow

CMBC implements daily reconciliation through 4 reconciliation types in the SyncData interface:

ReqTypeReconciliation TypeDescription
7 (OPENRC)Single account opening reconciliationVerify account opening records one by one
8 (BATCHOPENRC)Batch account opening reconciliationVerify account opening records in batch
9 (WITHDRAWRC)Single withdrawal reconciliationVerify withdrawal records one by one
10 (BATCHWITHDRAWRC)Batch withdrawal reconciliationVerify withdrawal records in batch

Reconciliation Discrepancy Handling

Discrepancy TypeDescriptionHandling
Long (moomoo has, bank doesn't)moomoo has an extra transactionVerify if bank missed a push, reverse if necessary
Short (bank has, moomoo doesn't)Bank has an extra transactionVerify if moomoo missed processing, supplement if necessary
Amount mismatchSame transaction with different amountsUse bank-side as source of truth, adjust moomoo-side record
Status mismatchSame transaction with different statusesManual judgment and correction

Security & Encryption

SM2 National Crypto Algorithm

CMBC uses China's National Commercial Cryptography Standard SM2 Algorithm for communication encryption:

DimensionDescription
Algorithm TypeSM2 Elliptic Curve Public Key Cryptography
Key Length256 bits
Equivalent SecurityApproximately RSA-3072
PurposeRequest/response data encryption + Digital signature
Compliance RequirementChinese mainland banks must use National Crypto algorithms

Encryption Flow

  1. Sender: Encrypts Protobuf-serialized binary data with SM2 public key
  2. Transmission: Encrypted data transmitted via SRPC framework
  3. Receiver: Decrypts with SM2 private key, then Protobuf deserialization
  4. Signature Verification: Each request carries an SM2 digital signature, receiver verifies to ensure data integrity

Exception Scenarios

Deposit Exceptions (4 Types)

#ExceptionSymptomCause & Handling
1Deposit rejected (2001)Bank returns LOCK_OF_CASHCNH currency blocked / Insufficient balance. Confirm currency; if CNH, inform user it's not supported
2Account abnormal (2002)Bank returns ACCOUNT_ABNORMALBank card frozen/closed. Contact CMBC to confirm status
3SyncData not receivedmoomoo didn't receive deposit pushNetwork interruption/SRPC communication error. Check network connectivity, review SRPC logs
4Data decryption failedProtobuf deserialization errorSM2 key mismatch/data corruption. Check key configuration, contact bank technical team

Withdrawal Exceptions (5 Types)

#ExceptionSymptomCause & Handling
1CreateWithdrawFutu failedWithdrawal request rejected by bankParameter error/bank-side risk control. Check request parameters and error codes
2WithDrawAck not receivedNo confirmation for a long time after withdrawalBank processing delay/communication interruption. Manually query bank-side status
3Freeze not releasedFunds still frozen after withdrawal failureRelease flow error. Manually release freeze
4Approval timeoutNo response to WithDrawApprovalmoomoo approval service error. Check approval service logs
5Duplicate withdrawalSame withdrawal executed multiple timesRefNo deduplication failed. Investigate duplicates via OrgRefNo

Reconciliation Exceptions (3 Types)

#ExceptionSymptomCause & Handling
1Reconciliation data missingNo reconciliation received for a dayReconciliate call failed. Manually trigger reconciliation
2Long/Short discrepancyRecords inconsistent between partiesNetwork packet loss/processing timing difference. Manual verification and adjustment
3Batch reconciliation timeoutBATCHOPENRC/BATCHWITHDRAWRC processing slowData volume too large. Process in batches or scale up

Teller System

CMBC has an independent teller login/logout mechanism managed through LoginIn/LoginOut interfaces:

InterfaceRequest IDPurposeDescription
LoginIn0x07Teller loginBank teller logs in before operations
LoginOut0x08Teller logoutBank teller logs out after operations
Business Significance of Teller System

Some CMBC operations (such as account opening approval, withdrawal approval) require bank teller participation. Tellers must be logged in to perform approval operations, and the system logs operations after logout. This is a traditional banking system-specific flow; virtual banks like Airstar don't need this mechanism.


Password Management

The ChangePassword (0x05) interface is used for changing BST transaction passwords:

DimensionDescription
Trigger ScenarioUser requests password change at bank side
Impact ScopeAll BST operations require the new password after change
Security RequirementPassword is SM2-encrypted in transit, moomoo side does not store plaintext

Code Location & Service Deployment

DimensionDescription
Service Namems_stock_bank_transaction
Code Directoryms_sb_trans_python/
LanguagePython
Proto FileCMBC-provided .proto definition file
DependenciesSM2 National Crypto library, Protobuf runtime, SRPC framework

Key Code Modules

ModuleResponsibility
ms_sb_trans_python/handler/Request handlers for 9 RPC methods
ms_sb_trans_python/crypto/SM2 encryption/decryption and signature verification
ms_sb_trans_python/proto/Protobuf-generated message classes
ms_sb_trans_python/service/Business logic (crediting, withdrawal, reconciliation)
ms_sb_trans_python/config/Bank connection configuration, key configuration

Change Guide

Change RequirementModification LocationDescription
Add CNH supportcheckCurrency() + bank-side negotiationBank side must also support CNH, modify currency validation logic
Modify error code mappinghandler/ error handlingAdjust MsBsRejRsn to user prompt mapping
Modify processing hoursTime period validation logicSynchronize front-end and back-end time period checks
Add new RPC methodBank provides new proto → generate code → implement handlerBank side must publish proto file first
Replace SM2 keysconfig/ key configurationCoordinate key rotation time window with bank
Modify reconciliation rulesservice/reconciliation.pyAdjust discrepancy judgment thresholds or handling strategies
Modify auto-withdrawal conditionsauto_bs config + AUTO_SETTING_IDRefer to Withdrawal Rules Manual
Adjust limitsLimit configuration (SQL seed)Modify per-transaction max/alarm/circuit breaker thresholds

Common Customer Complaints Top 3

#User FeedbackCauseCS Script
1"BST withdrawal timeout"Socket connection jitter, callback code -5"Your withdrawal is being processed, the system has automatically retried, please check the result shortly"
2"Why doesn't CMBC support CNH"CMBC BST doesn't support offshore RMB"CMBC currently supports HKD and USD for deposits and withdrawals, RMB is not available at this time"
3"Withdrawal rejected by bank"Callback code -6 or insufficient balance"Please confirm your account has sufficient balance; if still rejected, please contact customer service"

Monitoring & Alerts

Key Monitoring Items

#Monitor ItemTrigger ConditionHandling
1SRPC connection interrupted (Critical)SRPC connection to CMBC disconnectedCheck network, auto-reconnect
2SM2 decryption failed (High)Received data cannot be decryptedCheck if key configuration is consistent
3Deposit failure rate spike (High)Failure count exceeds threshold in time windowInvestigate specific error code distribution
4Withdrawal confirmation timeout (High)No WithDrawAck after CreateWithdrawFutuManually query bank-side status
5Reconciliation discrepancy (Medium)Daily reconciliation finds long/shortOperations verification and handling
6Abnormal teller login (Medium)LoginIn frequency abnormal or during non-working hoursSecurity team investigation

After Reading

I want to...Go to
See the overall comparison of 3 BST banksBST Overview
Understand CMB's binary Socket protocolCMB
See Airstar's REST API approachAirstar
Look up BST error codesUnified Error Code Center
See auto-withdrawal approval conditionsWithdrawal Rules Manual
See capability comparison of all banksBank Capability Matrix
Was this page helpful?

内部业务文档 · 仅限 moomoo 团队使用