### Install ttech-autofollow-sdk via pip Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/autofollow/sdk.mdx Use this command to install the SDK from the specified T-Bank package index. ```bash $ pip install ttech-autofollow-sdk --index-url https://opensource.tbank.ru/api/v4/projects/240/packages/pypi/simple ``` -------------------------------- ### Example Payload with Subscription Info and Trade Data Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html This example shows a combined payload containing information about active subscriptions and details of a trade, including quantity, price, time, and instrument identifiers. ```json { "subscribeInfoResponse": { "infoSubscriptions": [ { "streamId": "streamId", "instrumentUid": "instrumentUid", "figi": "figi", "subscriptionId": "subscriptionId" }, { "streamId": "streamId", "instrumentUid": "instrumentUid", "figi": "figi", "subscriptionId": "subscriptionId" } ], "trackingId": "trackingId" }, "trade": { "quantity": "quantity", "price": { "nano": 6, "units": "units" }, "instrumentUid": "instrumentUid", "figi": "figi", "time": "2000-01-23T04:56:07.000+00:00" } } ``` -------------------------------- ### Stream Connection Payload Example Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html This is an example payload for establishing a stream connection. It includes account identifiers and ping settings. ```json { "accounts": [ "string" ], "pingSettings": { "pingDelayMs": 0 } } ``` -------------------------------- ### Portfolio Stream Response Example Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html Example of a PortfolioStreamResponse message. This structure provides information about portfolio subscriptions and current holdings. ```json { "subscriptions": { "accounts": [ { "accountId": "string", "subscriptionStatus": "PORTFOLIO_SUBSCRIPTION_STATUS_SUCCESS" } ] }, "portfolio": { "totalAmountShares": { "currency": "string", "units": "string", "nano": 0 }, "totalAmountBonds": { "currency": "string", "units": "string", "nano": 0 }, "totalAmountEtf": { "currency": "string", "units": "string", "nano": 0 }, "totalAmountCurrencies": { "currency": "string", "units": "string", "nano": 0 }, "totalAmountFutures": { "currency": "string", "units": "string", "nano": 0 } } } ``` -------------------------------- ### Order State Stream Response Example Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md This is an example of the JSON response you might receive for an order state update. It contains detailed information about the order's lifecycle. ```json { "orderState": { "orderId": "49478317886", "orderRequestId": "ec5e2892-58ca-4851-bc47-c2acf1368fde", "clientCode": "770083706834", "createdAt": "2024-07-15T07:07:17.321267Z", "executionReportStatus": "EXECUTION_REPORT_STATUS_NEW", "ticker": "POLY", "classCode": "TQBR", "lotSize": 1, "direction": "ORDER_DIRECTION_BUY", "timeInForce": "TIME_IN_FORCE_DAY", "orderType": "ORDER_TYPE_LIMIT", "accountId": "2223337448", "initialOrderPrice": { "currency": "RUB", "units": "195", "nano": 200000000 }, "orderPrice": { "currency": "RUB", "units": "195", "nano": 200000000 }, "amount": { "currency": "RUB", "units": "195", "nano": 200000000 }, "executedOrderPrice": { "currency": "RUB", "units": "195", "nano": 200000000 }, "currency": "RUB", "lotsRequested": "1", "lotsExecuted": "1", "lotsLeft": "0", "lotsCancelled": "0", "marker": "MARKER_UNKNOWN", "trades": [ { "dateTime": "2024-07-15T07:07:17.321267Z", "price": { "units": "195", "nano": 200000000 }, "quantity": "1", "tradeId": "7653265991" } ], "exchange": "MOEX", "instrumentUid": "127361c2-32ec-448c-b3ec-602166f537ea" } } ``` -------------------------------- ### Subscribe to Last Prices Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md Request and response examples for subscribing to the latest price updates for instruments. ```json { "subscribeLastPriceRequest": { "subscriptionAction": "SUBSCRIPTION_ACTION_SUBSCRIBE", "instruments": [ { "instrumentId": "962e2a95-02a9-4171-abd7-aa198dbe643a" } ] } } ``` ```json { "subscribeLastPriceResponse": { "trackingId": "9db9ee41448a36bf3526c8bd8d1a6c83", "lastPriceSubscriptions": [ { "figi": "BBG004730RP0", "subscriptionStatus": "SUBSCRIPTION_STATUS_SUCCESS", "instrumentUid": "962e2a95-02a9-4171-abd7-aa198dbe643a", "streamId": "b620cf01-0080-4e14-8937-1cdcb92201a0", "subscriptionId": "d2969818-2c02-40f2-9d87-668a9b41e9c4" } ] } } ``` ```json { "lastPrice": { "figi": "BBG004730RP0", "price": { "units": "178", "nano": 790000000 }, "time": "2023-05-16T08:49:31.085056Z", "instrumentUid": "962e2a95-02a9-4171-abd7-aa198dbe643a" } } ``` -------------------------------- ### Portfolio Stream Event Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md Example of a portfolio change event payload. ```json { "portfolio": { "totalAmountShares": { "currency": "rub", "units": "2787", "nano": 700000000 }, "totalAmountBonds": { "currency": "rub", "units": "0", "nano": 0 }, "totalAmountEtf": { "currency": "rub", "units": "11", "nano": 115000000 }, "totalAmountCurrencies": { "currency": "rub", "units": "3194", "nano": 843600000 }, "expectedYield": { "units": "9158", "nano": 160000000 }, "positions": [ { "figi": "BBG004S68473", "instrumentType": "share", "quantity": { "units": "400", "nano": 0 }, "averagePositionPrice": { "currency": "rub", "units": "3", "nano": 942567000 }, "expectedYield": { "units": "6", "nano": 352000000 }, "averagePositionPricePt": { "units": "3", "nano": 942567000 }, "currentPrice": { "currency": "rub", "units": "4", "nano": 193000000 }, "averagePositionPriceFifo": { "currency": "rub", "units": "3", "nano": 956275000 }, "quantityLots": { "units": "4", "nano": 0 }, "blocked": false, "positionUid": "427f9bcc-2cab-4561-bf94-942d4261fbb7", "instrumentUid": "2dfbc1fd-b92a-436e-b011-928c79e805f2" } ], "accountId": "*accountId", "virtualPositions": [] } } ``` -------------------------------- ### Positions Stream Requests and Responses Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/protocols/ws.mdx Examples for subscribing to position updates and receiving position change events. ```json { "accounts": [ "*accountId" ] } ``` ```json { "subscriptions": { "accounts": [ { "accountId": "*accountId", "subscriptionStatus": "POSITIONS_SUBSCRIPTION_STATUS_SUCCESS" } ] } } ``` ```json { "position": { "accountId": "*accountId", "money": [ { "availableValue": { "currency": "rub", "units": "3148", "nano": 130000000 }, "blockedValue": { "currency": "rub", "units": "0", "nano": 20000000 } } ], "securities": [ { "figi": "BBG00RPRPX12", "blocked": "0", "balance": "9", "positionUid": "eee36ccf-5f28-4419-9c29-c6465f39581a", "instrumentUid": "ade12bc5-07d9-44fe-b27a-1543e05bacfd", "exchangeBlocked": false, "instrumentType": "etf" } ], "futures": [], "options": [], "date": "2023-05-16T13:29:13.411710Z" } } ``` -------------------------------- ### Portfolio Stream Requests and Responses Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/protocols/ws.mdx Examples for subscribing to portfolio updates and receiving portfolio change events. ```json { "accounts": [ "*accountId" ] } ``` ```json { "subscriptions": { "accounts": [ { "accountId": "*accountId", "subscriptionStatus": "PORTFOLIO_SUBSCRIPTION_STATUS_SUCCESS" } ] } } ``` ```json { "portfolio": { "totalAmountShares": { "currency": "rub", "units": "2787", "nano": 700000000 }, "totalAmountBonds": { "currency": "rub", "units": "0", "nano": 0 }, "totalAmountEtf": { "currency": "rub", "units": "11", "nano": 115000000 }, "totalAmountCurrencies": { "currency": "rub", "units": "3194", "nano": 843600000 }, "expectedYield": { "units": "9158", "nano": 160000000 }, "positions": [ { "figi": "BBG004S68473", "instrumentType": "share", "quantity": { "units": "400", "nano": 0 }, "averagePositionPrice": { "currency": "rub", "units": "3", "nano": 942567000 }, "expectedYield": { "units": "6", "nano": 352000000 }, "averagePositionPricePt": { "units": "3", "nano": 942567000 }, "currentPrice": { "currency": "rub", "units": "4", "nano": 193000000 }, "averagePositionPriceFifo": { "currency": "rub", "units": "3", "nano": 956275000 }, "quantityLots": { "units": "4", "nano": 0 }, "blocked": false, "positionUid": "427f9bcc-2cab-4561-bf94-942d4261fbb7", "instrumentUid": "2dfbc1fd-b92a-436e-b011-928c79e805f2" } ], "accountId": "*accountId", "virtualPositions": [] } } ``` -------------------------------- ### Subscribe to Trading Statuses Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md Request and response examples for subscribing to instrument trading status updates. ```json { "subscribeInfoRequest": { "subscriptionAction": "SUBSCRIPTION_ACTION_SUBSCRIBE", "instruments": [ { "instrumentId": "962e2a95-02a9-4171-abd7-aa198dbe643a" } ] } } ``` ```json { "subscribeInfoResponse": { "trackingId": "ca4af996193cf5d9b3b933fa0ad61910", "infoSubscriptions": [ { "figi": "BBG004730RP0", "subscriptionStatus": "SUBSCRIPTION_STATUS_SUCCESS", "instrumentUid": "962e2a95-02a9-4171-abd7-aa198dbe643a", "streamId": "e99563dc-b8cd-4930-9a0a-7c31988c0007", "subscriptionId": "dc550001-b138-4197-9792-84f304c706c2" } ] } } ``` ```json { "tradingStatus": { "figi": "BBG004730RP0", "tradingStatus": "SECURITY_TRADING_STATUS_NORMAL_TRADING", "time": "2023-05-16T07:00:00.750460Z", "limitOrderAvailableFlag": true, "marketOrderAvailableFlag": true, "instrumentUid": "962e2a95-02a9-4171-abd7-aa198dbe643a" } } ``` -------------------------------- ### GetCandles - Get Market Candles Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/example.md Use this to retrieve market candles for a given instrument and time interval. Requires instrument ID, start and end times, and candle interval. ```json { "from": "2022-11-08T05:47:40.866Z", \ Дата начала периода запрошенных свечей "to": "2022-11-09T05:47:40.866Z", \ Дата окончания периода запрошенных свечей "interval": "CANDLE_INTERVAL_1_MIN", \ Интервал свечей "instrumentId": "BBG000000001" \ Параметр, в котором вы можете указать FIGI или instrument_uid инструмента, по которому хотите получить операции. В данном случае используем Т-Банк Вечный портфель RUB } ``` -------------------------------- ### List Certificates in JDK (Java/Kotlin) Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/intro/cases.mdx Verify that certificates have been successfully imported into the JDK's cacerts store by listing them using keytool. Check for the presence of 'russian-root' and 'russian-sub' aliases. ```bash .\keytool.exe -list -cacerts ``` -------------------------------- ### Import Root Certificate to JDK (Java/Kotlin) Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/intro/cases.mdx Use keytool to import the Russian trusted root certificate into the JDK's cacerts store. Ensure you have administrator privileges and the correct JDK bin directory. ```bash cd "C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin" ``` ```bash .\keytool.exe -import -trustcacerts -cacerts -storepass changeit -alias russian-root -file "C:\Users\Aleksey\Downloads\windows_russian_trusted_root_ca\russian_trusted_root_ca.cer" ``` -------------------------------- ### Bearer Token Authorization Example Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/protocols/restapi.md Example format for the authorization token required when making requests to the T-Invest API. ```text Bearer t.QtEo8ahkNFX4RTpbqp0u4z4GDZq27HzUp6AotJASBx7_DVqmqZMHfM2Cy7JmUjS80boI9eVg ``` -------------------------------- ### OptionsBy Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/instruments/methods.mdx Retrieves a list of options. ```APIDOC ## OptionsBy ### Description Retrieves a list of options. ### Method POST ### Endpoint /optionsBy ### Parameters #### Request Body - **request** (FilterOptionsRequest) - Required - Request object to filter options. ### Response #### Success Response (200) - **response** (OptionsResponse) - Response object containing a list of options. ### Request Example { "request": { ... } } ### Response Example { "response": { ... } } ``` -------------------------------- ### Trades Stream Response Example (Deprecated) Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md An example of a deprecated JSON response for trade stream updates. It provides details about executed trades. ```json { "orderState": { "orderId": "36042910361", "createdAt": "2023-05-16T13:27:14.682140664Z", "direction": "ORDER_DIRECTION_SELL", "figi": "BBG00RPRPX12", "trades": [ { "dateTime": "2023-05-16T13:27:13.423246Z", "price": { "units": "1", "nano": 235000000 }, "quantity": "1", "tradeId": "7653265991" } ], "accountId": "*accountId", "instrumentUid": "ade12bc5-07d9-44fe-b27a-1543e05bacfd" } } ``` -------------------------------- ### SandboxPayInRequest and SandboxPayInResponse Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/sandbox/methods.md Details for making a sandbox account top-up request and the expected response. ```APIDOC ## POST /sandbox/payin ### Description Initiates a sandbox account top-up request. ### Method POST ### Endpoint /sandbox/payin ### Request Body #### SandboxPayInRequest - **account_id** (string) - Required - Account number - **amount** (MoneyValue) - Required - The amount to top up the account in rubles ### Request Example ```json { "account_id": "string", "amount": { "currency": "string", "units": 0, "nano": 0 } } ``` ### Response #### Success Response (200) - **balance** (MoneyValue) - The current account balance #### Response Example ```json { "balance": { "currency": "string", "units": 0, "nano": 0 } } ``` ``` -------------------------------- ### Import Issuing Certificate to JDK (Java/Kotlin) Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/intro/cases.mdx Import the Russian trusted issuing certificate into the JDK's cacerts store using keytool. This step is necessary after importing the root certificate. ```bash .\keytool.exe -import -trustcacerts -cacerts -storepass changeit -alias russian-sub -file "C:\Users\Aleksey\Downloads\russian_trusted_sub_ca\russian_trusted_sub_ca.cer" ``` -------------------------------- ### Get Broker Report Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/operations/faq_operations.md Asynchronously retrieve a broker report. First, request report generation to get a task ID, then query the report using the task ID. An error is returned if generation is not complete. ```APIDOC ## POST /invest/services/operations/methods#generatebrokerreportrequest ### Description Requests the generation of a broker report. ### Method POST ### Endpoint /invest/services/operations/methods#generatebrokerreportrequest ### Request Body - **account_id** (string) - Required - The account ID for which to generate the report. ### Response #### Success Response (200) - **task_id** (string) - The ID of the task to generate the broker report. ## GET /invest/services/operations/methods#getbrokerreport ### Description Retrieves a broker report using its task ID. ### Method GET ### Endpoint /invest/services/operations/methods#getbrokerreport ### Query Parameters - **task_id** (string) - Required - The ID of the task for report generation. ### Response #### Success Response (200) - [Broker report data] #### Error Response (e.g., 400) - **message** (string) - Error message indicating report generation is not complete or an issue occurred. ``` -------------------------------- ### GetFavoriteGroupsRequest Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/instruments/methods.mdx Request to get a list of favorite groups. ```APIDOC ## GetFavoriteGroupsRequest ### Description Запрос получения списка избранных групп. ### Fields - **instrument_id** (Array of string) - Массив идентификаторов инструментов. Принимает значение `figi` или `instrument_uid`. Если в группе будет хотя бы один из инструментов массива, в ответе у группы вернется признак `containsInstrument = true`. - **excluded_group_id** (Array of string) - Массив идентификаторов групп, которые нужно исключить из ответа. ``` -------------------------------- ### POST /OpenSandboxAccount Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/sandbox/methods.md Registers a new account in the sandbox environment. ```APIDOC ## POST /OpenSandboxAccount ### Description Registers a new account in the sandbox environment. ### Method POST ### Request Body - **name** (array of strings) - Required - Name of the account ### Response #### Success Response (200) - **account_id** (string) - The ID of the newly created account ``` -------------------------------- ### GET /tinkoff.public.invest.api.contract.v1.OperationsStreamService/PortfolioStream Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html Provides a server-side stream of portfolio updates. ```APIDOC ## GET /tinkoff.public.invest.api.contract.v1.OperationsStreamService/PortfolioStream ### Description Server-side stream of portfolio updates. ### Method GET ### Endpoint /tinkoff.public.invest.api.contract.v1.OperationsStreamService/PortfolioStream ### Request Body - **v1PortfolioStreamRequest** (object) - Required - The request message for the portfolio stream. ``` -------------------------------- ### Ping Message Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md Example of a ping message used to maintain the connection. ```json { "ping": { "time": "2024-04-11T08:49:14.974035911Z", "streamId": "" } } ``` -------------------------------- ### Portfolio Subscription Payload Example Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html A JSON payload representing a portfolio subscription request and its associated data structures. ```json { "subscriptions": { "streamId": "streamId", "accounts": [ { "accountId": "accountId" }, { "accountId": "accountId" } ], "trackingId": "trackingId" }, "portfolio": { "totalAmountBonds": { "nano": 5, "currency": "currency", "units": "units" }, "totalAmountFutures": { "nano": 5, "currency": "currency", "units": "units" }, "accountId": "accountId", "totalAmountCurrencies": { "nano": 5, "currency": "currency", "units": "units" }, "totalAmountSp": { "nano": 5, "currency": "currency", "units": "units" }, "expectedYield": { "nano": 6, "units": "units" }, "positions": [ { "varMargin": { "nano": 5, "currency": "currency", "units": "units" }, "instrumentType": "instrumentType", "quantity": { "nano": 6, "units": "units" }, "averagePositionPricePt": { "nano": 6, "units": "units" }, "expectedYieldFifo": { "nano": 6, "units": "units" }, "averagePositionPriceFifo": { "nano": 5, "currency": "currency", "units": "units" }, "currentPrice": { "nano": 5, "currency": "currency", "units": "units" }, "positionUid": "positionUid", "figi": "figi", "quantityLots": { "nano": 6, "units": "units" }, "blockedLots": { "nano": 6, "units": "units" }, "averagePositionPrice": { "nano": 5, "currency": "currency", "units": "units" }, "blocked": true, "instrumentUid": "instrumentUid", "currentNkd": { "nano": 5, "currency": "currency", "units": "units" }, "expectedYield": { "nano": 6, "units": "units" } }, { "varMargin": { "nano": 5, "currency": "currency", "units": "units" }, "instrumentType": "instrumentType", "quantity": { "nano": 6, "units": "units" }, "averagePositionPricePt": { "nano": 6, "units": "units" }, "expectedYieldFifo": { "nano": 6, "units": "units" }, "averagePositionPriceFifo": { "nano": 5, "currency": "currency", "units": "units" } ``` -------------------------------- ### POST /orders/post_order_async Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/orders/async.md Метод для асинхронной отправки торгового поручения. Брокер не дожидается подтверждения от биржи, что позволяет распараллелить процессы. ```APIDOC ## POST /orders/post_order_async ### Description Отправляет торговое поручение асинхронно. Метод не дожидается подтверждения от биржи, возвращая внутренний идентификатор брокера. ### Method POST ### Parameters #### Request Body - **order_id** (string) - Required - Идентификатор ключа идемпотентности в формате UUID. ### Response #### Success Response (200) - **order_request_id** (string) - Ключ идемпотентности, переданный в запросе. - **trade_intent_id** (string) - Внутренний идентификатор брокера. ``` -------------------------------- ### Positions Stream Event Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md Example of a position change event payload. ```json { "position": { "accountId": "*accountId", "money": [ { "availableValue": { "currency": "rub", "units": "3148", "nano": 130000000 }, "blockedValue": { "currency": "rub", "units": "0", "nano": 20000000 } } ], "securities": [ { "figi": "BBG00RPRPX12", "blocked": "0", "balance": "9", "positionUid": "eee36ccf-5f28-4419-9c29-c6465f39581a", "instrumentUid": "ade12bc5-07d9-44fe-b27a-1543e05bacfd", "exchangeBlocked": false, "instrumentType": "etf" } ], "futures": [], "options": [], "date": "2023-05-16T13:29:13.411710Z" } } ``` -------------------------------- ### GetFavoritesRequest Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/instruments/methods.mdx Request to get favorite instruments. No input parameters are required. ```APIDOC ## GetFavoritesRequest ### Description Запрос списка избранных инструментов, входные параметры не требуются. ### Fields - **group_id** (string) - Уникальный идентификатор группы. ``` -------------------------------- ### Get Operations By Cursor Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/operations/methods.mdx Retrieves a paginated list of operations for an account. ```APIDOC ## POST /operations ### Description Запрос списка операций по счету с пагинацией. ### Method POST ### Endpoint /operations ### Parameters #### Request Body - **account_id** (string) - Идентификатор счета клиента, обязательный параметр. Остальные параметры опциональны. - **instrument_id** (string) - Идентификатор инструмента. Принимает значение `figi`, `instrument_uid` or `ticker + '_' + class_code`. - **from** (google.protobuf.Timestamp) - Начало периода по UTC. - **to** (google.protobuf.Timestamp) - Окончание периода по UTC. - **cursor** (string) - Идентификатор элемента, с которого начать формировать ответ. - **limit** (int32) - Лимит количества операций. По умолчанию — `100`, максимальное значение — `1000`. - **operation_types** (Array of OperationType) - Тип операции. Принимает значение из списка `OperationType`. - **state** (OperationState) - Статус запрашиваемых операций указаны в `OperationState`. - **without_commissions** (bool) - Флаг возврата комиссии. По умолчанию — `false`. - **without_trades** (bool) - Флаг получения ответа без массива сделок. - **without_overnights** (bool) - Флаг показа overnight операций. ### Response #### Success Response (200) - **has_next** (bool) - Признак, есть ли следующий элемент. - **next_cursor** (string) - Следующий курсор. - **items** (Array of OperationItem) - Список операций. ### Request Example ```json { "account_id": "string", "instrument_id": "string", "from": "2023-10-27T10:00:00Z", "to": "2023-10-27T12:00:00Z", "cursor": "string", "limit": 100, "operation_types": [ "OPERATION_TYPE_UNSPECIFIED" ], "state": "OPERATION_STATE_UNSPECIFIED", "without_commissions": false, "without_trades": false, "without_overnights": false } ``` ### Response Example ```json { "has_next": true, "next_cursor": "string", "items": [ { "cursor": "string", "broker_account_id": "string", "id": "string", "parent_operation_id": "string", "name": "string", "date": "2023-10-27T10:00:00Z", "type": "OPERATION_TYPE_UNSPECIFIED", "description": "string", "state": "OPERATION_STATE_UNSPECIFIED", "instrument_uid": "string", "figi": "string", "instrument_type": "string", "instrument_kind": "INSTRUMENT_TYPE_UNSPECIFIED", "position_uid": "string", "ticker": "string", "class_code": "string", "payment": { "currency": "string", "units": "100", "nano": 100000000 }, "price": { "currency": "string", "units": "100", "nano": 100000000 }, "commission": { "currency": "string", "units": "100", "nano": 100000000 }, "yield": { "currency": "string", "units": "100", "nano": 100000000 }, "yield_relative": { "units": "100", "nano": 100000000 }, "accrued_int": { "currency": "string", "units": "100", "nano": 100000000 }, "quantity": "100", "quantity_rest": "100", "quantity_done": "100", "cancel_date_time": "2023-10-27T10:00:00Z", "cancel_reason": "string", "trades_info": { "trades": [ { "num": "string", "date": "2023-10-27T10:00:00Z", "quantity": "100", "price": { "currency": "string", "units": "100", "nano": 100000000 }, "yield": { "currency": "string", "units": "100", "nano": 100000000 }, "yield_relative": { "units": "100", "nano": 100000000 } } ] }, "asset_uid": "string", "child_operations": [ { "cursor": "string", "broker_account_id": "string", "id": "string", "parent_operation_id": "string", "name": "string", "date": "2023-10-27T10:00:00Z", "type": "OPERATION_TYPE_UNSPECIFIED", "description": "string", "state": "OPERATION_STATE_UNSPECIFIED", "instrument_uid": "string", "figi": "string", "instrument_type": "string", "instrument_kind": "INSTRUMENT_TYPE_UNSPECIFIED", "position_uid": "string", "ticker": "string", "class_code": "string", "payment": { "currency": "string", "units": "100", "nano": 100000000 }, "price": { "currency": "string", "units": "100", "nano": 100000000 }, "commission": { "currency": "string", "units": "100", "nano": 100000000 }, "yield": { "currency": "string", "units": "100", "nano": 100000000 }, "yield_relative": { "units": "100", "nano": 100000000 }, "accrued_int": { "currency": "string", "units": "100", "nano": 100000000 }, "quantity": "100", "quantity_rest": "100", "quantity_done": "100", "cancel_date_time": "2023-10-27T10:00:00Z", "cancel_reason": "string", "trades_info": { "trades": [ { "num": "string", "date": "2023-10-27T10:00:00Z", "quantity": "100", "price": { "currency": "string", "units": "100", "nano": 100000000 }, "yield": { "currency": "string", "units": "100", "nano": 100000000 }, "yield_relative": { "units": "100", "nano": 100000000 } } ] }, "asset_uid": "string", "child_operations": [] } ] } ] } ``` ``` -------------------------------- ### Order Parameters Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html Details on parameters related to order placement and execution. ```APIDOC ## Order Parameters ### Order Direction Allowed values: * "ORDER_DIRECTION_UNSPECIFIED" * "ORDER_DIRECTION_BUY" * "ORDER_DIRECTION_SELL" ### Time In Force string * TIME_IN_FORCE_UNSPECIFIED: Значение не определено см. TIME_IN_FORCE_DAY * TIME_IN_FORCE_DAY: Заявка действует до конца торгового дня. Значение по умолчанию * TIME_IN_FORCE_FILL_AND_KILL: Если в момент выставления возможно исполнение заявки(в т.ч. частичное), заявка будет исполнена или отменена сразу после выставления * TIME_IN_FORCE_FILL_OR_KILL: Если в момент выставления возможно полное исполнение заявки, заявка будет исполнена или отменена сразу после выставления, недоступно для срочного рынка и торговли по выходным Default value: "TIME_IN_FORCE_UNSPECIFIED" Allowed values: * "TIME_IN_FORCE_UNSPECIFIED" * "TIME_IN_FORCE_DAY" * "TIME_IN_FORCE_FILL_AND_KILL" * "TIME_IN_FORCE_FILL_OR_KILL" ### Order Type string Тип заявки. * ORDER_TYPE_UNSPECIFIED: Значение не указано * ORDER_TYPE_LIMIT: Лимитная * ORDER_TYPE_MARKET: Рыночная * ORDER_TYPE_BESTPRICE: Лучшая цена Default value: "ORDER_TYPE_UNSPECIFIED" Allowed values: * "ORDER_TYPE_UNSPECIFIED" * "ORDER_TYPE_LIMIT" * "ORDER_TYPE_MARKET" * "ORDER_TYPE_BESTPRICE" ### Account ID string ### Lots Requested string format: int64 ### Lots Executed string format: int64 ### Lots Left string format: int64 ### Lots Cancelled string format: int64 ### Marker string * MARKER_UNKNOWN: не определено * MARKER_BROKER: сделки брокера * MARKER_CHAT: исполнение поручение, полученного от клиента через каналы связи * MARKER_PAPER: исполнение поручение, полученного от клиента в бумажной форме * MARKER_MARGIN: принудительное закрытие позиций * MARKER_TKBNM: сделки по управлению ликвидностью * MARKER_SHORT: сделки РЕПО по привлечению у клиентов бумаг * MARKER_SPECMM: перенос временно непокрытых позиций Default value: "MARKER_UNKNOWN" Allowed values: * "MARKER_UNKNOWN" * "MARKER_BROKER" * "MARKER_CHAT" * "MARKER_PAPER" * "MARKER_MARGIN" * "MARKER_TKBNM" * "MARKER_SHORT" * "MARKER_SPECMM" * "MARKER_PO" ``` -------------------------------- ### Candle Event Message Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/README.md Example of a candle update message received from the stream. ```json { "candle": { "figi": "BBG004730RP0", "interval": "SUBSCRIPTION_INTERVAL_ONE_MINUTE", "open": { "units": "179", "nano": 50000000 }, "high": { "units": "179", "nano": 70000000 }, "low": { "units": "178", "nano": 950000000 }, "close": { "units": "178", "nano": 950000000 }, "volume": "4279", "time": "2023-05-16T08:44:00Z", "lastTradeTs": "2023-05-16T08:44:27.432487Z", "instrumentUid": "962e2a95-02a9-4171-abd7-aa198dbe643a" } } ``` -------------------------------- ### Get My Subscriptions Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html Retrieves the current subscription status for various data streams. ```APIDOC ## GET /invest/contracts/subscriptions ### Description Retrieves the current subscription status for various data streams. ### Method GET ### Endpoint /invest/contracts/subscriptions ### Response #### Success Response (200) - **accounts** (array) - An array of client accounts. - **accountId** (string) - The account identifier. - **subscriptionStatus** (string) - The subscription result. Allowed values: `PORTFOLIO_SUBSCRIPTION_STATUS_UNSPECIFIED`, `PORTFOLIO_SUBSCRIPTION_STATUS_SUCCESS`, `PORTFOLIO_SUBSCRIPTION_STATUS_ACCOUNT_NOT_FOUND`, `PORTFOLIO_SUBSCRIPTION_STATUS_INTERNAL_ERROR`. Defaults to `PORTFOLIO_SUBSCRIPTION_STATUS_UNSPECIFIED`. #### Response Example ```json { "accounts": [ { "accountId": "some_account_id", "subscriptionStatus": "PORTFOLIO_SUBSCRIPTION_STATUS_SUCCESS" } ] } ``` ``` -------------------------------- ### PostOrder - Place a Limit Order Source: https://github.com/invest/invest-contracts/blob/master/src/md/intro/developer/example.md Use this to place a limit order for buying an instrument. Requires instrument FIGI, quantity, price, direction, account ID, order type, and an idempotency key. ```json { "figi": "BBG000000001", \ FIGI инструмента, по которому выставляется заявка. В данном случае используем Т-Банк Вечный портфель RUB "quantity": "1", \ Количество лотов инструмента "price": { \ Цена, по которой будет выставлена заявка "nano": 600000000, "units": "5" }, "direction": "ORDER_DIRECTION_BUY", \ Направление заявки, в данном случае — покупка "accountId": "XXXXXXXXXX", \ Номер счета, с которого будет выставлена заявка "orderType": "ORDER_TYPE_LIMIT", \ Тип заявки, в данном случае — лимитная "orderId": "string" \ Ключ идемпотентности } ``` -------------------------------- ### Subscription Configuration Parameters Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html Common parameters used for configuring market data subscriptions. ```APIDOC ## Subscription Configuration Parameters ### Parameters - **instrumentUid** (string) - UID of the instrument. - **streamId** (string) - Identifier of the open connection. - **subscriptionId** (string) - Subscription identifier in UUID format. - **orderBookType** (string) - Type of order book (ORDERBOOK_TYPE_UNSPECIFIED, ORDERBOOK_TYPE_EXCHANGE, ORDERBOOK_TYPE_DEALER, ORDERBOOK_TYPE_ALL). ``` -------------------------------- ### GET /invest/services/stop-orders/stoporders#getstoporders Source: https://github.com/invest/invest-contracts/blob/master/src/md/services/stop-orders/head-stoporders.md Retrieves a list of all currently active stop orders. ```APIDOC ## GET /invest/services/stop-orders/stoporders#getstoporders ### Description Returns a list of all active stop orders for the user. ### Method GET ### Endpoint /invest/services/stop-orders/stoporders#getstoporders ``` -------------------------------- ### Subscribe Candles Request Payload Source: https://github.com/invest/invest-contracts/blob/master/src/docs/ws/websock-docs/output/index.html Example payload for initiating a subscription to candle data. ```json { "subscribeCandlesRequest": { "subscriptionAction": "SUBSCRIPTION_ACTION_UNSPECIFIED", "instruments": [ { ```