Enums & Constants
Enum types and constants in Node.js SDK
All enums are exported from the main package:
import { OrderSide, OrderType, OrderStatus, Board, Timeframe, AccountType, DataType, FCOType, FCOOperator, FCOStatus } from '@ssi.developer/ssi-sdk';The main package also exports ALLOWED_TIMEFRAMES, StreamingMethod, StreamingChannel, StreamingType, DataTopic, HTTPStatus, ServerErrorCode, the types FCOStatusLike/FCOTypeLike/FCOOperatorLike, and the topic helpers (buildTopic, buildTopics, TOPIC_TYPES, STREAM_INTERVALS, STREAM_INTERVAL_ALL, StreamInterval). They are covered below.
OrderSide
| Value | Code | Description |
|---|---|---|
OrderSide.BUY | "B" | Buy |
OrderSide.SELL | "S" | Sell |
OrderType
| Value | Code | Description |
|---|---|---|
OrderType.ATO | "ATO" | At-The-Open order |
OrderType.ATC | "ATC" | At-The-Close order |
OrderType.LO | "LO" | Limit order |
OrderType.MTL | "MTL" | Market To Limit |
OrderType.MP | "MP" | Market order |
OrderType.MOK | "MOK" | Match Or Kill |
OrderType.MAK | "MAK" | Match And Kill |
OrderType.PLO | "PLO" | Post-lunch order |
OrderStatus
| Value | Code | Description |
|---|---|---|
OrderStatus.PENDING | "PD" | Pending |
OrderStatus.PENDING_APPROVAL | "WA" | Pending approval |
OrderStatus.READY | "RS" | Ready |
OrderStatus.SENT | "SD" | Sent |
OrderStatus.QUEUED | "QU" | Queued |
OrderStatus.FILLED | "FF" | Fully filled |
OrderStatus.PARTIAL_FILLED | "PF" | Partially filled |
OrderStatus.PARTIAL_CANCELLED | "FFPC" | Partially filled + rest cancelled |
OrderStatus.PENDING_MODIFY | "WM" | Pending modification |
OrderStatus.PENDING_CANCEL | "WC" | Pending cancellation |
OrderStatus.CANCELLED | "CL" | Cancelled |
OrderStatus.REJECTED | "RJ" | Rejected |
OrderStatus.EXPIRED | "EX" | Expired |
OrderStatus.PRE_SESSION | "IAV" | Pre-session |
OrderStatus.SOI | "SOI" | Reported by the order/FCO engines. The SDK only names it after the code and does not describe its meaning |
OrderStatus.PAS | "PAS" | Same as above |
OrderStatus.CPL | "CPL" | Same as above |
OrderStatus.REQUESTED | "RQ" | Requested |
OrderStatus.ERROR | "ERR" | Error |
Board
| Value | Code | Description |
|---|---|---|
Board.HOSE | "HOSE" | HOSE exchange |
Board.HNX | "HNX" | HNX exchange |
Board.UPCOM | "UPCOM" | UPCOM exchange |
Board.DERIVATIVES | "DERIVATIVES" | Derivatives. Only valid on the stream and master data, not on the REST data endpoints |
Timeframe
| Value | Code | Description |
|---|---|---|
Timeframe.MINUTE_1 | "1m" | 1 minute |
Timeframe.MINUTE_3 | "3m" | 3 minutes |
Timeframe.MINUTE_5 | "5m" | 5 minutes |
Timeframe.MINUTE_15 | "15m" | 15 minutes |
Timeframe.HOUR_1 | "1h" | 1 hour |
Timeframe.DAY_1 | "1d" | 1 day |
Timeframe.WEEK_1 | "1w" | 1 week |
Timeframe.MONTH_1 | "1M" | 1 month |
WEEK_1 and MONTH_1 only remain for backward compatibility: the server rejects them with error 400210. The constant ALLOWED_TIMEFRAMES (a ReadonlySet<Timeframe>) lists the timeframes the OHLC endpoint accepts: 1d, 1m, 3m, 5m, 15m, 1h.
import { ALLOWED_TIMEFRAMES, Timeframe } from '@ssi.developer/ssi-sdk';
ALLOWED_TIMEFRAMES.has(Timeframe.MINUTE_5); // true
ALLOWED_TIMEFRAMES.has(Timeframe.WEEK_1); // falseFCOType
Conditional order type (Flexible Conditional Order).
| Value | Code | Description |
|---|---|---|
FCOType.GTD | "gtd" | Good Till Date |
FCOType.STOP | "stop" | Stop Market |
FCOType.STOP_LIMIT | "stop_limit" | Stop Limit |
FCOType.TRAILING_STOP | "trailing_stop" | Trailing Stop Market |
FCOType.TRAILING_STOP_LIMIT | "trailing_stop_limit" | Trailing Stop Limit |
FCOType.OCO | "oco" | One Cancels the Other |
FCOType.BULL_BEAR | "bullbear" | Bull Bear order |
FCOOperator
Comparison operator used to trigger Stop / Stop Limit orders.
| Value | Code | Description |
|---|---|---|
FCOOperator.GREATER | "greater" | Greater than (>) |
FCOOperator.GREATER_OR_EQUAL | "greater_or_equal" | Greater than or equal (>=) |
FCOOperator.LESSER | "lesser" | Less than (<) |
FCOOperator.LESSER_OR_EQUAL | "lesser_or_equal" | Less than or equal (<=) |
FCOOperator.EQUAL | "equal" | Equal (=) |
FCOStatus
Processing status of a conditional order.
| Value | Code | Description |
|---|---|---|
FCOStatus.INIT | "INIT" | Newly created |
FCOStatus.WAIT | "WAIT" | Waiting to trigger |
FCOStatus.TRI | "TRI" | Triggered |
FCOStatus.TRIT | "TRIT" | Triggered successfully |
FCOStatus.TER | "TER" | Terminated |
FCOStatus.FIS | "FIS" | Finished |
FCOStatus.WC | "WC" | Pending cancel |
FCOStatus.EXP | "EXP" | Expired |
FCOStatus.ERR | "ERR" | Error |
*Like types
FCO parameters accept either the enum member or its string value. The types FCOTypeLike, FCOOperatorLike and FCOStatusLike are exported (type only) so you can annotate variables:
import type { FCOStatusLike } from '@ssi.developer/ssi-sdk';
const status: FCOStatusLike = 'WAIT'; // same as FCOStatus.WAITAccountType
| Value | Code | Description |
|---|---|---|
AccountType.EQUITY | "Cash" | Cash account |
AccountType.EQUITY_MARGIN | "Margin" | Margin account |
AccountType.DERIVATIVE | "Derivative" | Derivative account |
DataType
| Value | Code | Description |
|---|---|---|
DataType.QUOTE | "quote" | Bid/ask data |
DataType.TRADE | "trade" | Trade data |
DataType.ODD_LOT | "oddlot" | Odd lot |
DataType.MARKET | "market" | Market status |
DataType.ROOM | "room" | Foreign room |
DataType.PUT | "put" | Put-through |
DataType.INDEX_SUMMARY | "indexsummary" | Index summary |
Streaming Enums
StreamingMethod
Method of a message sent on the streaming channel.
| Value | Code | Description |
|---|---|---|
StreamingMethod.SUBSCRIBE | "subscribe" | Subscribe to topics |
StreamingMethod.UNSUBSCRIBE | "unsubscribe" | Unsubscribe from topics |
StreamingMethod.PING_PONG | "ping_pong" | Heartbeat |
StreamingMethod.LIST_SUBSCRIPTION | "list_subscription" | List the current subscriptions |
DataTopic
Topic prefixes of the market data channel (with the trailing dot).
| Value | Code |
|---|---|
DataTopic.QUOTE | "quote." |
DataTopic.TRADE | "trade." |
DataTopic.ODD_LOT | "oddlot." |
DataTopic.MARKET | "market." |
DataTopic.INDEX_SUMMARY | "indexsummary." |
DataTopic.ROOM | "room." |
DataTopic.PUT | "put." |
StreamingChannel
| Value | Code | Description |
|---|---|---|
StreamingChannel.DATA | "DATA" | Market data channel |
StreamingChannel.HEARTBEAT | "HEARTBEAT" | Heartbeat channel |
StreamingChannel.TRADING | "TRADING" | Trading events channel |
StreamingType
| Value | Code | Description |
|---|---|---|
StreamingType.ORDER | "orderEvent" | Order event |
StreamingType.ORDER_MATCH | "orderMatchEvent" | Order match event |
StreamingType.PORTFOLIO | "clientPortfolioEvent" | Portfolio event |
Topic helpers
Use these to build correctly formed topic strings instead of concatenating text. For subscribing see API Services, section 6.3 and section 6.7.
| Name | Description |
|---|---|
buildTopic(topicType, filter = '*', interval?) | Build one topic, for example trade.VNM@1m or trade.index.VN30. Throws ValidationError if the type, filter or interval is not accepted |
buildTopics(topicType, filters, interval?) | Build one topic per filter. An empty list throws ValidationError |
TOPIC_TYPES | Topic types the SDK accepts: trade, quote, room, put, oddlot, market, order, portfolio, trade.index, indexsummary |
STREAM_INTERVALS | Valid intervals: tick, 1m, 5m (only for trade and trade.index) |
STREAM_INTERVAL_ALL | '*', used after @ (for example trade.VN30@*) |
StreamInterval | The type 'tick' | '1m' | '5m' |
Main rules (from the source): a topic carries a single filter (*, one code, or a range A-B), and a comma-separated list is rejected. Codes are upper-cased, except for the account numbers of order/portfolio. UPCOMINDEX is rewritten to HNXUPCOMINDEX. @* is only valid for trade, quote, room, put, oddlot with one concrete index or exchange code. What the server does with @* has not been confirmed, see the caveat in section 6.7. asset.* and margin.* are not live yet, so they are not in TOPIC_TYPES.
import { buildTopic, buildTopics } from '@ssi.developer/ssi-sdk';
buildTopic('trade', 'vnm', '1m'); // "trade.VNM@1m"
buildTopic('trade.index', 'VN30'); // "trade.index.VN30"
buildTopics('quote', ['SSI', 'HPG']); // ["quote.SSI", "quote.HPG"]ServerErrorCode
Application error codes the server returns in { code, msg }. Compare them with the code property of an error (SSIError.code, which includes APIError). A few numbers are reused in different places, so some members are aliases (for example 400104 is both "OTP could not be sent" and "symbol is required"). The SDK notes that the 4010xx signature codes do not line up with the server's own error-code mapping file: trust the number.
| Group | Members (value) |
|---|---|
| Auth / account / OTP | CREDENTIAL_NOT_LINKED_TO_CLIENT (400101), TWO_FA_INFO_ERROR (400102), TWO_FA_INFO_MISSING (400103), OTP_SEND_FAILED / SYMBOL_REQUIRED (400104), PUSH_APPROVAL_CREATE_FAILED (400171), OTP_VERIFICATION_FAILED (401100), REFRESH_TOKEN_INVALID (401101), REFRESH_CLIENT_MISSING (401102), REFRESH_TOKEN_REVOKED_OR_EXPIRED (401103), REFRESH_API_KEY_GONE (401104), INVALID_API_CREDENTIAL / TOKEN_WITHOUT_OTP (401105), PUSH_APPROVAL_NOT_FOUND (401113), PUSH_APPROVAL_PENDING / SMART_OTP_PENDING (401114, arrives as HTTP 202), PUSH_APPROVAL_REJECTED (401115), PUSH_APPROVAL_FOREIGN_TRANSACTION (401116), NO_SCOPE_GRANTED (403100) |
| Request signature | SIGNATURE_MISSING (401006), SIGNATURE_BODY_EMPTY (401008), SIGNATURE_MISMATCH / SIGNATURE_INVALID (401013) |
| Trading | MODIFY_PRICE_AND_QUANTITY (400107), REPLAY_WINDOW_EXCEEDED (400111) |
| Market data validators | SYMBOL_INVALID_CHARACTERS (400006), FROM_AFTER_TO (400202), BOARD_NOT_ALLOWED (400208), TIMEFRAME_NOT_SUPPORTED (400210, also used when from/to are empty), DATE_FORMAT_INVALID (400213), INDEX_SUMMARY_NEEDS_ONE_OF (504207), SECURITIES_INFO_NEEDS_ONE_OF (504208), SECURITIES_SUMMARY_NEEDS_SYMBOL_XOR_INDEX (504209) |
import { SSIError, ServerErrorCode } from '@ssi.developer/ssi-sdk';
try {
await auth.authenticate('YOUR_OTP');
} catch (error) {
if (error instanceof SSIError && error.code === ServerErrorCode.OTP_VERIFICATION_FAILED) {
console.log('OTP verification failed');
}
}For how to handle errors see Error Handling.
Trading WebSocket constants
This part belongs to the Trading WebSocket, which is exported from the main package @ssi.developer/ssi-sdk. See API Services, section 7.
MUTATING_METHODS (a ReadonlySet<string>, exported from @ssi.developer/ssi-sdk) lists the commands the server requires a signature for. These commands need Config.privateKey; without it the client throws WebSocketError. Method names are matched case-insensitively.
| Command that is signed |
|---|
order.place |
order.amend |
order.cancel |
order.batchnew |
order.batchcancel |
fco.place |
fco.cancel |
For the TradingWSResponse type see Models, and for the options see Configuration.
HTTPStatus
Common HTTP status codes, used internally to classify API errors.
| Value | Code | Description |
|---|---|---|
HTTPStatus.OK | 200 | Success |
HTTPStatus.NO_CONTENT | 204 | Success, no content |
HTTPStatus.BAD_REQUEST | 400 | Bad request |
HTTPStatus.UNAUTHORIZED | 401 | Unauthorized |
HTTPStatus.FORBIDDEN | 403 | Forbidden |
HTTPStatus.NOT_FOUND | 404 | Not found |
HTTPStatus.UNPROCESSABLE_ENTITY | 422 | Unprocessable entity |
HTTPStatus.TOO_MANY_REQUESTS | 429 | Rate limit exceeded |
HTTPStatus.INTERNAL_SERVER_ERROR | 500 | Internal server error |
HTTPStatus.BAD_GATEWAY | 502 | Bad gateway |
HTTPStatus.SERVICE_UNAVAILABLE | 503 | Service unavailable |
HTTPStatus.GATEWAY_TIMEOUT | 504 | Gateway timeout |