Read Linear Contract Metadata
An HTX worker can read a linear-swap ticker successfully and still query the wrong account when it starts private work. Public market data does not select the account's cross or isolated workflow on behalf of the application.
The HTX tutorial documents the @siebly/htx-api clients. Spot uses a separate surface from the derivatives methods on FuturesClient. Linear swaps, coin-margined swaps, and delivery contracts also retain distinct method families.
Start with one contract and inspect its metadata before constructing an order quantity:
htx-linear-contract.mjs
import { FuturesClient } from '@siebly/htx-api';
const client = new FuturesClient();
const response = await client.getLinearSwapContractInfo({
contract_code: 'BTC-USDT',
});
if (response.status !== 'ok') throw new Error('HTX contract request failed');
console.log(response.data);
The linear contract reference describes contract size, price tick, status, and supported margin modes. A contract's volume is not automatically an amount of the base asset. Convert with the selected contract's units and validate its trading status.
Keep Cross and Isolated Paths Consistent
For the SDK's linear-swap cross-margin workflow, methods such as getLinearSwapCrossAccountInfo, getLinearSwapCrossPositions, and submitLinearSwapCrossOrder describe the same account arrangement. An isolated order path is a different choice.
Carry contract code, margin arrangement, quantity unit, and position behaviour through the connector. A successfully signed request on an incompatible account path is still an invalid operation. Do not infer these settings from the contract's display name or change them silently at startup.
Subscribe to the Matching Product
HTX WebSocket routing uses product-specific keys. For example, WS_KEY_MAP.linearSwapPublic identifies the public linear-swap connection. Private topics and account notifications must match the selected product and margin workflow.
The SDK exposes both stream handling and supported WebSocket command methods. The availability of submitLinearSwapCrossOrder on its command client does not establish that every derivatives operation has an equivalent WebSocket method. Check the installed client's method and parameter types rather than substituting a Spot command.
Preserve Identifiers and Outcomes
Keep native order and execution identifiers as strings where the API represents them that way. Converting a large identifier to a JavaScript number can destroy its uniqueness before it reaches storage.
Record the client identifier before sending an order, then associate private progress with the returned native identifier. After a disconnect, repair the affected account state and resolve unknown commands before another placement. The shared order-state article covers those decisions; HTX routing and field interpretation remain in this connector.
Related articles
Continue from here