Inspect the Existing Account
A Bybit request with the right signature can still target the wrong account model. A worker expecting one wallet layout may receive another layout, or request a product that is not available under the account's current configuration.
Account mode, margin mode, and product category need separate configuration. Calling all three unified hides the differences that determine which request is valid.
RestClientV5.getAccountInfo() exposes fields including unifiedMarginStatus and marginMode. Bybit documents their current meaning in account information and the linked account-status enumeration.
This example uses credentials created for Bybit testnet:
bybit-account-mode.mjs
import { RestClientV5 } from 'bybit-api';
if (!process.env.BYBIT_TESTNET_KEY || !process.env.BYBIT_TESTNET_SECRET) {
throw new Error('Set both Bybit testnet credentials');
}
const client = new RestClientV5({
testnet: true,
key: process.env.BYBIT_TESTNET_KEY,
secret: process.env.BYBIT_TESTNET_SECRET,
});
const response = await client.getAccountInfo();
if (response.retCode !== 0) throw new Error(response.retMsg);
console.log({
unifiedMarginStatus: response.result.unifiedMarginStatus,
marginMode: response.result.marginMode,
});
A production startup check should compare those values with a documented configuration supported by the application. Unknown values should become a visible compatibility failure, not an assumed default.
Separate the Configuration Fields
| Field or decision | What it selects |
|---|---|
| Account status | The account generation reported by the exchange. |
| Margin mode | The account's reported margin arrangement. |
| Product category | The product requested by a particular method, such as spot, linear, or inverse. |
Wallet accountType | The account representation requested by the wallet endpoint. |
| Position mode | How the supported derivative position slots are represented. |
The table is a list of distinct questions, not a compatibility matrix. Use the current endpoint documentation to determine valid combinations for the actual account. Do not infer a category from the presence of USDT in a balance response.
Migrate the Consumer
Save representative responses from the supported old configuration. Update wallet, order, and position consumers against responses from the new configuration, including absent or inapplicable fields. Missing data is not a zero balance.
Private streams do not necessarily initialize the whole account. Account initialization must identify the initial reads each consumer requires and how incoming updates interact with those reads.
An account upgrade is an explicit account operation. Keep it outside routine client construction so restarting a service cannot change the account model used by another worker. After an intentional migration, recheck the required reads, subscriptions, and order-request shapes before enabling that workflow.
Related articles
Continue from here