UNPKG

tinkoff-invest-api

Version:
1,190 lines (1,189 loc) 62.3 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StopOrdersServiceDefinition = exports.StopOrder_TrailingData = exports.StopOrder = exports.CancelStopOrderResponse = exports.CancelStopOrderRequest = exports.GetStopOrdersResponse = exports.GetStopOrdersRequest = exports.PostStopOrderResponse = exports.PostStopOrderRequest_TrailingData = exports.PostStopOrderRequest = exports.trailingStopStatusToJSON = exports.trailingStopStatusFromJSON = exports.TrailingStopStatus = exports.trailingValueTypeToJSON = exports.trailingValueTypeFromJSON = exports.TrailingValueType = exports.takeProfitTypeToJSON = exports.takeProfitTypeFromJSON = exports.TakeProfitType = exports.exchangeOrderTypeToJSON = exports.exchangeOrderTypeFromJSON = exports.ExchangeOrderType = exports.stopOrderStatusOptionToJSON = exports.stopOrderStatusOptionFromJSON = exports.StopOrderStatusOption = exports.stopOrderTypeToJSON = exports.stopOrderTypeFromJSON = exports.StopOrderType = exports.stopOrderExpirationTypeToJSON = exports.stopOrderExpirationTypeFromJSON = exports.StopOrderExpirationType = exports.stopOrderDirectionToJSON = exports.stopOrderDirectionFromJSON = exports.StopOrderDirection = exports.protobufPackage = void 0; /* eslint-disable */ const long_1 = __importDefault(require("long")); const minimal_js_1 = __importDefault(require("protobufjs/minimal.js")); const common_js_1 = require("./common.js"); const timestamp_js_1 = require("./google/protobuf/timestamp.js"); exports.protobufPackage = "tinkoff.public.invest.api.contract.v1"; /** Направление сделки стоп-заявки. */ var StopOrderDirection; (function (StopOrderDirection) { /** STOP_ORDER_DIRECTION_UNSPECIFIED - Значение не указано. */ StopOrderDirection[StopOrderDirection["STOP_ORDER_DIRECTION_UNSPECIFIED"] = 0] = "STOP_ORDER_DIRECTION_UNSPECIFIED"; /** STOP_ORDER_DIRECTION_BUY - Покупка. */ StopOrderDirection[StopOrderDirection["STOP_ORDER_DIRECTION_BUY"] = 1] = "STOP_ORDER_DIRECTION_BUY"; /** STOP_ORDER_DIRECTION_SELL - Продажа. */ StopOrderDirection[StopOrderDirection["STOP_ORDER_DIRECTION_SELL"] = 2] = "STOP_ORDER_DIRECTION_SELL"; StopOrderDirection[StopOrderDirection["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(StopOrderDirection || (exports.StopOrderDirection = StopOrderDirection = {})); function stopOrderDirectionFromJSON(object) { switch (object) { case 0: case "STOP_ORDER_DIRECTION_UNSPECIFIED": return StopOrderDirection.STOP_ORDER_DIRECTION_UNSPECIFIED; case 1: case "STOP_ORDER_DIRECTION_BUY": return StopOrderDirection.STOP_ORDER_DIRECTION_BUY; case 2: case "STOP_ORDER_DIRECTION_SELL": return StopOrderDirection.STOP_ORDER_DIRECTION_SELL; case -1: case "UNRECOGNIZED": default: return StopOrderDirection.UNRECOGNIZED; } } exports.stopOrderDirectionFromJSON = stopOrderDirectionFromJSON; function stopOrderDirectionToJSON(object) { switch (object) { case StopOrderDirection.STOP_ORDER_DIRECTION_UNSPECIFIED: return "STOP_ORDER_DIRECTION_UNSPECIFIED"; case StopOrderDirection.STOP_ORDER_DIRECTION_BUY: return "STOP_ORDER_DIRECTION_BUY"; case StopOrderDirection.STOP_ORDER_DIRECTION_SELL: return "STOP_ORDER_DIRECTION_SELL"; case StopOrderDirection.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.stopOrderDirectionToJSON = stopOrderDirectionToJSON; /** Тип экспирации стоп-заявке. */ var StopOrderExpirationType; (function (StopOrderExpirationType) { /** STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED - Значение не указано. */ StopOrderExpirationType[StopOrderExpirationType["STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED"] = 0] = "STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED"; /** STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL - Действительно до отмены. */ StopOrderExpirationType[StopOrderExpirationType["STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL"] = 1] = "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL"; /** STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE - Действительно до даты снятия. */ StopOrderExpirationType[StopOrderExpirationType["STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE"] = 2] = "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE"; StopOrderExpirationType[StopOrderExpirationType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(StopOrderExpirationType || (exports.StopOrderExpirationType = StopOrderExpirationType = {})); function stopOrderExpirationTypeFromJSON(object) { switch (object) { case 0: case "STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED": return StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED; case 1: case "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL": return StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL; case 2: case "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE": return StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE; case -1: case "UNRECOGNIZED": default: return StopOrderExpirationType.UNRECOGNIZED; } } exports.stopOrderExpirationTypeFromJSON = stopOrderExpirationTypeFromJSON; function stopOrderExpirationTypeToJSON(object) { switch (object) { case StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED: return "STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED"; case StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL: return "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL"; case StopOrderExpirationType.STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE: return "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE"; case StopOrderExpirationType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.stopOrderExpirationTypeToJSON = stopOrderExpirationTypeToJSON; /** Тип стоп-заявки. */ var StopOrderType; (function (StopOrderType) { /** STOP_ORDER_TYPE_UNSPECIFIED - Значение не указано. */ StopOrderType[StopOrderType["STOP_ORDER_TYPE_UNSPECIFIED"] = 0] = "STOP_ORDER_TYPE_UNSPECIFIED"; /** STOP_ORDER_TYPE_TAKE_PROFIT - `Take-profit`-заявка. */ StopOrderType[StopOrderType["STOP_ORDER_TYPE_TAKE_PROFIT"] = 1] = "STOP_ORDER_TYPE_TAKE_PROFIT"; /** STOP_ORDER_TYPE_STOP_LOSS - `Stop-loss`-заявка. */ StopOrderType[StopOrderType["STOP_ORDER_TYPE_STOP_LOSS"] = 2] = "STOP_ORDER_TYPE_STOP_LOSS"; /** STOP_ORDER_TYPE_STOP_LIMIT - `Stop-limit`-заявка. */ StopOrderType[StopOrderType["STOP_ORDER_TYPE_STOP_LIMIT"] = 3] = "STOP_ORDER_TYPE_STOP_LIMIT"; StopOrderType[StopOrderType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(StopOrderType || (exports.StopOrderType = StopOrderType = {})); function stopOrderTypeFromJSON(object) { switch (object) { case 0: case "STOP_ORDER_TYPE_UNSPECIFIED": return StopOrderType.STOP_ORDER_TYPE_UNSPECIFIED; case 1: case "STOP_ORDER_TYPE_TAKE_PROFIT": return StopOrderType.STOP_ORDER_TYPE_TAKE_PROFIT; case 2: case "STOP_ORDER_TYPE_STOP_LOSS": return StopOrderType.STOP_ORDER_TYPE_STOP_LOSS; case 3: case "STOP_ORDER_TYPE_STOP_LIMIT": return StopOrderType.STOP_ORDER_TYPE_STOP_LIMIT; case -1: case "UNRECOGNIZED": default: return StopOrderType.UNRECOGNIZED; } } exports.stopOrderTypeFromJSON = stopOrderTypeFromJSON; function stopOrderTypeToJSON(object) { switch (object) { case StopOrderType.STOP_ORDER_TYPE_UNSPECIFIED: return "STOP_ORDER_TYPE_UNSPECIFIED"; case StopOrderType.STOP_ORDER_TYPE_TAKE_PROFIT: return "STOP_ORDER_TYPE_TAKE_PROFIT"; case StopOrderType.STOP_ORDER_TYPE_STOP_LOSS: return "STOP_ORDER_TYPE_STOP_LOSS"; case StopOrderType.STOP_ORDER_TYPE_STOP_LIMIT: return "STOP_ORDER_TYPE_STOP_LIMIT"; case StopOrderType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.stopOrderTypeToJSON = stopOrderTypeToJSON; /** Статус стоп-заяки. */ var StopOrderStatusOption; (function (StopOrderStatusOption) { /** STOP_ORDER_STATUS_UNSPECIFIED - Значение не указано. */ StopOrderStatusOption[StopOrderStatusOption["STOP_ORDER_STATUS_UNSPECIFIED"] = 0] = "STOP_ORDER_STATUS_UNSPECIFIED"; /** STOP_ORDER_STATUS_ALL - Все заявки. */ StopOrderStatusOption[StopOrderStatusOption["STOP_ORDER_STATUS_ALL"] = 1] = "STOP_ORDER_STATUS_ALL"; /** STOP_ORDER_STATUS_ACTIVE - Активные заявки. */ StopOrderStatusOption[StopOrderStatusOption["STOP_ORDER_STATUS_ACTIVE"] = 2] = "STOP_ORDER_STATUS_ACTIVE"; /** STOP_ORDER_STATUS_EXECUTED - Исполненные заявки. */ StopOrderStatusOption[StopOrderStatusOption["STOP_ORDER_STATUS_EXECUTED"] = 3] = "STOP_ORDER_STATUS_EXECUTED"; /** STOP_ORDER_STATUS_CANCELED - Отменённые заявки. */ StopOrderStatusOption[StopOrderStatusOption["STOP_ORDER_STATUS_CANCELED"] = 4] = "STOP_ORDER_STATUS_CANCELED"; /** STOP_ORDER_STATUS_EXPIRED - Истёкшие заявки. */ StopOrderStatusOption[StopOrderStatusOption["STOP_ORDER_STATUS_EXPIRED"] = 5] = "STOP_ORDER_STATUS_EXPIRED"; StopOrderStatusOption[StopOrderStatusOption["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(StopOrderStatusOption || (exports.StopOrderStatusOption = StopOrderStatusOption = {})); function stopOrderStatusOptionFromJSON(object) { switch (object) { case 0: case "STOP_ORDER_STATUS_UNSPECIFIED": return StopOrderStatusOption.STOP_ORDER_STATUS_UNSPECIFIED; case 1: case "STOP_ORDER_STATUS_ALL": return StopOrderStatusOption.STOP_ORDER_STATUS_ALL; case 2: case "STOP_ORDER_STATUS_ACTIVE": return StopOrderStatusOption.STOP_ORDER_STATUS_ACTIVE; case 3: case "STOP_ORDER_STATUS_EXECUTED": return StopOrderStatusOption.STOP_ORDER_STATUS_EXECUTED; case 4: case "STOP_ORDER_STATUS_CANCELED": return StopOrderStatusOption.STOP_ORDER_STATUS_CANCELED; case 5: case "STOP_ORDER_STATUS_EXPIRED": return StopOrderStatusOption.STOP_ORDER_STATUS_EXPIRED; case -1: case "UNRECOGNIZED": default: return StopOrderStatusOption.UNRECOGNIZED; } } exports.stopOrderStatusOptionFromJSON = stopOrderStatusOptionFromJSON; function stopOrderStatusOptionToJSON(object) { switch (object) { case StopOrderStatusOption.STOP_ORDER_STATUS_UNSPECIFIED: return "STOP_ORDER_STATUS_UNSPECIFIED"; case StopOrderStatusOption.STOP_ORDER_STATUS_ALL: return "STOP_ORDER_STATUS_ALL"; case StopOrderStatusOption.STOP_ORDER_STATUS_ACTIVE: return "STOP_ORDER_STATUS_ACTIVE"; case StopOrderStatusOption.STOP_ORDER_STATUS_EXECUTED: return "STOP_ORDER_STATUS_EXECUTED"; case StopOrderStatusOption.STOP_ORDER_STATUS_CANCELED: return "STOP_ORDER_STATUS_CANCELED"; case StopOrderStatusOption.STOP_ORDER_STATUS_EXPIRED: return "STOP_ORDER_STATUS_EXPIRED"; case StopOrderStatusOption.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.stopOrderStatusOptionToJSON = stopOrderStatusOptionToJSON; /** Тип выставляемой заявки. */ var ExchangeOrderType; (function (ExchangeOrderType) { /** EXCHANGE_ORDER_TYPE_UNSPECIFIED - Значение не указано. */ ExchangeOrderType[ExchangeOrderType["EXCHANGE_ORDER_TYPE_UNSPECIFIED"] = 0] = "EXCHANGE_ORDER_TYPE_UNSPECIFIED"; /** EXCHANGE_ORDER_TYPE_MARKET - Заявка по рыночной цене. */ ExchangeOrderType[ExchangeOrderType["EXCHANGE_ORDER_TYPE_MARKET"] = 1] = "EXCHANGE_ORDER_TYPE_MARKET"; /** EXCHANGE_ORDER_TYPE_LIMIT - Лимитная заявка. */ ExchangeOrderType[ExchangeOrderType["EXCHANGE_ORDER_TYPE_LIMIT"] = 2] = "EXCHANGE_ORDER_TYPE_LIMIT"; ExchangeOrderType[ExchangeOrderType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(ExchangeOrderType || (exports.ExchangeOrderType = ExchangeOrderType = {})); function exchangeOrderTypeFromJSON(object) { switch (object) { case 0: case "EXCHANGE_ORDER_TYPE_UNSPECIFIED": return ExchangeOrderType.EXCHANGE_ORDER_TYPE_UNSPECIFIED; case 1: case "EXCHANGE_ORDER_TYPE_MARKET": return ExchangeOrderType.EXCHANGE_ORDER_TYPE_MARKET; case 2: case "EXCHANGE_ORDER_TYPE_LIMIT": return ExchangeOrderType.EXCHANGE_ORDER_TYPE_LIMIT; case -1: case "UNRECOGNIZED": default: return ExchangeOrderType.UNRECOGNIZED; } } exports.exchangeOrderTypeFromJSON = exchangeOrderTypeFromJSON; function exchangeOrderTypeToJSON(object) { switch (object) { case ExchangeOrderType.EXCHANGE_ORDER_TYPE_UNSPECIFIED: return "EXCHANGE_ORDER_TYPE_UNSPECIFIED"; case ExchangeOrderType.EXCHANGE_ORDER_TYPE_MARKET: return "EXCHANGE_ORDER_TYPE_MARKET"; case ExchangeOrderType.EXCHANGE_ORDER_TYPE_LIMIT: return "EXCHANGE_ORDER_TYPE_LIMIT"; case ExchangeOrderType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.exchangeOrderTypeToJSON = exchangeOrderTypeToJSON; /** Тип TakeProfit-заявки. */ var TakeProfitType; (function (TakeProfitType) { /** TAKE_PROFIT_TYPE_UNSPECIFIED - Значение не указано. */ TakeProfitType[TakeProfitType["TAKE_PROFIT_TYPE_UNSPECIFIED"] = 0] = "TAKE_PROFIT_TYPE_UNSPECIFIED"; /** TAKE_PROFIT_TYPE_REGULAR - Обычная заявка, значение по умолчанию. */ TakeProfitType[TakeProfitType["TAKE_PROFIT_TYPE_REGULAR"] = 1] = "TAKE_PROFIT_TYPE_REGULAR"; /** TAKE_PROFIT_TYPE_TRAILING - Трейлинг-стоп. */ TakeProfitType[TakeProfitType["TAKE_PROFIT_TYPE_TRAILING"] = 2] = "TAKE_PROFIT_TYPE_TRAILING"; TakeProfitType[TakeProfitType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(TakeProfitType || (exports.TakeProfitType = TakeProfitType = {})); function takeProfitTypeFromJSON(object) { switch (object) { case 0: case "TAKE_PROFIT_TYPE_UNSPECIFIED": return TakeProfitType.TAKE_PROFIT_TYPE_UNSPECIFIED; case 1: case "TAKE_PROFIT_TYPE_REGULAR": return TakeProfitType.TAKE_PROFIT_TYPE_REGULAR; case 2: case "TAKE_PROFIT_TYPE_TRAILING": return TakeProfitType.TAKE_PROFIT_TYPE_TRAILING; case -1: case "UNRECOGNIZED": default: return TakeProfitType.UNRECOGNIZED; } } exports.takeProfitTypeFromJSON = takeProfitTypeFromJSON; function takeProfitTypeToJSON(object) { switch (object) { case TakeProfitType.TAKE_PROFIT_TYPE_UNSPECIFIED: return "TAKE_PROFIT_TYPE_UNSPECIFIED"; case TakeProfitType.TAKE_PROFIT_TYPE_REGULAR: return "TAKE_PROFIT_TYPE_REGULAR"; case TakeProfitType.TAKE_PROFIT_TYPE_TRAILING: return "TAKE_PROFIT_TYPE_TRAILING"; case TakeProfitType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.takeProfitTypeToJSON = takeProfitTypeToJSON; /** Тип параметров значений трейлинг-стопа. */ var TrailingValueType; (function (TrailingValueType) { /** TRAILING_VALUE_UNSPECIFIED - Значение не указано. */ TrailingValueType[TrailingValueType["TRAILING_VALUE_UNSPECIFIED"] = 0] = "TRAILING_VALUE_UNSPECIFIED"; /** TRAILING_VALUE_ABSOLUTE - Абсолютное значение в единицах цены. */ TrailingValueType[TrailingValueType["TRAILING_VALUE_ABSOLUTE"] = 1] = "TRAILING_VALUE_ABSOLUTE"; /** TRAILING_VALUE_RELATIVE - Относительное значение в процентах. */ TrailingValueType[TrailingValueType["TRAILING_VALUE_RELATIVE"] = 2] = "TRAILING_VALUE_RELATIVE"; TrailingValueType[TrailingValueType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(TrailingValueType || (exports.TrailingValueType = TrailingValueType = {})); function trailingValueTypeFromJSON(object) { switch (object) { case 0: case "TRAILING_VALUE_UNSPECIFIED": return TrailingValueType.TRAILING_VALUE_UNSPECIFIED; case 1: case "TRAILING_VALUE_ABSOLUTE": return TrailingValueType.TRAILING_VALUE_ABSOLUTE; case 2: case "TRAILING_VALUE_RELATIVE": return TrailingValueType.TRAILING_VALUE_RELATIVE; case -1: case "UNRECOGNIZED": default: return TrailingValueType.UNRECOGNIZED; } } exports.trailingValueTypeFromJSON = trailingValueTypeFromJSON; function trailingValueTypeToJSON(object) { switch (object) { case TrailingValueType.TRAILING_VALUE_UNSPECIFIED: return "TRAILING_VALUE_UNSPECIFIED"; case TrailingValueType.TRAILING_VALUE_ABSOLUTE: return "TRAILING_VALUE_ABSOLUTE"; case TrailingValueType.TRAILING_VALUE_RELATIVE: return "TRAILING_VALUE_RELATIVE"; case TrailingValueType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.trailingValueTypeToJSON = trailingValueTypeToJSON; /** Статус трейлинг-стопа. */ var TrailingStopStatus; (function (TrailingStopStatus) { /** TRAILING_STOP_UNSPECIFIED - Значение не указано. */ TrailingStopStatus[TrailingStopStatus["TRAILING_STOP_UNSPECIFIED"] = 0] = "TRAILING_STOP_UNSPECIFIED"; /** TRAILING_STOP_ACTIVE - Активный. */ TrailingStopStatus[TrailingStopStatus["TRAILING_STOP_ACTIVE"] = 1] = "TRAILING_STOP_ACTIVE"; /** TRAILING_STOP_ACTIVATED - Активированный. */ TrailingStopStatus[TrailingStopStatus["TRAILING_STOP_ACTIVATED"] = 2] = "TRAILING_STOP_ACTIVATED"; TrailingStopStatus[TrailingStopStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(TrailingStopStatus || (exports.TrailingStopStatus = TrailingStopStatus = {})); function trailingStopStatusFromJSON(object) { switch (object) { case 0: case "TRAILING_STOP_UNSPECIFIED": return TrailingStopStatus.TRAILING_STOP_UNSPECIFIED; case 1: case "TRAILING_STOP_ACTIVE": return TrailingStopStatus.TRAILING_STOP_ACTIVE; case 2: case "TRAILING_STOP_ACTIVATED": return TrailingStopStatus.TRAILING_STOP_ACTIVATED; case -1: case "UNRECOGNIZED": default: return TrailingStopStatus.UNRECOGNIZED; } } exports.trailingStopStatusFromJSON = trailingStopStatusFromJSON; function trailingStopStatusToJSON(object) { switch (object) { case TrailingStopStatus.TRAILING_STOP_UNSPECIFIED: return "TRAILING_STOP_UNSPECIFIED"; case TrailingStopStatus.TRAILING_STOP_ACTIVE: return "TRAILING_STOP_ACTIVE"; case TrailingStopStatus.TRAILING_STOP_ACTIVATED: return "TRAILING_STOP_ACTIVATED"; case TrailingStopStatus.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.trailingStopStatusToJSON = trailingStopStatusToJSON; function createBasePostStopOrderRequest() { return { figi: undefined, quantity: 0, price: undefined, stopPrice: undefined, direction: 0, accountId: "", expirationType: 0, stopOrderType: 0, expireDate: undefined, instrumentId: "", exchangeOrderType: 0, takeProfitType: 0, trailingData: undefined, priceType: 0, orderId: "", }; } exports.PostStopOrderRequest = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.figi !== undefined) { writer.uint32(10).string(message.figi); } if (message.quantity !== 0) { writer.uint32(16).int64(message.quantity); } if (message.price !== undefined) { common_js_1.Quotation.encode(message.price, writer.uint32(26).fork()).ldelim(); } if (message.stopPrice !== undefined) { common_js_1.Quotation.encode(message.stopPrice, writer.uint32(34).fork()).ldelim(); } if (message.direction !== 0) { writer.uint32(40).int32(message.direction); } if (message.accountId !== "") { writer.uint32(50).string(message.accountId); } if (message.expirationType !== 0) { writer.uint32(56).int32(message.expirationType); } if (message.stopOrderType !== 0) { writer.uint32(64).int32(message.stopOrderType); } if (message.expireDate !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.expireDate), writer.uint32(74).fork()).ldelim(); } if (message.instrumentId !== "") { writer.uint32(82).string(message.instrumentId); } if (message.exchangeOrderType !== 0) { writer.uint32(88).int32(message.exchangeOrderType); } if (message.takeProfitType !== 0) { writer.uint32(96).int32(message.takeProfitType); } if (message.trailingData !== undefined) { exports.PostStopOrderRequest_TrailingData.encode(message.trailingData, writer.uint32(106).fork()).ldelim(); } if (message.priceType !== 0) { writer.uint32(112).int32(message.priceType); } if (message.orderId !== "") { writer.uint32(122).string(message.orderId); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePostStopOrderRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.figi = reader.string(); continue; case 2: if (tag !== 16) { break; } message.quantity = longToNumber(reader.int64()); continue; case 3: if (tag !== 26) { break; } message.price = common_js_1.Quotation.decode(reader, reader.uint32()); continue; case 4: if (tag !== 34) { break; } message.stopPrice = common_js_1.Quotation.decode(reader, reader.uint32()); continue; case 5: if (tag !== 40) { break; } message.direction = reader.int32(); continue; case 6: if (tag !== 50) { break; } message.accountId = reader.string(); continue; case 7: if (tag !== 56) { break; } message.expirationType = reader.int32(); continue; case 8: if (tag !== 64) { break; } message.stopOrderType = reader.int32(); continue; case 9: if (tag !== 74) { break; } message.expireDate = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; case 10: if (tag !== 82) { break; } message.instrumentId = reader.string(); continue; case 11: if (tag !== 88) { break; } message.exchangeOrderType = reader.int32(); continue; case 12: if (tag !== 96) { break; } message.takeProfitType = reader.int32(); continue; case 13: if (tag !== 106) { break; } message.trailingData = exports.PostStopOrderRequest_TrailingData.decode(reader, reader.uint32()); continue; case 14: if (tag !== 112) { break; } message.priceType = reader.int32(); continue; case 15: if (tag !== 122) { break; } message.orderId = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { figi: isSet(object.figi) ? globalThis.String(object.figi) : undefined, quantity: isSet(object.quantity) ? globalThis.Number(object.quantity) : 0, price: isSet(object.price) ? common_js_1.Quotation.fromJSON(object.price) : undefined, stopPrice: isSet(object.stopPrice) ? common_js_1.Quotation.fromJSON(object.stopPrice) : undefined, direction: isSet(object.direction) ? stopOrderDirectionFromJSON(object.direction) : 0, accountId: isSet(object.accountId) ? globalThis.String(object.accountId) : "", expirationType: isSet(object.expirationType) ? stopOrderExpirationTypeFromJSON(object.expirationType) : 0, stopOrderType: isSet(object.stopOrderType) ? stopOrderTypeFromJSON(object.stopOrderType) : 0, expireDate: isSet(object.expireDate) ? fromJsonTimestamp(object.expireDate) : undefined, instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "", exchangeOrderType: isSet(object.exchangeOrderType) ? exchangeOrderTypeFromJSON(object.exchangeOrderType) : 0, takeProfitType: isSet(object.takeProfitType) ? takeProfitTypeFromJSON(object.takeProfitType) : 0, trailingData: isSet(object.trailingData) ? exports.PostStopOrderRequest_TrailingData.fromJSON(object.trailingData) : undefined, priceType: isSet(object.priceType) ? (0, common_js_1.priceTypeFromJSON)(object.priceType) : 0, orderId: isSet(object.orderId) ? globalThis.String(object.orderId) : "", }; }, toJSON(message) { const obj = {}; if (message.figi !== undefined) { obj.figi = message.figi; } if (message.quantity !== 0) { obj.quantity = Math.round(message.quantity); } if (message.price !== undefined) { obj.price = common_js_1.Quotation.toJSON(message.price); } if (message.stopPrice !== undefined) { obj.stopPrice = common_js_1.Quotation.toJSON(message.stopPrice); } if (message.direction !== 0) { obj.direction = stopOrderDirectionToJSON(message.direction); } if (message.accountId !== "") { obj.accountId = message.accountId; } if (message.expirationType !== 0) { obj.expirationType = stopOrderExpirationTypeToJSON(message.expirationType); } if (message.stopOrderType !== 0) { obj.stopOrderType = stopOrderTypeToJSON(message.stopOrderType); } if (message.expireDate !== undefined) { obj.expireDate = message.expireDate.toISOString(); } if (message.instrumentId !== "") { obj.instrumentId = message.instrumentId; } if (message.exchangeOrderType !== 0) { obj.exchangeOrderType = exchangeOrderTypeToJSON(message.exchangeOrderType); } if (message.takeProfitType !== 0) { obj.takeProfitType = takeProfitTypeToJSON(message.takeProfitType); } if (message.trailingData !== undefined) { obj.trailingData = exports.PostStopOrderRequest_TrailingData.toJSON(message.trailingData); } if (message.priceType !== 0) { obj.priceType = (0, common_js_1.priceTypeToJSON)(message.priceType); } if (message.orderId !== "") { obj.orderId = message.orderId; } return obj; }, }; function createBasePostStopOrderRequest_TrailingData() { return { indent: undefined, indentType: 0, spread: undefined, spreadType: 0 }; } exports.PostStopOrderRequest_TrailingData = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.indent !== undefined) { common_js_1.Quotation.encode(message.indent, writer.uint32(10).fork()).ldelim(); } if (message.indentType !== 0) { writer.uint32(16).int32(message.indentType); } if (message.spread !== undefined) { common_js_1.Quotation.encode(message.spread, writer.uint32(26).fork()).ldelim(); } if (message.spreadType !== 0) { writer.uint32(32).int32(message.spreadType); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePostStopOrderRequest_TrailingData(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.indent = common_js_1.Quotation.decode(reader, reader.uint32()); continue; case 2: if (tag !== 16) { break; } message.indentType = reader.int32(); continue; case 3: if (tag !== 26) { break; } message.spread = common_js_1.Quotation.decode(reader, reader.uint32()); continue; case 4: if (tag !== 32) { break; } message.spreadType = reader.int32(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { indent: isSet(object.indent) ? common_js_1.Quotation.fromJSON(object.indent) : undefined, indentType: isSet(object.indentType) ? trailingValueTypeFromJSON(object.indentType) : 0, spread: isSet(object.spread) ? common_js_1.Quotation.fromJSON(object.spread) : undefined, spreadType: isSet(object.spreadType) ? trailingValueTypeFromJSON(object.spreadType) : 0, }; }, toJSON(message) { const obj = {}; if (message.indent !== undefined) { obj.indent = common_js_1.Quotation.toJSON(message.indent); } if (message.indentType !== 0) { obj.indentType = trailingValueTypeToJSON(message.indentType); } if (message.spread !== undefined) { obj.spread = common_js_1.Quotation.toJSON(message.spread); } if (message.spreadType !== 0) { obj.spreadType = trailingValueTypeToJSON(message.spreadType); } return obj; }, }; function createBasePostStopOrderResponse() { return { stopOrderId: "", orderRequestId: "", responseMetadata: undefined }; } exports.PostStopOrderResponse = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.stopOrderId !== "") { writer.uint32(10).string(message.stopOrderId); } if (message.orderRequestId !== "") { writer.uint32(18).string(message.orderRequestId); } if (message.responseMetadata !== undefined) { common_js_1.ResponseMetadata.encode(message.responseMetadata, writer.uint32(2034).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePostStopOrderResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.stopOrderId = reader.string(); continue; case 2: if (tag !== 18) { break; } message.orderRequestId = reader.string(); continue; case 254: if (tag !== 2034) { break; } message.responseMetadata = common_js_1.ResponseMetadata.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { stopOrderId: isSet(object.stopOrderId) ? globalThis.String(object.stopOrderId) : "", orderRequestId: isSet(object.orderRequestId) ? globalThis.String(object.orderRequestId) : "", responseMetadata: isSet(object.responseMetadata) ? common_js_1.ResponseMetadata.fromJSON(object.responseMetadata) : undefined, }; }, toJSON(message) { const obj = {}; if (message.stopOrderId !== "") { obj.stopOrderId = message.stopOrderId; } if (message.orderRequestId !== "") { obj.orderRequestId = message.orderRequestId; } if (message.responseMetadata !== undefined) { obj.responseMetadata = common_js_1.ResponseMetadata.toJSON(message.responseMetadata); } return obj; }, }; function createBaseGetStopOrdersRequest() { return { accountId: "", status: 0, from: undefined, to: undefined }; } exports.GetStopOrdersRequest = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.accountId !== "") { writer.uint32(10).string(message.accountId); } if (message.status !== 0) { writer.uint32(16).int32(message.status); } if (message.from !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.from), writer.uint32(26).fork()).ldelim(); } if (message.to !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.to), writer.uint32(34).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetStopOrdersRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.accountId = reader.string(); continue; case 2: if (tag !== 16) { break; } message.status = reader.int32(); continue; case 3: if (tag !== 26) { break; } message.from = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; case 4: if (tag !== 34) { break; } message.to = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { accountId: isSet(object.accountId) ? globalThis.String(object.accountId) : "", status: isSet(object.status) ? stopOrderStatusOptionFromJSON(object.status) : 0, from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined, to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined, }; }, toJSON(message) { const obj = {}; if (message.accountId !== "") { obj.accountId = message.accountId; } if (message.status !== 0) { obj.status = stopOrderStatusOptionToJSON(message.status); } if (message.from !== undefined) { obj.from = message.from.toISOString(); } if (message.to !== undefined) { obj.to = message.to.toISOString(); } return obj; }, }; function createBaseGetStopOrdersResponse() { return { stopOrders: [] }; } exports.GetStopOrdersResponse = { encode(message, writer = minimal_js_1.default.Writer.create()) { for (const v of message.stopOrders) { exports.StopOrder.encode(v, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetStopOrdersResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.stopOrders.push(exports.StopOrder.decode(reader, reader.uint32())); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { stopOrders: globalThis.Array.isArray(object?.stopOrders) ? object.stopOrders.map((e) => exports.StopOrder.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.stopOrders?.length) { obj.stopOrders = message.stopOrders.map((e) => exports.StopOrder.toJSON(e)); } return obj; }, }; function createBaseCancelStopOrderRequest() { return { accountId: "", stopOrderId: "" }; } exports.CancelStopOrderRequest = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.accountId !== "") { writer.uint32(10).string(message.accountId); } if (message.stopOrderId !== "") { writer.uint32(18).string(message.stopOrderId); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCancelStopOrderRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.accountId = reader.string(); continue; case 2: if (tag !== 18) { break; } message.stopOrderId = reader.string(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { accountId: isSet(object.accountId) ? globalThis.String(object.accountId) : "", stopOrderId: isSet(object.stopOrderId) ? globalThis.String(object.stopOrderId) : "", }; }, toJSON(message) { const obj = {}; if (message.accountId !== "") { obj.accountId = message.accountId; } if (message.stopOrderId !== "") { obj.stopOrderId = message.stopOrderId; } return obj; }, }; function createBaseCancelStopOrderResponse() { return { time: undefined }; } exports.CancelStopOrderResponse = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.time !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.time), writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCancelStopOrderResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.time = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined }; }, toJSON(message) { const obj = {}; if (message.time !== undefined) { obj.time = message.time.toISOString(); } return obj; }, }; function createBaseStopOrder() { return { stopOrderId: "", lotsRequested: 0, figi: "", direction: 0, currency: "", orderType: 0, createDate: undefined, activationDateTime: undefined, expirationTime: undefined, price: undefined, stopPrice: undefined, instrumentUid: "", takeProfitType: 0, trailingData: undefined, status: 0, exchangeOrderType: 0, exchangeOrderId: undefined, }; } exports.StopOrder = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.stopOrderId !== "") { writer.uint32(10).string(message.stopOrderId); } if (message.lotsRequested !== 0) { writer.uint32(16).int64(message.lotsRequested); } if (message.figi !== "") { writer.uint32(26).string(message.figi); } if (message.direction !== 0) { writer.uint32(32).int32(message.direction); } if (message.currency !== "") { writer.uint32(42).string(message.currency); } if (message.orderType !== 0) { writer.uint32(48).int32(message.orderType); } if (message.createDate !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.createDate), writer.uint32(58).fork()).ldelim(); } if (message.activationDateTime !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.activationDateTime), writer.uint32(66).fork()).ldelim(); } if (message.expirationTime !== undefined) { timestamp_js_1.Timestamp.encode(toTimestamp(message.expirationTime), writer.uint32(74).fork()).ldelim(); } if (message.price !== undefined) { common_js_1.MoneyValue.encode(message.price, writer.uint32(82).fork()).ldelim(); } if (message.stopPrice !== undefined) { common_js_1.MoneyValue.encode(message.stopPrice, writer.uint32(90).fork()).ldelim(); } if (message.instrumentUid !== "") { writer.uint32(98).string(message.instrumentUid); } if (message.takeProfitType !== 0) { writer.uint32(104).int32(message.takeProfitType); } if (message.trailingData !== undefined) { exports.StopOrder_TrailingData.encode(message.trailingData, writer.uint32(114).fork()).ldelim(); } if (message.status !== 0) { writer.uint32(120).int32(message.status); } if (message.exchangeOrderType !== 0) { writer.uint32(128).int32(message.exchangeOrderType); } if (message.exchangeOrderId !== undefined) { writer.uint32(138).string(message.exchangeOrderId); } return writer; }, decode(input, length) { const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStopOrder(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.stopOrderId = reader.string(); continue; case 2: if (tag !== 16) { break; } message.lotsRequested = longToNumber(reader.int64()); continue; case 3: if (tag !== 26) { break; } message.figi = reader.string(); continue; case 4: if (tag !== 32) { break; } message.direction = reader.int32(); continue; case 5: if (tag !== 42) { break; } message.currency = reader.string(); continue; case 6: if (tag !== 48) { break; } message.orderType = reader.int32(); continue; case 7: if (tag !== 58) { break; } message.createDate = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; case 8: if (tag !== 66) { break; } message.activationDateTime = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; case 9: if (tag !== 74) { break; } message.expirationTime = fromTimestamp(timestamp_js_1.Timestamp.decode(reader, reader.uint32())); continue; case 10: if (tag !== 82) { break; } message.price = common_js_1.MoneyValue.decode(reader, reader.uint32()); continue; case 11: if (tag !== 90) { break; } message.stopPrice = common_js_1.MoneyValue.decode(reader, reader.uint32()); continue; case 12: if (tag !== 98) { break; } message.instrumentUid = reader.string(); continue; case 13: if (tag !== 104) { break; } message.takeProfitType = reader.int32(); continue; case 14: if (tag !== 114) { break; } message.trailingData = exports.StopOrder_TrailingData.decode(reader, reader.uint32()); continue; case 15: if (tag !== 120) { break; } message.status = reader.int32(); continue; case 16: if (tag !== 128) { break; } message.exchangeOrderType = reader.int32(); continue; case 17: