Create Market order
Authorization
The WebSocket connection being used must be pre-authorized with authorization request.
Alternative request
The same operation can be performed using HTTP request.
The request creates a market order with the parameters defined in the message body for the specified portfolio.
Request
To create an order, send a message to the established WebSocket connection with the operation code create:market containing the details of this order.
- Request body
- Schema
{
"opcode": "create:market",
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"side": "buy",
"quantity": 300,
"instrument": {
"symbol": "SBER",
"exchange": "MOEX",
"instrumentGroup": "TQBR"
},
"comment": "First order",
"user": {
"portfolio": "D39004"
},
"timeInForce": "oneday",
"allowMargin": false,
"checkDuplicates": true
}
Request body parameters
authorize— Authorization of WebSocket connectioncreate:market— Creation of market ordercreate:limit— Creation of limit ordercreate:stop— Creation of stop ordercreate:stopLimit— Creation of stop limit orderupdate:market— Modification of market orderupdate:limit— Modification of limit orderupdate:stop— Modification of stop orderupdate:stopLimit— Modification of stop limit orderdelete:market— Cancelation of market orderdelete:limit— Cancelation of limit orderdelete:stop— Cancelation of stop orderdelete:stopLimit— Cancelation of stop limit orderbuysellMOEX— Moscow ExchangeSPBX— SPB Exchange- List of Moscow Exchange codes is available in table
- SPB Exchange securities always have
SPBXcode OneDay— Execute within one trading day. At the expiration of this term the unexecuted balance is withdrawnImmediateOrCancel— Execute immediately for the entire available volume of counter orders. The unexecuted balance is canceledFillOrKill— Execute immediately for the whole specified volume without a balance. If execution without a balance is impossible — the order is canceledAtTheClose— Execution at market price prevailing at the moment of market close. Available only for SPBX (automatically converted tofillorkillon MOEX) and applicable only to market orders, as the order price depends on the market price at execution timeGoodTillCancelled— Execute within the maximum available period supported by the exchange. For example, within one year for MOEX. Futures market onlyBookOrCancel— Passive order. Will be placed on the exchange only if its price or spread value is worse than similar indicators of counter orders- for any placement or modification of exchange orders on the derivatives market, including closing previously opened positions;
- for placement or modification of exchange orders on the equity and currency markets if it results in opening a new uncovered position or increasing the deficit on an existing one;
- for placement or modification of conditional orders on any market.
- the client has been assigned a different risk level;
- the 100% collateral service is enabled.
Operation code:
Example: authorize
Unique request identifier. All response messages related to the request will have the same identifier value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Transaction side:
Example: buy
Number of lots
Example: 300
instrument
object
Security data
Security code (ticker)
Example: SBER
Exchange code:
Example: MOEX
Trading mode code (Board):
Example: true
Custom order comment. Maximum comment length is limited by 100 characters
Example: First order
user
object
User data
Client portfolio ID
Example: D39004
Order placement condition considering the possibility of its execution:
Example: OneDay
Flag confirming the consent of a client with the initial risk level to place or modify an order whose execution may create or increase an uncovered position.
The flag is not carried over between requests — each request that requires confirmation must include its own allowMargin: true flag.
Must be true:
May be false or omitted if:
Example: false
Flag for checking the uniqueness of commands. It is enabled by default, preventing spamming with similar commands. When disabled, speeds up request processing.
Example: true
Responses
According to the results of processing the received request, the server will return a message with the corresponding code to the WebSocket connection.
Messages
- 200
- 400
Successful request processing report
- Body
- Schema
{
"requestGuid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"httpCode": 200,
"message": "An order '12345' has been created.",
"orderNumber": "12345"
}
Response body parameters
Unique request identifier. The value is the guid parameter specified in the request body
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Response HTTP code
Example: 200
Text description of the returned HTTP code
Example: An order '12345' has been created.
Unique order ID
Example: 12345
Failed to process the request. Check the validity of the transmitted message and try again.
- Body
- Schema
{
"requestGuid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"httpCode": 400,
"message": "Invalid or unsupported quantity"
}
Response body parameters
Unique request identifier. The value is the guid parameter specified in the request body
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Response HTTP code
Example: 400
Text description of the returned HTTP code
Example: Invalid or unsupported quantity