Python

Enums & Constants

Enum types and constants in Python SDK 3.3.2

This page lists the SDK's enums and constants (the page name transport-classes is a legacy name; the content is Enums). All enums are imported from ssi_sdk.enums:

from ssi_sdk.enums import OrderSide, OrderType, OrderStatus, Board, AccountType, Timeframe

from_value

Every enum that extends BaseEnum (all except Timeframe, which is a plain Enum) has a classmethod from_value(value) that converts a value to a member safely: it accepts None (returns None), an existing member, the raw value, or a name/value in any letter case; if nothing matches it returns None and does not raise.

from ssi_sdk.enums import OrderStatus

OrderStatus.from_value("ff")      # OrderStatus.FILLED
OrderStatus.from_value("unknown") # None

Timeframe has no from_value; use Timeframe("1m") or pass the string straight to methods that take an interval.

OrderSide

ValueCodeDescription
BUY"B"Buy
SELL"S"Sell

OrderType

price is required for LO and PLO; market-priced order types ignore price.

ValueCodeDescription
LO"LO"Limit Order
MTL"MTL"Market To Limit (HOSE): a market order whose unfilled part becomes a limit order
MP"MP"Market Price (HNX/UPCOM)
ATO"ATO"At The Open, matched in the opening auction
ATC"ATC"At The Close, matched in the closing auction
MOK"MOK"Match Or Kill (HNX): fill completely at once or cancel
MAK"MAK"Match And Kill (HNX): fill what is possible at once, cancel the rest
PLO"PLO"Post-close limit order, traded in the session after the closing auction

OrderStatus

ValueCodeDescription
PENDING"PD"Pending
PENDING_APPROVAL"WA"Waiting for approval
READY"RS"Ready
SENT"SD"Sent
QUEUED"QU"Queued
FILLED"FF"Fully filled
PARTIAL_FILLED"PF"Partially filled
PARTIAL_CANCELLED"FFPC"Partially filled + cancelled remainder
PENDING_MODIFY"WM"Pending modification
PENDING_CANCEL"WC"Pending cancellation
CANCELLED"CL"Cancelled
REJECTED"RJ"Rejected (by the server or the exchange)
EXPIRED"EX"Expired
PRE_SESSION"IAV"Waiting for its session
SOI"SOI"Reported by the order engine (the SDK names it after its code)
PAS"PAS"Reported by the order engine (the SDK names it after its code)
CPL"CPL"Reported by the order engine (the SDK names it after its code)
REQUESTED"RQ"Request received (FCO engine)
ERROR"ERR"Error reported by the engine

SOI, PAS and CPL have only a code and no business description in the SDK; do not infer what they mean.

Board

ValueCodeDescription
HOSE"HOSE"HOSE exchange
HNX"HNX"HNX exchange
UPCOM"UPCOM"UPCOM exchange
DERIVATIVES"DERIVATIVES"Derivatives. Only valid on the stream (subscribe_board) and master data

MarketFlagMessage.board returns the code DER for derivatives, not DERIVATIVES.

AccountType

ValueCodeDescription
EQUITY"Cash"Equity account
EQUITY_MARGIN"Margin"Margin account
DERIVATIVE"Derivative"Derivative account

Timeframe

Timeframe is a plain Enum (no from_value).

ValueCodeDescription
MINUTE_1"1m"1 minute
MINUTE_3"3m"3 minutes
MINUTE_5"5m"5 minutes
MINUTE_15"15m"15 minutes
HOUR_1"1h"1 hour
DAY_1"1d"1 day
WEEK_1"1w"1 week
MONTH_1"1M"1 month

Not every member works everywhere:

  • ALLOWED_TIMEFRAMES (same module) is the set of intervals REST accepts: 1d, 1m, 3m, 5m, 15m, 1h.
  • 1w and 1M exist in the enum, but get_ohlc_1week_historical and get_ohlc_1month_historical always raise ValidationError (code 400210); the download_ohlc_* methods raise NotImplementedError. See Services, section 3.1.
  • On the stream only tick, 1m and 5m are available (see Services, section 6.7.3).

FCOType

Conditional order type (Flexible Conditional Order).

ValueCodeDescription
GTD"gtd"Good Till Date
STOP"stop"Stop Market
STOP_LIMIT"stop_limit"Stop Limit
TRAILING_STOP"trailing_stop"Trailing Stop Market
TRAILING_STOP_LIMIT"trailing_stop_limit"Trailing Stop Limit
OCO"oco"One Cancels the Other
BULL_BEAR"bullbear"Bull Bear order

FCOOperator

Comparison operator used to trigger Stop / Stop Limit orders.

ValueCodeDescription
GREATER"greater"Greater than (>)
GREATER_OR_EQUAL"greater_or_equal"Greater than or equal (>=)
LESSER"lesser"Less than (<)
LESSER_OR_EQUAL"lesser_or_equal"Less than or equal (<=)
EQUAL"equal"Equal (=)

FCOStatus

Processing status of a conditional order. The status change history comes from get_fco_status_history (model FCOStatusHistoryItem, see Models).

ValueCodeDescription
INIT"INIT"Newly created
WAIT"WAIT"Waiting to trigger
TRI"TRI"Triggered
TRIT"TRIT"Triggered successfully
TER"TER"Terminated
FIS"FIS"Finished
WC"WC"Pending cancel
EXP"EXP"Expired
ERR"ERR"Error

Streaming enums

The SDK uses these enums to build topics and recognise messages; you usually do not need them directly.

EnumValuesDescription
StreamingMethodsubscribe, unsubscribe, ping_pong, list_subscriptionRequest method (the server compares case-insensitively)
StreamingChannelDATA, HEARTBEAT, TRADINGStream channel
StreamingTypeorderEvent, orderMatchEvent, clientPortfolioEventdata.eventType of trading events
DataTopicquote., trade., oddlot., market., indexsummary., room., put.Market data topic prefix
DataTypequote, trade, oddlot, market, room, put, indexsummaryData kind (no trailing dot)

Messages you receive: Services, section 6; models: Models: Streaming Messages.

Enums and constants elsewhere

  • ServerErrorCode (the server's application error codes) and HTTPStatus also live in ssi_sdk.enums, see Exceptions.
  • ConnectionEvent (the stream connection event; not exported at top level, import it from ssi_sdk.transport.reconnect): see Services, section 6.9.
  • Limit constants (for example MAX_CLIENT_REQUEST_ID_LENGTH = 20, MAX_BATCH_ORDERS = 20): see Models: Constants.

On this page