UNPKG

tinkoff-invest-api

Version:
6,708 lines 269 kB
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal.js";
import { instrumentStatusFromJSON, instrumentStatusToJSON, Ping, PingDelaySettings, PingRequest, Quotation, securityTradingStatusFromJSON, securityTradingStatusToJSON, } from "./common.js";
import { Timestamp } from "./google/protobuf/timestamp.js";
export const protobufPackage = "tinkoff.public.invest.api.contract.v1";
/** Тип операции со списком подписок. */
export var SubscriptionAction;
(function (SubscriptionAction) {
    /** SUBSCRIPTION_ACTION_UNSPECIFIED - Статус подписки не определен. */
    SubscriptionAction[SubscriptionAction["SUBSCRIPTION_ACTION_UNSPECIFIED"] = 0] = "SUBSCRIPTION_ACTION_UNSPECIFIED";
    /** SUBSCRIPTION_ACTION_SUBSCRIBE - Подписаться. */
    SubscriptionAction[SubscriptionAction["SUBSCRIPTION_ACTION_SUBSCRIBE"] = 1] = "SUBSCRIPTION_ACTION_SUBSCRIBE";
    /** SUBSCRIPTION_ACTION_UNSUBSCRIBE - Отписаться. */
    SubscriptionAction[SubscriptionAction["SUBSCRIPTION_ACTION_UNSUBSCRIBE"] = 2] = "SUBSCRIPTION_ACTION_UNSUBSCRIBE";
    SubscriptionAction[SubscriptionAction["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SubscriptionAction || (SubscriptionAction = {}));
export function subscriptionActionFromJSON(object) {
    switch (object) {
        case 0:
        case "SUBSCRIPTION_ACTION_UNSPECIFIED":
            return SubscriptionAction.SUBSCRIPTION_ACTION_UNSPECIFIED;
        case 1:
        case "SUBSCRIPTION_ACTION_SUBSCRIBE":
            return SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE;
        case 2:
        case "SUBSCRIPTION_ACTION_UNSUBSCRIBE":
            return SubscriptionAction.SUBSCRIPTION_ACTION_UNSUBSCRIBE;
        case -1:
        case "UNRECOGNIZED":
        default:
            return SubscriptionAction.UNRECOGNIZED;
    }
}
export function subscriptionActionToJSON(object) {
    switch (object) {
        case SubscriptionAction.SUBSCRIPTION_ACTION_UNSPECIFIED:
            return "SUBSCRIPTION_ACTION_UNSPECIFIED";
        case SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE:
            return "SUBSCRIPTION_ACTION_SUBSCRIBE";
        case SubscriptionAction.SUBSCRIPTION_ACTION_UNSUBSCRIBE:
            return "SUBSCRIPTION_ACTION_UNSUBSCRIBE";
        case SubscriptionAction.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Интервал свечи. */
export var SubscriptionInterval;
(function (SubscriptionInterval) {
    /** SUBSCRIPTION_INTERVAL_UNSPECIFIED - Интервал свечи не определен. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_UNSPECIFIED"] = 0] = "SUBSCRIPTION_INTERVAL_UNSPECIFIED";
    /** SUBSCRIPTION_INTERVAL_ONE_MINUTE - Минутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_ONE_MINUTE"] = 1] = "SUBSCRIPTION_INTERVAL_ONE_MINUTE";
    /** SUBSCRIPTION_INTERVAL_FIVE_MINUTES - Пятиминутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_FIVE_MINUTES"] = 2] = "SUBSCRIPTION_INTERVAL_FIVE_MINUTES";
    /** SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES - Пятнадцатиминутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES"] = 3] = "SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES";
    /** SUBSCRIPTION_INTERVAL_ONE_HOUR - Часовые свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_ONE_HOUR"] = 4] = "SUBSCRIPTION_INTERVAL_ONE_HOUR";
    /** SUBSCRIPTION_INTERVAL_ONE_DAY - Дневные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_ONE_DAY"] = 5] = "SUBSCRIPTION_INTERVAL_ONE_DAY";
    /** SUBSCRIPTION_INTERVAL_2_MIN - Двухминутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_2_MIN"] = 6] = "SUBSCRIPTION_INTERVAL_2_MIN";
    /** SUBSCRIPTION_INTERVAL_3_MIN - Трехминутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_3_MIN"] = 7] = "SUBSCRIPTION_INTERVAL_3_MIN";
    /** SUBSCRIPTION_INTERVAL_10_MIN - Десятиминутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_10_MIN"] = 8] = "SUBSCRIPTION_INTERVAL_10_MIN";
    /** SUBSCRIPTION_INTERVAL_30_MIN - Тридцатиминутные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_30_MIN"] = 9] = "SUBSCRIPTION_INTERVAL_30_MIN";
    /** SUBSCRIPTION_INTERVAL_2_HOUR - Двухчасовые свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_2_HOUR"] = 10] = "SUBSCRIPTION_INTERVAL_2_HOUR";
    /** SUBSCRIPTION_INTERVAL_4_HOUR - Четырехчасовые свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_4_HOUR"] = 11] = "SUBSCRIPTION_INTERVAL_4_HOUR";
    /** SUBSCRIPTION_INTERVAL_WEEK - Недельные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_WEEK"] = 12] = "SUBSCRIPTION_INTERVAL_WEEK";
    /** SUBSCRIPTION_INTERVAL_MONTH - Месячные свечи. */
    SubscriptionInterval[SubscriptionInterval["SUBSCRIPTION_INTERVAL_MONTH"] = 13] = "SUBSCRIPTION_INTERVAL_MONTH";
    SubscriptionInterval[SubscriptionInterval["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SubscriptionInterval || (SubscriptionInterval = {}));
export function subscriptionIntervalFromJSON(object) {
    switch (object) {
        case 0:
        case "SUBSCRIPTION_INTERVAL_UNSPECIFIED":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_UNSPECIFIED;
        case 1:
        case "SUBSCRIPTION_INTERVAL_ONE_MINUTE":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_MINUTE;
        case 2:
        case "SUBSCRIPTION_INTERVAL_FIVE_MINUTES":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_FIVE_MINUTES;
        case 3:
        case "SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES;
        case 4:
        case "SUBSCRIPTION_INTERVAL_ONE_HOUR":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_HOUR;
        case 5:
        case "SUBSCRIPTION_INTERVAL_ONE_DAY":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_DAY;
        case 6:
        case "SUBSCRIPTION_INTERVAL_2_MIN":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_2_MIN;
        case 7:
        case "SUBSCRIPTION_INTERVAL_3_MIN":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_3_MIN;
        case 8:
        case "SUBSCRIPTION_INTERVAL_10_MIN":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_10_MIN;
        case 9:
        case "SUBSCRIPTION_INTERVAL_30_MIN":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_30_MIN;
        case 10:
        case "SUBSCRIPTION_INTERVAL_2_HOUR":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_2_HOUR;
        case 11:
        case "SUBSCRIPTION_INTERVAL_4_HOUR":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_4_HOUR;
        case 12:
        case "SUBSCRIPTION_INTERVAL_WEEK":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_WEEK;
        case 13:
        case "SUBSCRIPTION_INTERVAL_MONTH":
            return SubscriptionInterval.SUBSCRIPTION_INTERVAL_MONTH;
        case -1:
        case "UNRECOGNIZED":
        default:
            return SubscriptionInterval.UNRECOGNIZED;
    }
}
export function subscriptionIntervalToJSON(object) {
    switch (object) {
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_UNSPECIFIED:
            return "SUBSCRIPTION_INTERVAL_UNSPECIFIED";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_MINUTE:
            return "SUBSCRIPTION_INTERVAL_ONE_MINUTE";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_FIVE_MINUTES:
            return "SUBSCRIPTION_INTERVAL_FIVE_MINUTES";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES:
            return "SUBSCRIPTION_INTERVAL_FIFTEEN_MINUTES";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_HOUR:
            return "SUBSCRIPTION_INTERVAL_ONE_HOUR";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_DAY:
            return "SUBSCRIPTION_INTERVAL_ONE_DAY";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_2_MIN:
            return "SUBSCRIPTION_INTERVAL_2_MIN";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_3_MIN:
            return "SUBSCRIPTION_INTERVAL_3_MIN";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_10_MIN:
            return "SUBSCRIPTION_INTERVAL_10_MIN";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_30_MIN:
            return "SUBSCRIPTION_INTERVAL_30_MIN";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_2_HOUR:
            return "SUBSCRIPTION_INTERVAL_2_HOUR";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_4_HOUR:
            return "SUBSCRIPTION_INTERVAL_4_HOUR";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_WEEK:
            return "SUBSCRIPTION_INTERVAL_WEEK";
        case SubscriptionInterval.SUBSCRIPTION_INTERVAL_MONTH:
            return "SUBSCRIPTION_INTERVAL_MONTH";
        case SubscriptionInterval.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Результат подписки. */
export var SubscriptionStatus;
(function (SubscriptionStatus) {
    /** SUBSCRIPTION_STATUS_UNSPECIFIED - Статус подписки не определен. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_UNSPECIFIED"] = 0] = "SUBSCRIPTION_STATUS_UNSPECIFIED";
    /** SUBSCRIPTION_STATUS_SUCCESS - Успешно. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_SUCCESS"] = 1] = "SUBSCRIPTION_STATUS_SUCCESS";
    /** SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND - Инструмент не найден. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND"] = 2] = "SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND";
    /** SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID - Некорректный статус подписки. [Список возможных значений](./marketdata#subscriptionaction). */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID"] = 3] = "SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID";
    /** SUBSCRIPTION_STATUS_DEPTH_IS_INVALID - Некорректная глубина стакана. Доступные значения — 1, 10, 20, 30, 40, 50. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_DEPTH_IS_INVALID"] = 4] = "SUBSCRIPTION_STATUS_DEPTH_IS_INVALID";
    /** SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID - Некорректный интервал свечей. [Список возможных значений](./marketdata#subscriptioninterval). */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID"] = 5] = "SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID";
    /** SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED - Превышен лимит на общее количество подписок в рамках стрима. [Лимитная политика](./limits/). */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED"] = 6] = "SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED";
    /** SUBSCRIPTION_STATUS_INTERNAL_ERROR - Внутренняя ошибка сервиса. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_INTERNAL_ERROR"] = 7] = "SUBSCRIPTION_STATUS_INTERNAL_ERROR";
    /** SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS - Превышен лимит на количество запросов на подписки в течение установленного отрезка времени. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS"] = 8] = "SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS";
    /** SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND - Активная подписка не найдена. Ошибка может возникнуть только при отписке от несуществующей подписки. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND"] = 9] = "SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND";
    /** SUBSCRIPTION_STATUS_SOURCE_IS_INVALID - Указан некорректный источник. */
    SubscriptionStatus[SubscriptionStatus["SUBSCRIPTION_STATUS_SOURCE_IS_INVALID"] = 10] = "SUBSCRIPTION_STATUS_SOURCE_IS_INVALID";
    SubscriptionStatus[SubscriptionStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(SubscriptionStatus || (SubscriptionStatus = {}));
export function subscriptionStatusFromJSON(object) {
    switch (object) {
        case 0:
        case "SUBSCRIPTION_STATUS_UNSPECIFIED":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_UNSPECIFIED;
        case 1:
        case "SUBSCRIPTION_STATUS_SUCCESS":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_SUCCESS;
        case 2:
        case "SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND;
        case 3:
        case "SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID;
        case 4:
        case "SUBSCRIPTION_STATUS_DEPTH_IS_INVALID":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_DEPTH_IS_INVALID;
        case 5:
        case "SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID;
        case 6:
        case "SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED;
        case 7:
        case "SUBSCRIPTION_STATUS_INTERNAL_ERROR":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_INTERNAL_ERROR;
        case 8:
        case "SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS;
        case 9:
        case "SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND;
        case 10:
        case "SUBSCRIPTION_STATUS_SOURCE_IS_INVALID":
            return SubscriptionStatus.SUBSCRIPTION_STATUS_SOURCE_IS_INVALID;
        case -1:
        case "UNRECOGNIZED":
        default:
            return SubscriptionStatus.UNRECOGNIZED;
    }
}
export function subscriptionStatusToJSON(object) {
    switch (object) {
        case SubscriptionStatus.SUBSCRIPTION_STATUS_UNSPECIFIED:
            return "SUBSCRIPTION_STATUS_UNSPECIFIED";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_SUCCESS:
            return "SUBSCRIPTION_STATUS_SUCCESS";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND:
            return "SUBSCRIPTION_STATUS_INSTRUMENT_NOT_FOUND";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID:
            return "SUBSCRIPTION_STATUS_SUBSCRIPTION_ACTION_IS_INVALID";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_DEPTH_IS_INVALID:
            return "SUBSCRIPTION_STATUS_DEPTH_IS_INVALID";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID:
            return "SUBSCRIPTION_STATUS_INTERVAL_IS_INVALID";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED:
            return "SUBSCRIPTION_STATUS_LIMIT_IS_EXCEEDED";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_INTERNAL_ERROR:
            return "SUBSCRIPTION_STATUS_INTERNAL_ERROR";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS:
            return "SUBSCRIPTION_STATUS_TOO_MANY_REQUESTS";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND:
            return "SUBSCRIPTION_STATUS_SUBSCRIPTION_NOT_FOUND";
        case SubscriptionStatus.SUBSCRIPTION_STATUS_SOURCE_IS_INVALID:
            return "SUBSCRIPTION_STATUS_SOURCE_IS_INVALID";
        case SubscriptionStatus.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Типы источников сделок. */
export var TradeSourceType;
(function (TradeSourceType) {
    /** TRADE_SOURCE_UNSPECIFIED - Тип источника сделки не определён. */
    TradeSourceType[TradeSourceType["TRADE_SOURCE_UNSPECIFIED"] = 0] = "TRADE_SOURCE_UNSPECIFIED";
    /** TRADE_SOURCE_EXCHANGE - Биржевые сделки. */
    TradeSourceType[TradeSourceType["TRADE_SOURCE_EXCHANGE"] = 1] = "TRADE_SOURCE_EXCHANGE";
    /** TRADE_SOURCE_DEALER - Сделки дилера. */
    TradeSourceType[TradeSourceType["TRADE_SOURCE_DEALER"] = 2] = "TRADE_SOURCE_DEALER";
    /** TRADE_SOURCE_ALL - Все сделки. */
    TradeSourceType[TradeSourceType["TRADE_SOURCE_ALL"] = 3] = "TRADE_SOURCE_ALL";
    TradeSourceType[TradeSourceType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(TradeSourceType || (TradeSourceType = {}));
export function tradeSourceTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "TRADE_SOURCE_UNSPECIFIED":
            return TradeSourceType.TRADE_SOURCE_UNSPECIFIED;
        case 1:
        case "TRADE_SOURCE_EXCHANGE":
            return TradeSourceType.TRADE_SOURCE_EXCHANGE;
        case 2:
        case "TRADE_SOURCE_DEALER":
            return TradeSourceType.TRADE_SOURCE_DEALER;
        case 3:
        case "TRADE_SOURCE_ALL":
            return TradeSourceType.TRADE_SOURCE_ALL;
        case -1:
        case "UNRECOGNIZED":
        default:
            return TradeSourceType.UNRECOGNIZED;
    }
}
export function tradeSourceTypeToJSON(object) {
    switch (object) {
        case TradeSourceType.TRADE_SOURCE_UNSPECIFIED:
            return "TRADE_SOURCE_UNSPECIFIED";
        case TradeSourceType.TRADE_SOURCE_EXCHANGE:
            return "TRADE_SOURCE_EXCHANGE";
        case TradeSourceType.TRADE_SOURCE_DEALER:
            return "TRADE_SOURCE_DEALER";
        case TradeSourceType.TRADE_SOURCE_ALL:
            return "TRADE_SOURCE_ALL";
        case TradeSourceType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Направление сделки. */
export var TradeDirection;
(function (TradeDirection) {
    /** TRADE_DIRECTION_UNSPECIFIED - Направление сделки не определено. */
    TradeDirection[TradeDirection["TRADE_DIRECTION_UNSPECIFIED"] = 0] = "TRADE_DIRECTION_UNSPECIFIED";
    /** TRADE_DIRECTION_BUY - Покупка. */
    TradeDirection[TradeDirection["TRADE_DIRECTION_BUY"] = 1] = "TRADE_DIRECTION_BUY";
    /** TRADE_DIRECTION_SELL - Продажа. */
    TradeDirection[TradeDirection["TRADE_DIRECTION_SELL"] = 2] = "TRADE_DIRECTION_SELL";
    TradeDirection[TradeDirection["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(TradeDirection || (TradeDirection = {}));
export function tradeDirectionFromJSON(object) {
    switch (object) {
        case 0:
        case "TRADE_DIRECTION_UNSPECIFIED":
            return TradeDirection.TRADE_DIRECTION_UNSPECIFIED;
        case 1:
        case "TRADE_DIRECTION_BUY":
            return TradeDirection.TRADE_DIRECTION_BUY;
        case 2:
        case "TRADE_DIRECTION_SELL":
            return TradeDirection.TRADE_DIRECTION_SELL;
        case -1:
        case "UNRECOGNIZED":
        default:
            return TradeDirection.UNRECOGNIZED;
    }
}
export function tradeDirectionToJSON(object) {
    switch (object) {
        case TradeDirection.TRADE_DIRECTION_UNSPECIFIED:
            return "TRADE_DIRECTION_UNSPECIFIED";
        case TradeDirection.TRADE_DIRECTION_BUY:
            return "TRADE_DIRECTION_BUY";
        case TradeDirection.TRADE_DIRECTION_SELL:
            return "TRADE_DIRECTION_SELL";
        case TradeDirection.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Интервал свечей. Максимальное значение интервала приведено ориентировочно, может отличаться в большую сторону в зависимости от параметров запроса. */
export var CandleInterval;
(function (CandleInterval) {
    /** CANDLE_INTERVAL_UNSPECIFIED - Интервал не определен. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_UNSPECIFIED"] = 0] = "CANDLE_INTERVAL_UNSPECIFIED";
    /** CANDLE_INTERVAL_1_MIN - От 1 минуты до 1 дня. Максимальное значение `limit` — 2400. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_1_MIN"] = 1] = "CANDLE_INTERVAL_1_MIN";
    /** CANDLE_INTERVAL_5_MIN - От 5 минут до недели. Максимальное значение `limit` — 2400. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_5_MIN"] = 2] = "CANDLE_INTERVAL_5_MIN";
    /** CANDLE_INTERVAL_15_MIN - От 15 минут до 3 недель. Максимальное значение `limit` — 2400. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_15_MIN"] = 3] = "CANDLE_INTERVAL_15_MIN";
    /** CANDLE_INTERVAL_HOUR - От 1 часа до 3 месяцев. Максимальное значение `limit` — 2400. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_HOUR"] = 4] = "CANDLE_INTERVAL_HOUR";
    /** CANDLE_INTERVAL_DAY - От 1 дня до 6 лет. Максимальное значение `limit` — 2400. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_DAY"] = 5] = "CANDLE_INTERVAL_DAY";
    /** CANDLE_INTERVAL_2_MIN - От 2 минут до 1 дня. Максимальное значение `limit` — 1200. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_2_MIN"] = 6] = "CANDLE_INTERVAL_2_MIN";
    /** CANDLE_INTERVAL_3_MIN - От 3 минут до 1 дня. Максимальное значение `limit` — 750. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_3_MIN"] = 7] = "CANDLE_INTERVAL_3_MIN";
    /** CANDLE_INTERVAL_10_MIN - От 10 минут до недели. Максимальное значение `limit` — 1200. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_10_MIN"] = 8] = "CANDLE_INTERVAL_10_MIN";
    /** CANDLE_INTERVAL_30_MIN - От 30 минут до 3 недель. Максимальное значение `limit` — 1200. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_30_MIN"] = 9] = "CANDLE_INTERVAL_30_MIN";
    /** CANDLE_INTERVAL_2_HOUR - От 2 часов до 3 месяцев. Максимальное значение `limit` — 2400. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_2_HOUR"] = 10] = "CANDLE_INTERVAL_2_HOUR";
    /** CANDLE_INTERVAL_4_HOUR - От 4 часов до 3 месяцев. Максимальное значение `limit` — 700. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_4_HOUR"] = 11] = "CANDLE_INTERVAL_4_HOUR";
    /** CANDLE_INTERVAL_WEEK - От 1 недели до 5 лет. Максимальное значение `limit` — 300. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_WEEK"] = 12] = "CANDLE_INTERVAL_WEEK";
    /** CANDLE_INTERVAL_MONTH - От 1 месяца до 10 лет. Максимальное значение `limit` — 120. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_MONTH"] = 13] = "CANDLE_INTERVAL_MONTH";
    /** CANDLE_INTERVAL_5_SEC - От 5 секунд до 200 минут. Максимальное значение `limit` — 2500. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_5_SEC"] = 14] = "CANDLE_INTERVAL_5_SEC";
    /** CANDLE_INTERVAL_10_SEC - От 10 секунд до 200 минут. Максимальное значение `limit` — 1250. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_10_SEC"] = 15] = "CANDLE_INTERVAL_10_SEC";
    /** CANDLE_INTERVAL_30_SEC - От 30 секунд до 20 часов. Максимальное значение `limit` — 2500. */
    CandleInterval[CandleInterval["CANDLE_INTERVAL_30_SEC"] = 16] = "CANDLE_INTERVAL_30_SEC";
    CandleInterval[CandleInterval["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CandleInterval || (CandleInterval = {}));
export function candleIntervalFromJSON(object) {
    switch (object) {
        case 0:
        case "CANDLE_INTERVAL_UNSPECIFIED":
            return CandleInterval.CANDLE_INTERVAL_UNSPECIFIED;
        case 1:
        case "CANDLE_INTERVAL_1_MIN":
            return CandleInterval.CANDLE_INTERVAL_1_MIN;
        case 2:
        case "CANDLE_INTERVAL_5_MIN":
            return CandleInterval.CANDLE_INTERVAL_5_MIN;
        case 3:
        case "CANDLE_INTERVAL_15_MIN":
            return CandleInterval.CANDLE_INTERVAL_15_MIN;
        case 4:
        case "CANDLE_INTERVAL_HOUR":
            return CandleInterval.CANDLE_INTERVAL_HOUR;
        case 5:
        case "CANDLE_INTERVAL_DAY":
            return CandleInterval.CANDLE_INTERVAL_DAY;
        case 6:
        case "CANDLE_INTERVAL_2_MIN":
            return CandleInterval.CANDLE_INTERVAL_2_MIN;
        case 7:
        case "CANDLE_INTERVAL_3_MIN":
            return CandleInterval.CANDLE_INTERVAL_3_MIN;
        case 8:
        case "CANDLE_INTERVAL_10_MIN":
            return CandleInterval.CANDLE_INTERVAL_10_MIN;
        case 9:
        case "CANDLE_INTERVAL_30_MIN":
            return CandleInterval.CANDLE_INTERVAL_30_MIN;
        case 10:
        case "CANDLE_INTERVAL_2_HOUR":
            return CandleInterval.CANDLE_INTERVAL_2_HOUR;
        case 11:
        case "CANDLE_INTERVAL_4_HOUR":
            return CandleInterval.CANDLE_INTERVAL_4_HOUR;
        case 12:
        case "CANDLE_INTERVAL_WEEK":
            return CandleInterval.CANDLE_INTERVAL_WEEK;
        case 13:
        case "CANDLE_INTERVAL_MONTH":
            return CandleInterval.CANDLE_INTERVAL_MONTH;
        case 14:
        case "CANDLE_INTERVAL_5_SEC":
            return CandleInterval.CANDLE_INTERVAL_5_SEC;
        case 15:
        case "CANDLE_INTERVAL_10_SEC":
            return CandleInterval.CANDLE_INTERVAL_10_SEC;
        case 16:
        case "CANDLE_INTERVAL_30_SEC":
            return CandleInterval.CANDLE_INTERVAL_30_SEC;
        case -1:
        case "UNRECOGNIZED":
        default:
            return CandleInterval.UNRECOGNIZED;
    }
}
export function candleIntervalToJSON(object) {
    switch (object) {
        case CandleInterval.CANDLE_INTERVAL_UNSPECIFIED:
            return "CANDLE_INTERVAL_UNSPECIFIED";
        case CandleInterval.CANDLE_INTERVAL_1_MIN:
            return "CANDLE_INTERVAL_1_MIN";
        case CandleInterval.CANDLE_INTERVAL_5_MIN:
            return "CANDLE_INTERVAL_5_MIN";
        case CandleInterval.CANDLE_INTERVAL_15_MIN:
            return "CANDLE_INTERVAL_15_MIN";
        case CandleInterval.CANDLE_INTERVAL_HOUR:
            return "CANDLE_INTERVAL_HOUR";
        case CandleInterval.CANDLE_INTERVAL_DAY:
            return "CANDLE_INTERVAL_DAY";
        case CandleInterval.CANDLE_INTERVAL_2_MIN:
            return "CANDLE_INTERVAL_2_MIN";
        case CandleInterval.CANDLE_INTERVAL_3_MIN:
            return "CANDLE_INTERVAL_3_MIN";
        case CandleInterval.CANDLE_INTERVAL_10_MIN:
            return "CANDLE_INTERVAL_10_MIN";
        case CandleInterval.CANDLE_INTERVAL_30_MIN:
            return "CANDLE_INTERVAL_30_MIN";
        case CandleInterval.CANDLE_INTERVAL_2_HOUR:
            return "CANDLE_INTERVAL_2_HOUR";
        case CandleInterval.CANDLE_INTERVAL_4_HOUR:
            return "CANDLE_INTERVAL_4_HOUR";
        case CandleInterval.CANDLE_INTERVAL_WEEK:
            return "CANDLE_INTERVAL_WEEK";
        case CandleInterval.CANDLE_INTERVAL_MONTH:
            return "CANDLE_INTERVAL_MONTH";
        case CandleInterval.CANDLE_INTERVAL_5_SEC:
            return "CANDLE_INTERVAL_5_SEC";
        case CandleInterval.CANDLE_INTERVAL_10_SEC:
            return "CANDLE_INTERVAL_10_SEC";
        case CandleInterval.CANDLE_INTERVAL_30_SEC:
            return "CANDLE_INTERVAL_30_SEC";
        case CandleInterval.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var CandleSource;
(function (CandleSource) {
    /** CANDLE_SOURCE_UNSPECIFIED - Источник свечей не определен. */
    CandleSource[CandleSource["CANDLE_SOURCE_UNSPECIFIED"] = 0] = "CANDLE_SOURCE_UNSPECIFIED";
    /** CANDLE_SOURCE_EXCHANGE - Биржевые свечи. */
    CandleSource[CandleSource["CANDLE_SOURCE_EXCHANGE"] = 1] = "CANDLE_SOURCE_EXCHANGE";
    /** CANDLE_SOURCE_DEALER_WEEKEND - Свечи  дилера в результате торговли по выходным. */
    CandleSource[CandleSource["CANDLE_SOURCE_DEALER_WEEKEND"] = 2] = "CANDLE_SOURCE_DEALER_WEEKEND";
    CandleSource[CandleSource["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(CandleSource || (CandleSource = {}));
export function candleSourceFromJSON(object) {
    switch (object) {
        case 0:
        case "CANDLE_SOURCE_UNSPECIFIED":
            return CandleSource.CANDLE_SOURCE_UNSPECIFIED;
        case 1:
        case "CANDLE_SOURCE_EXCHANGE":
            return CandleSource.CANDLE_SOURCE_EXCHANGE;
        case 2:
        case "CANDLE_SOURCE_DEALER_WEEKEND":
            return CandleSource.CANDLE_SOURCE_DEALER_WEEKEND;
        case -1:
        case "UNRECOGNIZED":
        default:
            return CandleSource.UNRECOGNIZED;
    }
}
export function candleSourceToJSON(object) {
    switch (object) {
        case CandleSource.CANDLE_SOURCE_UNSPECIFIED:
            return "CANDLE_SOURCE_UNSPECIFIED";
        case CandleSource.CANDLE_SOURCE_EXCHANGE:
            return "CANDLE_SOURCE_EXCHANGE";
        case CandleSource.CANDLE_SOURCE_DEALER_WEEKEND:
            return "CANDLE_SOURCE_DEALER_WEEKEND";
        case CandleSource.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var MarketValueType;
(function (MarketValueType) {
    /** INSTRUMENT_VALUE_UNSPECIFIED - Не определен. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_UNSPECIFIED"] = 0] = "INSTRUMENT_VALUE_UNSPECIFIED";
    /** INSTRUMENT_VALUE_LAST_PRICE - Последняя биржевая цена. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_LAST_PRICE"] = 1] = "INSTRUMENT_VALUE_LAST_PRICE";
    /** INSTRUMENT_VALUE_LAST_PRICE_DEALER - Последняя цена дилера. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_LAST_PRICE_DEALER"] = 2] = "INSTRUMENT_VALUE_LAST_PRICE_DEALER";
    /** INSTRUMENT_VALUE_CLOSE_PRICE - Цена закрытия. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_CLOSE_PRICE"] = 3] = "INSTRUMENT_VALUE_CLOSE_PRICE";
    /** INSTRUMENT_VALUE_EVENING_SESSION_PRICE - Цена последней сделки с вечерней сессии. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_EVENING_SESSION_PRICE"] = 4] = "INSTRUMENT_VALUE_EVENING_SESSION_PRICE";
    /** INSTRUMENT_VALUE_OPEN_INTEREST - Открытый интерес, возвращается только для фьючерсов. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_OPEN_INTEREST"] = 5] = "INSTRUMENT_VALUE_OPEN_INTEREST";
    /** INSTRUMENT_VALUE_THEOR_PRICE - Теоретическая цена, возвращается только для опционов. */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_THEOR_PRICE"] = 6] = "INSTRUMENT_VALUE_THEOR_PRICE";
    /** INSTRUMENT_VALUE_YIELD - Доходность */
    MarketValueType[MarketValueType["INSTRUMENT_VALUE_YIELD"] = 7] = "INSTRUMENT_VALUE_YIELD";
    MarketValueType[MarketValueType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(MarketValueType || (MarketValueType = {}));
export function marketValueTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "INSTRUMENT_VALUE_UNSPECIFIED":
            return MarketValueType.INSTRUMENT_VALUE_UNSPECIFIED;
        case 1:
        case "INSTRUMENT_VALUE_LAST_PRICE":
            return MarketValueType.INSTRUMENT_VALUE_LAST_PRICE;
        case 2:
        case "INSTRUMENT_VALUE_LAST_PRICE_DEALER":
            return MarketValueType.INSTRUMENT_VALUE_LAST_PRICE_DEALER;
        case 3:
        case "INSTRUMENT_VALUE_CLOSE_PRICE":
            return MarketValueType.INSTRUMENT_VALUE_CLOSE_PRICE;
        case 4:
        case "INSTRUMENT_VALUE_EVENING_SESSION_PRICE":
            return MarketValueType.INSTRUMENT_VALUE_EVENING_SESSION_PRICE;
        case 5:
        case "INSTRUMENT_VALUE_OPEN_INTEREST":
            return MarketValueType.INSTRUMENT_VALUE_OPEN_INTEREST;
        case 6:
        case "INSTRUMENT_VALUE_THEOR_PRICE":
            return MarketValueType.INSTRUMENT_VALUE_THEOR_PRICE;
        case 7:
        case "INSTRUMENT_VALUE_YIELD":
            return MarketValueType.INSTRUMENT_VALUE_YIELD;
        case -1:
        case "UNRECOGNIZED":
        default:
            return MarketValueType.UNRECOGNIZED;
    }
}
export function marketValueTypeToJSON(object) {
    switch (object) {
        case MarketValueType.INSTRUMENT_VALUE_UNSPECIFIED:
            return "INSTRUMENT_VALUE_UNSPECIFIED";
        case MarketValueType.INSTRUMENT_VALUE_LAST_PRICE:
            return "INSTRUMENT_VALUE_LAST_PRICE";
        case MarketValueType.INSTRUMENT_VALUE_LAST_PRICE_DEALER:
            return "INSTRUMENT_VALUE_LAST_PRICE_DEALER";
        case MarketValueType.INSTRUMENT_VALUE_CLOSE_PRICE:
            return "INSTRUMENT_VALUE_CLOSE_PRICE";
        case MarketValueType.INSTRUMENT_VALUE_EVENING_SESSION_PRICE:
            return "INSTRUMENT_VALUE_EVENING_SESSION_PRICE";
        case MarketValueType.INSTRUMENT_VALUE_OPEN_INTEREST:
            return "INSTRUMENT_VALUE_OPEN_INTEREST";
        case MarketValueType.INSTRUMENT_VALUE_THEOR_PRICE:
            return "INSTRUMENT_VALUE_THEOR_PRICE";
        case MarketValueType.INSTRUMENT_VALUE_YIELD:
            return "INSTRUMENT_VALUE_YIELD";
        case MarketValueType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var OrderBookType;
(function (OrderBookType) {
    /** ORDERBOOK_TYPE_UNSPECIFIED - Не определен. */
    OrderBookType[OrderBookType["ORDERBOOK_TYPE_UNSPECIFIED"] = 0] = "ORDERBOOK_TYPE_UNSPECIFIED";
    /** ORDERBOOK_TYPE_EXCHANGE - Биржевой стакан. */
    OrderBookType[OrderBookType["ORDERBOOK_TYPE_EXCHANGE"] = 1] = "ORDERBOOK_TYPE_EXCHANGE";
    /** ORDERBOOK_TYPE_DEALER - Стакан дилера. */
    OrderBookType[OrderBookType["ORDERBOOK_TYPE_DEALER"] = 2] = "ORDERBOOK_TYPE_DEALER";
    /** ORDERBOOK_TYPE_ALL - Стакан биржевой и дилера. */
    OrderBookType[OrderBookType["ORDERBOOK_TYPE_ALL"] = 3] = "ORDERBOOK_TYPE_ALL";
    OrderBookType[OrderBookType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(OrderBookType || (OrderBookType = {}));
export function orderBookTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "ORDERBOOK_TYPE_UNSPECIFIED":
            return OrderBookType.ORDERBOOK_TYPE_UNSPECIFIED;
        case 1:
        case "ORDERBOOK_TYPE_EXCHANGE":
            return OrderBookType.ORDERBOOK_TYPE_EXCHANGE;
        case 2:
        case "ORDERBOOK_TYPE_DEALER":
            return OrderBookType.ORDERBOOK_TYPE_DEALER;
        case 3:
        case "ORDERBOOK_TYPE_ALL":
            return OrderBookType.ORDERBOOK_TYPE_ALL;
        case -1:
        case "UNRECOGNIZED":
        default:
            return OrderBookType.UNRECOGNIZED;
    }
}
export function orderBookTypeToJSON(object) {
    switch (object) {
        case OrderBookType.ORDERBOOK_TYPE_UNSPECIFIED:
            return "ORDERBOOK_TYPE_UNSPECIFIED";
        case OrderBookType.ORDERBOOK_TYPE_EXCHANGE:
            return "ORDERBOOK_TYPE_EXCHANGE";
        case OrderBookType.ORDERBOOK_TYPE_DEALER:
            return "ORDERBOOK_TYPE_DEALER";
        case OrderBookType.ORDERBOOK_TYPE_ALL:
            return "ORDERBOOK_TYPE_ALL";
        case OrderBookType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Тип последней цены */
export var LastPriceType;
(function (LastPriceType) {
    /** LAST_PRICE_UNSPECIFIED - Не определен. */
    LastPriceType[LastPriceType["LAST_PRICE_UNSPECIFIED"] = 0] = "LAST_PRICE_UNSPECIFIED";
    /** LAST_PRICE_EXCHANGE - Цена биржи. */
    LastPriceType[LastPriceType["LAST_PRICE_EXCHANGE"] = 1] = "LAST_PRICE_EXCHANGE";
    /** LAST_PRICE_DEALER - Цена дилера */
    LastPriceType[LastPriceType["LAST_PRICE_DEALER"] = 2] = "LAST_PRICE_DEALER";
    LastPriceType[LastPriceType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(LastPriceType || (LastPriceType = {}));
export function lastPriceTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "LAST_PRICE_UNSPECIFIED":
            return LastPriceType.LAST_PRICE_UNSPECIFIED;
        case 1:
        case "LAST_PRICE_EXCHANGE":
            return LastPriceType.LAST_PRICE_EXCHANGE;
        case 2:
        case "LAST_PRICE_DEALER":
            return LastPriceType.LAST_PRICE_DEALER;
        case -1:
        case "UNRECOGNIZED":
        default:
            return LastPriceType.UNRECOGNIZED;
    }
}
export function lastPriceTypeToJSON(object) {
    switch (object) {
        case LastPriceType.LAST_PRICE_UNSPECIFIED:
            return "LAST_PRICE_UNSPECIFIED";
        case LastPriceType.LAST_PRICE_EXCHANGE:
            return "LAST_PRICE_EXCHANGE";
        case LastPriceType.LAST_PRICE_DEALER:
            return "LAST_PRICE_DEALER";
        case LastPriceType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var GetCandlesRequest_CandleSource;
(function (GetCandlesRequest_CandleSource) {
    /** CANDLE_SOURCE_UNSPECIFIED - Все свечи. */
    GetCandlesRequest_CandleSource[GetCandlesRequest_CandleSource["CANDLE_SOURCE_UNSPECIFIED"] = 0] = "CANDLE_SOURCE_UNSPECIFIED";
    /** CANDLE_SOURCE_EXCHANGE - Биржевые свечи. */
    GetCandlesRequest_CandleSource[GetCandlesRequest_CandleSource["CANDLE_SOURCE_EXCHANGE"] = 1] = "CANDLE_SOURCE_EXCHANGE";
    /** CANDLE_SOURCE_INCLUDE_WEEKEND - Все свечи с учетом торговли по выходным. */
    GetCandlesRequest_CandleSource[GetCandlesRequest_CandleSource["CANDLE_SOURCE_INCLUDE_WEEKEND"] = 3] = "CANDLE_SOURCE_INCLUDE_WEEKEND";
    GetCandlesRequest_CandleSource[GetCandlesRequest_CandleSource["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(GetCandlesRequest_CandleSource || (GetCandlesRequest_CandleSource = {}));
export function getCandlesRequest_CandleSourceFromJSON(object) {
    switch (object) {
        case 0:
        case "CANDLE_SOURCE_UNSPECIFIED":
            return GetCandlesRequest_CandleSource.CANDLE_SOURCE_UNSPECIFIED;
        case 1:
        case "CANDLE_SOURCE_EXCHANGE":
            return GetCandlesRequest_CandleSource.CANDLE_SOURCE_EXCHANGE;
        case 3:
        case "CANDLE_SOURCE_INCLUDE_WEEKEND":
            return GetCandlesRequest_CandleSource.CANDLE_SOURCE_INCLUDE_WEEKEND;
        case -1:
        case "UNRECOGNIZED":
        default:
            return GetCandlesRequest_CandleSource.UNRECOGNIZED;
    }
}
export function getCandlesRequest_CandleSourceToJSON(object) {
    switch (object) {
        case GetCandlesRequest_CandleSource.CANDLE_SOURCE_UNSPECIFIED:
            return "CANDLE_SOURCE_UNSPECIFIED";
        case GetCandlesRequest_CandleSource.CANDLE_SOURCE_EXCHANGE:
            return "CANDLE_SOURCE_EXCHANGE";
        case GetCandlesRequest_CandleSource.CANDLE_SOURCE_INCLUDE_WEEKEND:
            return "CANDLE_SOURCE_INCLUDE_WEEKEND";
        case GetCandlesRequest_CandleSource.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
/** Интервал свечи. */
export var GetTechAnalysisRequest_IndicatorInterval;
(function (GetTechAnalysisRequest_IndicatorInterval) {
    /** INDICATOR_INTERVAL_UNSPECIFIED - Интервал не определен. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_UNSPECIFIED"] = 0] = "INDICATOR_INTERVAL_UNSPECIFIED";
    /** INDICATOR_INTERVAL_ONE_MINUTE - 1 минута. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_ONE_MINUTE"] = 1] = "INDICATOR_INTERVAL_ONE_MINUTE";
    /** INDICATOR_INTERVAL_FIVE_MINUTES - 5 минут. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_FIVE_MINUTES"] = 2] = "INDICATOR_INTERVAL_FIVE_MINUTES";
    /** INDICATOR_INTERVAL_FIFTEEN_MINUTES - 15 минут. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_FIFTEEN_MINUTES"] = 3] = "INDICATOR_INTERVAL_FIFTEEN_MINUTES";
    /** INDICATOR_INTERVAL_ONE_HOUR - 1 час. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_ONE_HOUR"] = 4] = "INDICATOR_INTERVAL_ONE_HOUR";
    /** INDICATOR_INTERVAL_ONE_DAY - 1 день. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_ONE_DAY"] = 5] = "INDICATOR_INTERVAL_ONE_DAY";
    /** INDICATOR_INTERVAL_2_MIN - 2 минуты. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_2_MIN"] = 6] = "INDICATOR_INTERVAL_2_MIN";
    /** INDICATOR_INTERVAL_3_MIN - 3 минуты. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_3_MIN"] = 7] = "INDICATOR_INTERVAL_3_MIN";
    /** INDICATOR_INTERVAL_10_MIN - 10 минут. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_10_MIN"] = 8] = "INDICATOR_INTERVAL_10_MIN";
    /** INDICATOR_INTERVAL_30_MIN - 30 минут. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_30_MIN"] = 9] = "INDICATOR_INTERVAL_30_MIN";
    /** INDICATOR_INTERVAL_2_HOUR - 2 часа. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_2_HOUR"] = 10] = "INDICATOR_INTERVAL_2_HOUR";
    /** INDICATOR_INTERVAL_4_HOUR - 4 часа. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_4_HOUR"] = 11] = "INDICATOR_INTERVAL_4_HOUR";
    /** INDICATOR_INTERVAL_WEEK - Неделя. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_WEEK"] = 12] = "INDICATOR_INTERVAL_WEEK";
    /** INDICATOR_INTERVAL_MONTH - Месяц. */
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["INDICATOR_INTERVAL_MONTH"] = 13] = "INDICATOR_INTERVAL_MONTH";
    GetTechAnalysisRequest_IndicatorInterval[GetTechAnalysisRequest_IndicatorInterval["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(GetTechAnalysisRequest_IndicatorInterval || (GetTechAnalysisRequest_IndicatorInterval = {}));
export function getTechAnalysisRequest_IndicatorIntervalFromJSON(object) {
    switch (object) {
        case 0:
        case "INDICATOR_INTERVAL_UNSPECIFIED":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_UNSPECIFIED;
        case 1:
        case "INDICATOR_INTERVAL_ONE_MINUTE":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_ONE_MINUTE;
        case 2:
        case "INDICATOR_INTERVAL_FIVE_MINUTES":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_FIVE_MINUTES;
        case 3:
        case "INDICATOR_INTERVAL_FIFTEEN_MINUTES":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_FIFTEEN_MINUTES;
        case 4:
        case "INDICATOR_INTERVAL_ONE_HOUR":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_ONE_HOUR;
        case 5:
        case "INDICATOR_INTERVAL_ONE_DAY":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_ONE_DAY;
        case 6:
        case "INDICATOR_INTERVAL_2_MIN":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_2_MIN;
        case 7:
        case "INDICATOR_INTERVAL_3_MIN":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_3_MIN;
        case 8:
        case "INDICATOR_INTERVAL_10_MIN":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_10_MIN;
        case 9:
        case "INDICATOR_INTERVAL_30_MIN":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_30_MIN;
        case 10:
        case "INDICATOR_INTERVAL_2_HOUR":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_2_HOUR;
        case 11:
        case "INDICATOR_INTERVAL_4_HOUR":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_4_HOUR;
        case 12:
        case "INDICATOR_INTERVAL_WEEK":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_WEEK;
        case 13:
        case "INDICATOR_INTERVAL_MONTH":
            return GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_MONTH;
        case -1:
        case "UNRECOGNIZED":
        default:
            return GetTechAnalysisRequest_IndicatorInterval.UNRECOGNIZED;
    }
}
export function getTechAnalysisRequest_IndicatorIntervalToJSON(object) {
    switch (object) {
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_UNSPECIFIED:
            return "INDICATOR_INTERVAL_UNSPECIFIED";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_ONE_MINUTE:
            return "INDICATOR_INTERVAL_ONE_MINUTE";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_FIVE_MINUTES:
            return "INDICATOR_INTERVAL_FIVE_MINUTES";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_FIFTEEN_MINUTES:
            return "INDICATOR_INTERVAL_FIFTEEN_MINUTES";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_ONE_HOUR:
            return "INDICATOR_INTERVAL_ONE_HOUR";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_ONE_DAY:
            return "INDICATOR_INTERVAL_ONE_DAY";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_2_MIN:
            return "INDICATOR_INTERVAL_2_MIN";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_3_MIN:
            return "INDICATOR_INTERVAL_3_MIN";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_10_MIN:
            return "INDICATOR_INTERVAL_10_MIN";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_30_MIN:
            return "INDICATOR_INTERVAL_30_MIN";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_2_HOUR:
            return "INDICATOR_INTERVAL_2_HOUR";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_4_HOUR:
            return "INDICATOR_INTERVAL_4_HOUR";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_WEEK:
            return "INDICATOR_INTERVAL_WEEK";
        case GetTechAnalysisRequest_IndicatorInterval.INDICATOR_INTERVAL_MONTH:
            return "INDICATOR_INTERVAL_MONTH";
        case GetTechAnalysisRequest_IndicatorInterval.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var GetTechAnalysisRequest_TypeOfPrice;
(function (GetTechAnalysisRequest_TypeOfPrice) {
    /** TYPE_OF_PRICE_UNSPECIFIED - Не указано. */
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["TYPE_OF_PRICE_UNSPECIFIED"] = 0] = "TYPE_OF_PRICE_UNSPECIFIED";
    /** TYPE_OF_PRICE_CLOSE - Цена закрытия. */
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["TYPE_OF_PRICE_CLOSE"] = 1] = "TYPE_OF_PRICE_CLOSE";
    /** TYPE_OF_PRICE_OPEN - Цена открытия. */
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["TYPE_OF_PRICE_OPEN"] = 2] = "TYPE_OF_PRICE_OPEN";
    /** TYPE_OF_PRICE_HIGH - Максимальное значение за выбранный интервал. */
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["TYPE_OF_PRICE_HIGH"] = 3] = "TYPE_OF_PRICE_HIGH";
    /** TYPE_OF_PRICE_LOW - Минимальное значение за выбранный интервал. */
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["TYPE_OF_PRICE_LOW"] = 4] = "TYPE_OF_PRICE_LOW";
    /** TYPE_OF_PRICE_AVG - Среднее значение по показателям [ (close + open + high + low) / 4 ]. */
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["TYPE_OF_PRICE_AVG"] = 5] = "TYPE_OF_PRICE_AVG";
    GetTechAnalysisRequest_TypeOfPrice[GetTechAnalysisRequest_TypeOfPrice["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(GetTechAnalysisRequest_TypeOfPrice || (GetTechAnalysisRequest_TypeOfPrice = {}));
export function getTechAnalysisRequest_TypeOfPriceFromJSON(object) {
    switch (object) {
        case 0:
        case "TYPE_OF_PRICE_UNSPECIFIED":
            return GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_UNSPECIFIED;
        case 1:
        case "TYPE_OF_PRICE_CLOSE":
            return GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_CLOSE;
        case 2:
        case "TYPE_OF_PRICE_OPEN":
            return GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_OPEN;
        case 3:
        case "TYPE_OF_PRICE_HIGH":
            return GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_HIGH;
        case 4:
        case "TYPE_OF_PRICE_LOW":
            return GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_LOW;
        case 5:
        case "TYPE_OF_PRICE_AVG":
            return GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_AVG;
        case -1:
        case "UNRECOGNIZED":
        default:
            return GetTechAnalysisRequest_TypeOfPrice.UNRECOGNIZED;
    }
}
export function getTechAnalysisRequest_TypeOfPriceToJSON(object) {
    switch (object) {
        case GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_UNSPECIFIED:
            return "TYPE_OF_PRICE_UNSPECIFIED";
        case GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_CLOSE:
            return "TYPE_OF_PRICE_CLOSE";
        case GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_OPEN:
            return "TYPE_OF_PRICE_OPEN";
        case GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_HIGH:
            return "TYPE_OF_PRICE_HIGH";
        case GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_LOW:
            return "TYPE_OF_PRICE_LOW";
        case GetTechAnalysisRequest_TypeOfPrice.TYPE_OF_PRICE_AVG:
            return "TYPE_OF_PRICE_AVG";
        case GetTechAnalysisRequest_TypeOfPrice.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
export var GetTechAnalysisRequest_IndicatorType;
(function (GetTechAnalysisRequest_IndicatorType) {
    /** INDICATOR_TYPE_UNSPECIFIED - Не определен. */
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["INDICATOR_TYPE_UNSPECIFIED"] = 0] = "INDICATOR_TYPE_UNSPECIFIED";
    /** INDICATOR_TYPE_BB - Bollinger Bands — линия Боллинжера. */
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["INDICATOR_TYPE_BB"] = 1] = "INDICATOR_TYPE_BB";
    /** INDICATOR_TYPE_EMA - Exponential Moving Average — EMA, экспоненциальная скользящая средняя. */
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["INDICATOR_TYPE_EMA"] = 2] = "INDICATOR_TYPE_EMA";
    /** INDICATOR_TYPE_RSI - Relative Strength Index — индекс относительной силы. */
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["INDICATOR_TYPE_RSI"] = 3] = "INDICATOR_TYPE_RSI";
    /** INDICATOR_TYPE_MACD - Moving Average Convergence/Divergence — схождение/расхождение скользящих средних. */
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["INDICATOR_TYPE_MACD"] = 4] = "INDICATOR_TYPE_MACD";
    /** INDICATOR_TYPE_SMA - Simple Moving Average — простое скользящее среднее. */
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["INDICATOR_TYPE_SMA"] = 5] = "INDICATOR_TYPE_SMA";
    GetTechAnalysisRequest_IndicatorType[GetTechAnalysisRequest_IndicatorType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(GetTechAnalysisRequest_IndicatorType || (GetTechAnalysisRequest_IndicatorType = {}));
export function getTechAnalysisRequest_IndicatorTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "INDICATOR_TYPE_UNSPECIFIED":
            return GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_UNSPECIFIED;
        case 1:
        case "INDICATOR_TYPE_BB":
            return GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_BB;
        case 2:
        case "INDICATOR_TYPE_EMA":
            return GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_EMA;
        case 3:
        case "INDICATOR_TYPE_RSI":
            return GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_RSI;
        case 4:
        case "INDICATOR_TYPE_MACD":
            return GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_MACD;
        case 5:
        case "INDICATOR_TYPE_SMA":
            return GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_SMA;
        case -1:
        case "UNRECOGNIZED":
        default:
            return GetTechAnalysisRequest_IndicatorType.UNRECOGNIZED;
    }
}
export function getTechAnalysisRequest_IndicatorTypeToJSON(object) {
    switch (object) {
        case GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_UNSPECIFIED:
            return "INDICATOR_TYPE_UNSPECIFIED";
        case GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_BB:
            return "INDICATOR_TYPE_BB";
        case GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_EMA:
            return "INDICATOR_TYPE_EMA";
        case GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_RSI:
            return "INDICATOR_TYPE_RSI";
        case GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_MACD:
            return "INDICATOR_TYPE_MACD";
        case GetTechAnalysisRequest_IndicatorType.INDICATOR_TYPE_SMA:
            return "INDICATOR_TYPE_SMA";
        case GetTechAnalysisRequest_IndicatorType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function createBaseMarketDataRequest() {
    return {
        subscribeCandlesRequest: undefined,
        subscribeOrderBookRequest: undefined,
        subscribeTradesRequest: undefined,
        subscribeInfoRequest: undefined,
        subscribeLastPriceRequest: undefined,
        getMySubscriptions: undefined,
        ping: undefined,
        pingSettings: undefined,
    };
}
export const MarketDataRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscribeCandlesRequest !== undefined) {
            SubscribeCandlesRequest.encode(message.subscribeCandlesRequest, writer.uint32(10).fork()).ldelim();
        }
        if (message.subscribeOrderBookRequest !== undefined) {
            SubscribeOrderBookRequest.encode(message.subscribeOrderBookRequest, writer.uint32(18).fork()).ldelim();
        }
        if (message.subscribeTradesRequest !== undefined) {
            SubscribeTradesRequest.encode(message.subscribeTradesRequest, writer.uint32(26).fork()).ldelim();
        }
        if (message.subscribeInfoRequest !== undefined) {
            SubscribeInfoRequest.encode(message.subscribeInfoRequest, writer.uint32(34).fork()).ldelim();
        }
        if (message.subscribeLastPriceRequest !== undefined) {
            SubscribeLastPriceRequest.encode(message.subscribeLastPriceRequest, writer.uint32(42).fork()).ldelim();
        }
        if (message.getMySubscriptions !== undefined) {
            GetMySubscriptions.encode(message.getMySubscriptions, writer.uint32(50).fork()).ldelim();
        }
        if (message.ping !== undefined) {
            PingRequest.encode(message.ping, writer.uint32(58).fork()).ldelim();
        }
        if (message.pingSettings !== undefined) {
            PingDelaySettings.encode(message.pingSettings, writer.uint32(122).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMarketDataRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.subscribeCandlesRequest = SubscribeCandlesRequest.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.subscribeOrderBookRequest = SubscribeOrderBookRequest.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.subscribeTradesRequest = SubscribeTradesRequest.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.subscribeInfoRequest = SubscribeInfoRequest.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.subscribeLastPriceRequest = SubscribeLastPriceRequest.decode(reader, reader.uint32());
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.getMySubscriptions = GetMySubscriptions.decode(reader, reader.uint32());
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.ping = PingRequest.decode(reader, reader.uint32());
                    continue;
                case 15:
                    if (tag !== 122) {
                        break;
                    }
                    message.pingSettings = PingDelaySettings.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscribeCandlesRequest: isSet(object.subscribeCandlesRequest)
                ? SubscribeCandlesRequest.fromJSON(object.subscribeCandlesRequest)
                : undefined,
            subscribeOrderBookRequest: isSet(object.subscribeOrderBookRequest)
                ? SubscribeOrderBookRequest.fromJSON(object.subscribeOrderBookRequest)
                : undefined,
            subscribeTradesRequest: isSet(object.subscribeTradesRequest)
                ? SubscribeTradesRequest.fromJSON(object.subscribeTradesRequest)
                : undefined,
            subscribeInfoRequest: isSet(object.subscribeInfoRequest)
                ? SubscribeInfoRequest.fromJSON(object.subscribeInfoRequest)
                : undefined,
            subscribeLastPriceRequest: isSet(object.subscribeLastPriceRequest)
                ? SubscribeLastPriceRequest.fromJSON(object.subscribeLastPriceRequest)
                : undefined,
            getMySubscriptions: isSet(object.getMySubscriptions)
                ? GetMySubscriptions.fromJSON(object.getMySubscriptions)
                : undefined,
            ping: isSet(object.ping) ? PingRequest.fromJSON(object.ping) : undefined,
            pingSettings: isSet(object.pingSettings) ? PingDelaySettings.fromJSON(object.pingSettings) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscribeCandlesRequest !== undefined) {
            obj.subscribeCandlesRequest = SubscribeCandlesRequest.toJSON(message.subscribeCandlesRequest);
        }
        if (message.subscribeOrderBookRequest !== undefined) {
            obj.subscribeOrderBookRequest = SubscribeOrderBookRequest.toJSON(message.subscribeOrderBookRequest);
        }
        if (message.subscribeTradesRequest !== undefined) {
            obj.subscribeTradesRequest = SubscribeTradesRequest.toJSON(message.subscribeTradesRequest);
        }
        if (message.subscribeInfoRequest !== undefined) {
            obj.subscribeInfoRequest = SubscribeInfoRequest.toJSON(message.subscribeInfoRequest);
        }
        if (message.subscribeLastPriceRequest !== undefined) {
            obj.subscribeLastPriceRequest = SubscribeLastPriceRequest.toJSON(message.subscribeLastPriceRequest);
        }
        if (message.getMySubscriptions !== undefined) {
            obj.getMySubscriptions = GetMySubscriptions.toJSON(message.getMySubscriptions);
        }
        if (message.ping !== undefined) {
            obj.ping = PingRequest.toJSON(message.ping);
        }
        if (message.pingSettings !== undefined) {
            obj.pingSettings = PingDelaySettings.toJSON(message.pingSettings);
        }
        return obj;
    },
};
function createBaseMarketDataServerSideStreamRequest() {
    return {
        subscribeCandlesRequest: undefined,
        subscribeOrderBookRequest: undefined,
        subscribeTradesRequest: undefined,
        subscribeInfoRequest: undefined,
        subscribeLastPriceRequest: undefined,
        pingSettings: undefined,
    };
}
export const MarketDataServerSideStreamRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscribeCandlesRequest !== undefined) {
            SubscribeCandlesRequest.encode(message.subscribeCandlesRequest, writer.uint32(10).fork()).ldelim();
        }
        if (message.subscribeOrderBookRequest !== undefined) {
            SubscribeOrderBookRequest.encode(message.subscribeOrderBookRequest, writer.uint32(18).fork()).ldelim();
        }
        if (message.subscribeTradesRequest !== undefined) {
            SubscribeTradesRequest.encode(message.subscribeTradesRequest, writer.uint32(26).fork()).ldelim();
        }
        if (message.subscribeInfoRequest !== undefined) {
            SubscribeInfoRequest.encode(message.subscribeInfoRequest, writer.uint32(34).fork()).ldelim();
        }
        if (message.subscribeLastPriceRequest !== undefined) {
            SubscribeLastPriceRequest.encode(message.subscribeLastPriceRequest, writer.uint32(42).fork()).ldelim();
        }
        if (message.pingSettings !== undefined) {
            PingDelaySettings.encode(message.pingSettings, writer.uint32(122).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMarketDataServerSideStreamRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.subscribeCandlesRequest = SubscribeCandlesRequest.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.subscribeOrderBookRequest = SubscribeOrderBookRequest.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.subscribeTradesRequest = SubscribeTradesRequest.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.subscribeInfoRequest = SubscribeInfoRequest.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.subscribeLastPriceRequest = SubscribeLastPriceRequest.decode(reader, reader.uint32());
                    continue;
                case 15:
                    if (tag !== 122) {
                        break;
                    }
                    message.pingSettings = PingDelaySettings.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscribeCandlesRequest: isSet(object.subscribeCandlesRequest)
                ? SubscribeCandlesRequest.fromJSON(object.subscribeCandlesRequest)
                : undefined,
            subscribeOrderBookRequest: isSet(object.subscribeOrderBookRequest)
                ? SubscribeOrderBookRequest.fromJSON(object.subscribeOrderBookRequest)
                : undefined,
            subscribeTradesRequest: isSet(object.subscribeTradesRequest)
                ? SubscribeTradesRequest.fromJSON(object.subscribeTradesRequest)
                : undefined,
            subscribeInfoRequest: isSet(object.subscribeInfoRequest)
                ? SubscribeInfoRequest.fromJSON(object.subscribeInfoRequest)
                : undefined,
            subscribeLastPriceRequest: isSet(object.subscribeLastPriceRequest)
                ? SubscribeLastPriceRequest.fromJSON(object.subscribeLastPriceRequest)
                : undefined,
            pingSettings: isSet(object.pingSettings) ? PingDelaySettings.fromJSON(object.pingSettings) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscribeCandlesRequest !== undefined) {
            obj.subscribeCandlesRequest = SubscribeCandlesRequest.toJSON(message.subscribeCandlesRequest);
        }
        if (message.subscribeOrderBookRequest !== undefined) {
            obj.subscribeOrderBookRequest = SubscribeOrderBookRequest.toJSON(message.subscribeOrderBookRequest);
        }
        if (message.subscribeTradesRequest !== undefined) {
            obj.subscribeTradesRequest = SubscribeTradesRequest.toJSON(message.subscribeTradesRequest);
        }
        if (message.subscribeInfoRequest !== undefined) {
            obj.subscribeInfoRequest = SubscribeInfoRequest.toJSON(message.subscribeInfoRequest);
        }
        if (message.subscribeLastPriceRequest !== undefined) {
            obj.subscribeLastPriceRequest = SubscribeLastPriceRequest.toJSON(message.subscribeLastPriceRequest);
        }
        if (message.pingSettings !== undefined) {
            obj.pingSettings = PingDelaySettings.toJSON(message.pingSettings);
        }
        return obj;
    },
};
function createBaseMarketDataResponse() {
    return {
        subscribeCandlesResponse: undefined,
        subscribeOrderBookResponse: undefined,
        subscribeTradesResponse: undefined,
        subscribeInfoResponse: undefined,
        candle: undefined,
        trade: undefined,
        orderbook: undefined,
        tradingStatus: undefined,
        ping: undefined,
        subscribeLastPriceResponse: undefined,
        lastPrice: undefined,
        openInterest: undefined,
    };
}
export const MarketDataResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscribeCandlesResponse !== undefined) {
            SubscribeCandlesResponse.encode(message.subscribeCandlesResponse, writer.uint32(10).fork()).ldelim();
        }
        if (message.subscribeOrderBookResponse !== undefined) {
            SubscribeOrderBookResponse.encode(message.subscribeOrderBookResponse, writer.uint32(18).fork()).ldelim();
        }
        if (message.subscribeTradesResponse !== undefined) {
            SubscribeTradesResponse.encode(message.subscribeTradesResponse, writer.uint32(26).fork()).ldelim();
        }
        if (message.subscribeInfoResponse !== undefined) {
            SubscribeInfoResponse.encode(message.subscribeInfoResponse, writer.uint32(34).fork()).ldelim();
        }
        if (message.candle !== undefined) {
            Candle.encode(message.candle, writer.uint32(42).fork()).ldelim();
        }
        if (message.trade !== undefined) {
            Trade.encode(message.trade, writer.uint32(50).fork()).ldelim();
        }
        if (message.orderbook !== undefined) {
            OrderBook.encode(message.orderbook, writer.uint32(58).fork()).ldelim();
        }
        if (message.tradingStatus !== undefined) {
            TradingStatus.encode(message.tradingStatus, writer.uint32(66).fork()).ldelim();
        }
        if (message.ping !== undefined) {
            Ping.encode(message.ping, writer.uint32(74).fork()).ldelim();
        }
        if (message.subscribeLastPriceResponse !== undefined) {
            SubscribeLastPriceResponse.encode(message.subscribeLastPriceResponse, writer.uint32(82).fork()).ldelim();
        }
        if (message.lastPrice !== undefined) {
            LastPrice.encode(message.lastPrice, writer.uint32(90).fork()).ldelim();
        }
        if (message.openInterest !== undefined) {
            OpenInterest.encode(message.openInterest, writer.uint32(98).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMarketDataResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.subscribeCandlesResponse = SubscribeCandlesResponse.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.subscribeOrderBookResponse = SubscribeOrderBookResponse.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.subscribeTradesResponse = SubscribeTradesResponse.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.subscribeInfoResponse = SubscribeInfoResponse.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.candle = Candle.decode(reader, reader.uint32());
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.trade = Trade.decode(reader, reader.uint32());
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.orderbook = OrderBook.decode(reader, reader.uint32());
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.tradingStatus = TradingStatus.decode(reader, reader.uint32());
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.ping = Ping.decode(reader, reader.uint32());
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.subscribeLastPriceResponse = SubscribeLastPriceResponse.decode(reader, reader.uint32());
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.lastPrice = LastPrice.decode(reader, reader.uint32());
                    continue;
                case 12:
                    if (tag !== 98) {
                        break;
                    }
                    message.openInterest = OpenInterest.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscribeCandlesResponse: isSet(object.subscribeCandlesResponse)
                ? SubscribeCandlesResponse.fromJSON(object.subscribeCandlesResponse)
                : undefined,
            subscribeOrderBookResponse: isSet(object.subscribeOrderBookResponse)
                ? SubscribeOrderBookResponse.fromJSON(object.subscribeOrderBookResponse)
                : undefined,
            subscribeTradesResponse: isSet(object.subscribeTradesResponse)
                ? SubscribeTradesResponse.fromJSON(object.subscribeTradesResponse)
                : undefined,
            subscribeInfoResponse: isSet(object.subscribeInfoResponse)
                ? SubscribeInfoResponse.fromJSON(object.subscribeInfoResponse)
                : undefined,
            candle: isSet(object.candle) ? Candle.fromJSON(object.candle) : undefined,
            trade: isSet(object.trade) ? Trade.fromJSON(object.trade) : undefined,
            orderbook: isSet(object.orderbook) ? OrderBook.fromJSON(object.orderbook) : undefined,
            tradingStatus: isSet(object.tradingStatus) ? TradingStatus.fromJSON(object.tradingStatus) : undefined,
            ping: isSet(object.ping) ? Ping.fromJSON(object.ping) : undefined,
            subscribeLastPriceResponse: isSet(object.subscribeLastPriceResponse)
                ? SubscribeLastPriceResponse.fromJSON(object.subscribeLastPriceResponse)
                : undefined,
            lastPrice: isSet(object.lastPrice) ? LastPrice.fromJSON(object.lastPrice) : undefined,
            openInterest: isSet(object.openInterest) ? OpenInterest.fromJSON(object.openInterest) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscribeCandlesResponse !== undefined) {
            obj.subscribeCandlesResponse = SubscribeCandlesResponse.toJSON(message.subscribeCandlesResponse);
        }
        if (message.subscribeOrderBookResponse !== undefined) {
            obj.subscribeOrderBookResponse = SubscribeOrderBookResponse.toJSON(message.subscribeOrderBookResponse);
        }
        if (message.subscribeTradesResponse !== undefined) {
            obj.subscribeTradesResponse = SubscribeTradesResponse.toJSON(message.subscribeTradesResponse);
        }
        if (message.subscribeInfoResponse !== undefined) {
            obj.subscribeInfoResponse = SubscribeInfoResponse.toJSON(message.subscribeInfoResponse);
        }
        if (message.candle !== undefined) {
            obj.candle = Candle.toJSON(message.candle);
        }
        if (message.trade !== undefined) {
            obj.trade = Trade.toJSON(message.trade);
        }
        if (message.orderbook !== undefined) {
            obj.orderbook = OrderBook.toJSON(message.orderbook);
        }
        if (message.tradingStatus !== undefined) {
            obj.tradingStatus = TradingStatus.toJSON(message.tradingStatus);
        }
        if (message.ping !== undefined) {
            obj.ping = Ping.toJSON(message.ping);
        }
        if (message.subscribeLastPriceResponse !== undefined) {
            obj.subscribeLastPriceResponse = SubscribeLastPriceResponse.toJSON(message.subscribeLastPriceResponse);
        }
        if (message.lastPrice !== undefined) {
            obj.lastPrice = LastPrice.toJSON(message.lastPrice);
        }
        if (message.openInterest !== undefined) {
            obj.openInterest = OpenInterest.toJSON(message.openInterest);
        }
        return obj;
    },
};
function createBaseSubscribeCandlesRequest() {
    return { subscriptionAction: 0, instruments: [], waitingClose: false, candleSourceType: undefined };
}
export const SubscribeCandlesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscriptionAction !== 0) {
            writer.uint32(8).int32(message.subscriptionAction);
        }
        for (const v of message.instruments) {
            CandleInstrument.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.waitingClose === true) {
            writer.uint32(24).bool(message.waitingClose);
        }
        if (message.candleSourceType !== undefined) {
            writer.uint32(72).int32(message.candleSourceType);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeCandlesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instruments.push(CandleInstrument.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.waitingClose = reader.bool();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.candleSourceType = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => CandleInstrument.fromJSON(e))
                : [],
            waitingClose: isSet(object.waitingClose) ? globalThis.Boolean(object.waitingClose) : false,
            candleSourceType: isSet(object.candleSourceType)
                ? getCandlesRequest_CandleSourceFromJSON(object.candleSourceType)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => CandleInstrument.toJSON(e));
        }
        if (message.waitingClose === true) {
            obj.waitingClose = message.waitingClose;
        }
        if (message.candleSourceType !== undefined) {
            obj.candleSourceType = getCandlesRequest_CandleSourceToJSON(message.candleSourceType);
        }
        return obj;
    },
};
function createBaseCandleInstrument() {
    return { figi: "", interval: 0, instrumentId: "" };
}
export const CandleInstrument = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.interval !== 0) {
            writer.uint32(16).int32(message.interval);
        }
        if (message.instrumentId !== "") {
            writer.uint32(26).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCandleInstrument();
        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.interval = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.instrumentId = 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) : "",
            interval: isSet(object.interval) ? subscriptionIntervalFromJSON(object.interval) : 0,
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.interval !== 0) {
            obj.interval = subscriptionIntervalToJSON(message.interval);
        }
        if (message.instrumentId !== "") {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseSubscribeCandlesResponse() {
    return { trackingId: "", candlesSubscriptions: [] };
}
export const SubscribeCandlesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.trackingId !== "") {
            writer.uint32(10).string(message.trackingId);
        }
        for (const v of message.candlesSubscriptions) {
            CandleSubscription.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeCandlesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.trackingId = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.candlesSubscriptions.push(CandleSubscription.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            trackingId: isSet(object.trackingId) ? globalThis.String(object.trackingId) : "",
            candlesSubscriptions: globalThis.Array.isArray(object?.candlesSubscriptions)
                ? object.candlesSubscriptions.map((e) => CandleSubscription.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.trackingId !== "") {
            obj.trackingId = message.trackingId;
        }
        if (message.candlesSubscriptions?.length) {
            obj.candlesSubscriptions = message.candlesSubscriptions.map((e) => CandleSubscription.toJSON(e));
        }
        return obj;
    },
};
function createBaseCandleSubscription() {
    return {
        figi: "",
        interval: 0,
        subscriptionStatus: 0,
        instrumentUid: "",
        waitingClose: false,
        streamId: "",
        subscriptionId: "",
        subscriptionAction: 0,
        candleSourceType: undefined,
        ticker: "",
        classCode: "",
    };
}
export const CandleSubscription = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.interval !== 0) {
            writer.uint32(16).int32(message.interval);
        }
        if (message.subscriptionStatus !== 0) {
            writer.uint32(24).int32(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(34).string(message.instrumentUid);
        }
        if (message.waitingClose === true) {
            writer.uint32(40).bool(message.waitingClose);
        }
        if (message.streamId !== "") {
            writer.uint32(50).string(message.streamId);
        }
        if (message.subscriptionId !== "") {
            writer.uint32(58).string(message.subscriptionId);
        }
        if (message.subscriptionAction !== 0) {
            writer.uint32(64).int32(message.subscriptionAction);
        }
        if (message.candleSourceType !== undefined) {
            writer.uint32(72).int32(message.candleSourceType);
        }
        if (message.ticker !== "") {
            writer.uint32(82).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(90).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCandleSubscription();
        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.interval = reader.int32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.subscriptionStatus = reader.int32();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.waitingClose = reader.bool();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.streamId = reader.string();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.subscriptionId = reader.string();
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.candleSourceType = reader.int32();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.classCode = 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) : "",
            interval: isSet(object.interval) ? subscriptionIntervalFromJSON(object.interval) : 0,
            subscriptionStatus: isSet(object.subscriptionStatus) ? subscriptionStatusFromJSON(object.subscriptionStatus) : 0,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            waitingClose: isSet(object.waitingClose) ? globalThis.Boolean(object.waitingClose) : false,
            streamId: isSet(object.streamId) ? globalThis.String(object.streamId) : "",
            subscriptionId: isSet(object.subscriptionId) ? globalThis.String(object.subscriptionId) : "",
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            candleSourceType: isSet(object.candleSourceType)
                ? getCandlesRequest_CandleSourceFromJSON(object.candleSourceType)
                : undefined,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.interval !== 0) {
            obj.interval = subscriptionIntervalToJSON(message.interval);
        }
        if (message.subscriptionStatus !== 0) {
            obj.subscriptionStatus = subscriptionStatusToJSON(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.waitingClose === true) {
            obj.waitingClose = message.waitingClose;
        }
        if (message.streamId !== "") {
            obj.streamId = message.streamId;
        }
        if (message.subscriptionId !== "") {
            obj.subscriptionId = message.subscriptionId;
        }
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.candleSourceType !== undefined) {
            obj.candleSourceType = getCandlesRequest_CandleSourceToJSON(message.candleSourceType);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseSubscribeOrderBookRequest() {
    return { subscriptionAction: 0, instruments: [] };
}
export const SubscribeOrderBookRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscriptionAction !== 0) {
            writer.uint32(8).int32(message.subscriptionAction);
        }
        for (const v of message.instruments) {
            OrderBookInstrument.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeOrderBookRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instruments.push(OrderBookInstrument.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => OrderBookInstrument.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => OrderBookInstrument.toJSON(e));
        }
        return obj;
    },
};
function createBaseOrderBookInstrument() {
    return { figi: "", depth: 0, instrumentId: "", orderBookType: 0 };
}
export const OrderBookInstrument = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.depth !== 0) {
            writer.uint32(16).int32(message.depth);
        }
        if (message.instrumentId !== "") {
            writer.uint32(26).string(message.instrumentId);
        }
        if (message.orderBookType !== 0) {
            writer.uint32(32).int32(message.orderBookType);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseOrderBookInstrument();
        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.depth = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.instrumentId = reader.string();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.orderBookType = reader.int32();
                    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) : "",
            depth: isSet(object.depth) ? globalThis.Number(object.depth) : 0,
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "",
            orderBookType: isSet(object.orderBookType) ? orderBookTypeFromJSON(object.orderBookType) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.depth !== 0) {
            obj.depth = Math.round(message.depth);
        }
        if (message.instrumentId !== "") {
            obj.instrumentId = message.instrumentId;
        }
        if (message.orderBookType !== 0) {
            obj.orderBookType = orderBookTypeToJSON(message.orderBookType);
        }
        return obj;
    },
};
function createBaseSubscribeOrderBookResponse() {
    return { trackingId: "", orderBookSubscriptions: [] };
}
export const SubscribeOrderBookResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.trackingId !== "") {
            writer.uint32(10).string(message.trackingId);
        }
        for (const v of message.orderBookSubscriptions) {
            OrderBookSubscription.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeOrderBookResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.trackingId = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.orderBookSubscriptions.push(OrderBookSubscription.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            trackingId: isSet(object.trackingId) ? globalThis.String(object.trackingId) : "",
            orderBookSubscriptions: globalThis.Array.isArray(object?.orderBookSubscriptions)
                ? object.orderBookSubscriptions.map((e) => OrderBookSubscription.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.trackingId !== "") {
            obj.trackingId = message.trackingId;
        }
        if (message.orderBookSubscriptions?.length) {
            obj.orderBookSubscriptions = message.orderBookSubscriptions.map((e) => OrderBookSubscription.toJSON(e));
        }
        return obj;
    },
};
function createBaseOrderBookSubscription() {
    return {
        figi: "",
        depth: 0,
        subscriptionStatus: 0,
        instrumentUid: "",
        streamId: "",
        subscriptionId: "",
        orderBookType: 0,
        subscriptionAction: 0,
        ticker: "",
        classCode: "",
    };
}
export const OrderBookSubscription = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.depth !== 0) {
            writer.uint32(16).int32(message.depth);
        }
        if (message.subscriptionStatus !== 0) {
            writer.uint32(24).int32(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(34).string(message.instrumentUid);
        }
        if (message.streamId !== "") {
            writer.uint32(42).string(message.streamId);
        }
        if (message.subscriptionId !== "") {
            writer.uint32(50).string(message.subscriptionId);
        }
        if (message.orderBookType !== 0) {
            writer.uint32(56).int32(message.orderBookType);
        }
        if (message.subscriptionAction !== 0) {
            writer.uint32(64).int32(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            writer.uint32(74).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(82).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseOrderBookSubscription();
        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.depth = reader.int32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.subscriptionStatus = reader.int32();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.streamId = reader.string();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.subscriptionId = reader.string();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.orderBookType = reader.int32();
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.classCode = 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) : "",
            depth: isSet(object.depth) ? globalThis.Number(object.depth) : 0,
            subscriptionStatus: isSet(object.subscriptionStatus) ? subscriptionStatusFromJSON(object.subscriptionStatus) : 0,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            streamId: isSet(object.streamId) ? globalThis.String(object.streamId) : "",
            subscriptionId: isSet(object.subscriptionId) ? globalThis.String(object.subscriptionId) : "",
            orderBookType: isSet(object.orderBookType) ? orderBookTypeFromJSON(object.orderBookType) : 0,
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.depth !== 0) {
            obj.depth = Math.round(message.depth);
        }
        if (message.subscriptionStatus !== 0) {
            obj.subscriptionStatus = subscriptionStatusToJSON(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.streamId !== "") {
            obj.streamId = message.streamId;
        }
        if (message.subscriptionId !== "") {
            obj.subscriptionId = message.subscriptionId;
        }
        if (message.orderBookType !== 0) {
            obj.orderBookType = orderBookTypeToJSON(message.orderBookType);
        }
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseSubscribeTradesRequest() {
    return { subscriptionAction: 0, instruments: [], tradeSource: 0, withOpenInterest: false };
}
export const SubscribeTradesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscriptionAction !== 0) {
            writer.uint32(8).int32(message.subscriptionAction);
        }
        for (const v of message.instruments) {
            TradeInstrument.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.tradeSource !== 0) {
            writer.uint32(24).int32(message.tradeSource);
        }
        if (message.withOpenInterest === true) {
            writer.uint32(32).bool(message.withOpenInterest);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeTradesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instruments.push(TradeInstrument.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.tradeSource = reader.int32();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.withOpenInterest = reader.bool();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => TradeInstrument.fromJSON(e))
                : [],
            tradeSource: isSet(object.tradeSource) ? tradeSourceTypeFromJSON(object.tradeSource) : 0,
            withOpenInterest: isSet(object.withOpenInterest) ? globalThis.Boolean(object.withOpenInterest) : false,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => TradeInstrument.toJSON(e));
        }
        if (message.tradeSource !== 0) {
            obj.tradeSource = tradeSourceTypeToJSON(message.tradeSource);
        }
        if (message.withOpenInterest === true) {
            obj.withOpenInterest = message.withOpenInterest;
        }
        return obj;
    },
};
function createBaseTradeInstrument() {
    return { figi: "", instrumentId: "" };
}
export const TradeInstrument = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.instrumentId !== "") {
            writer.uint32(18).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTradeInstrument();
        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 !== 18) {
                        break;
                    }
                    message.instrumentId = 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) : "",
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.instrumentId !== "") {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseSubscribeTradesResponse() {
    return { trackingId: "", tradeSubscriptions: [], tradeSource: 0 };
}
export const SubscribeTradesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.trackingId !== "") {
            writer.uint32(10).string(message.trackingId);
        }
        for (const v of message.tradeSubscriptions) {
            TradeSubscription.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.tradeSource !== 0) {
            writer.uint32(24).int32(message.tradeSource);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeTradesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.trackingId = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.tradeSubscriptions.push(TradeSubscription.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.tradeSource = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            trackingId: isSet(object.trackingId) ? globalThis.String(object.trackingId) : "",
            tradeSubscriptions: globalThis.Array.isArray(object?.tradeSubscriptions)
                ? object.tradeSubscriptions.map((e) => TradeSubscription.fromJSON(e))
                : [],
            tradeSource: isSet(object.tradeSource) ? tradeSourceTypeFromJSON(object.tradeSource) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.trackingId !== "") {
            obj.trackingId = message.trackingId;
        }
        if (message.tradeSubscriptions?.length) {
            obj.tradeSubscriptions = message.tradeSubscriptions.map((e) => TradeSubscription.toJSON(e));
        }
        if (message.tradeSource !== 0) {
            obj.tradeSource = tradeSourceTypeToJSON(message.tradeSource);
        }
        return obj;
    },
};
function createBaseTradeSubscription() {
    return {
        figi: "",
        subscriptionStatus: 0,
        instrumentUid: "",
        streamId: "",
        subscriptionId: "",
        withOpenInterest: false,
        subscriptionAction: 0,
        ticker: "",
        classCode: "",
    };
}
export const TradeSubscription = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.subscriptionStatus !== 0) {
            writer.uint32(16).int32(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(26).string(message.instrumentUid);
        }
        if (message.streamId !== "") {
            writer.uint32(34).string(message.streamId);
        }
        if (message.subscriptionId !== "") {
            writer.uint32(42).string(message.subscriptionId);
        }
        if (message.withOpenInterest === true) {
            writer.uint32(48).bool(message.withOpenInterest);
        }
        if (message.subscriptionAction !== 0) {
            writer.uint32(56).int32(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            writer.uint32(66).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(74).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTradeSubscription();
        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.subscriptionStatus = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.streamId = reader.string();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.subscriptionId = reader.string();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.withOpenInterest = reader.bool();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.classCode = 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) : "",
            subscriptionStatus: isSet(object.subscriptionStatus) ? subscriptionStatusFromJSON(object.subscriptionStatus) : 0,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            streamId: isSet(object.streamId) ? globalThis.String(object.streamId) : "",
            subscriptionId: isSet(object.subscriptionId) ? globalThis.String(object.subscriptionId) : "",
            withOpenInterest: isSet(object.withOpenInterest) ? globalThis.Boolean(object.withOpenInterest) : false,
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.subscriptionStatus !== 0) {
            obj.subscriptionStatus = subscriptionStatusToJSON(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.streamId !== "") {
            obj.streamId = message.streamId;
        }
        if (message.subscriptionId !== "") {
            obj.subscriptionId = message.subscriptionId;
        }
        if (message.withOpenInterest === true) {
            obj.withOpenInterest = message.withOpenInterest;
        }
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseSubscribeInfoRequest() {
    return { subscriptionAction: 0, instruments: [] };
}
export const SubscribeInfoRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscriptionAction !== 0) {
            writer.uint32(8).int32(message.subscriptionAction);
        }
        for (const v of message.instruments) {
            InfoInstrument.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeInfoRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instruments.push(InfoInstrument.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => InfoInstrument.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => InfoInstrument.toJSON(e));
        }
        return obj;
    },
};
function createBaseInfoInstrument() {
    return { figi: "", instrumentId: "" };
}
export const InfoInstrument = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.instrumentId !== "") {
            writer.uint32(18).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseInfoInstrument();
        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 !== 18) {
                        break;
                    }
                    message.instrumentId = 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) : "",
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.instrumentId !== "") {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseSubscribeInfoResponse() {
    return { trackingId: "", infoSubscriptions: [] };
}
export const SubscribeInfoResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.trackingId !== "") {
            writer.uint32(10).string(message.trackingId);
        }
        for (const v of message.infoSubscriptions) {
            InfoSubscription.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeInfoResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.trackingId = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.infoSubscriptions.push(InfoSubscription.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            trackingId: isSet(object.trackingId) ? globalThis.String(object.trackingId) : "",
            infoSubscriptions: globalThis.Array.isArray(object?.infoSubscriptions)
                ? object.infoSubscriptions.map((e) => InfoSubscription.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.trackingId !== "") {
            obj.trackingId = message.trackingId;
        }
        if (message.infoSubscriptions?.length) {
            obj.infoSubscriptions = message.infoSubscriptions.map((e) => InfoSubscription.toJSON(e));
        }
        return obj;
    },
};
function createBaseInfoSubscription() {
    return {
        figi: "",
        subscriptionStatus: 0,
        instrumentUid: "",
        streamId: "",
        subscriptionId: "",
        subscriptionAction: 0,
        ticker: "",
        classCode: "",
    };
}
export const InfoSubscription = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.subscriptionStatus !== 0) {
            writer.uint32(16).int32(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(26).string(message.instrumentUid);
        }
        if (message.streamId !== "") {
            writer.uint32(34).string(message.streamId);
        }
        if (message.subscriptionId !== "") {
            writer.uint32(42).string(message.subscriptionId);
        }
        if (message.subscriptionAction !== 0) {
            writer.uint32(48).int32(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            writer.uint32(58).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(66).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseInfoSubscription();
        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.subscriptionStatus = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.streamId = reader.string();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.subscriptionId = reader.string();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.classCode = 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) : "",
            subscriptionStatus: isSet(object.subscriptionStatus) ? subscriptionStatusFromJSON(object.subscriptionStatus) : 0,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            streamId: isSet(object.streamId) ? globalThis.String(object.streamId) : "",
            subscriptionId: isSet(object.subscriptionId) ? globalThis.String(object.subscriptionId) : "",
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.subscriptionStatus !== 0) {
            obj.subscriptionStatus = subscriptionStatusToJSON(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.streamId !== "") {
            obj.streamId = message.streamId;
        }
        if (message.subscriptionId !== "") {
            obj.subscriptionId = message.subscriptionId;
        }
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseSubscribeLastPriceRequest() {
    return { subscriptionAction: 0, instruments: [] };
}
export const SubscribeLastPriceRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.subscriptionAction !== 0) {
            writer.uint32(8).int32(message.subscriptionAction);
        }
        for (const v of message.instruments) {
            LastPriceInstrument.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeLastPriceRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instruments.push(LastPriceInstrument.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => LastPriceInstrument.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => LastPriceInstrument.toJSON(e));
        }
        return obj;
    },
};
function createBaseLastPriceInstrument() {
    return { figi: "", instrumentId: "" };
}
export const LastPriceInstrument = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.instrumentId !== "") {
            writer.uint32(18).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseLastPriceInstrument();
        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 !== 18) {
                        break;
                    }
                    message.instrumentId = 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) : "",
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.instrumentId !== "") {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseSubscribeLastPriceResponse() {
    return { trackingId: "", lastPriceSubscriptions: [] };
}
export const SubscribeLastPriceResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.trackingId !== "") {
            writer.uint32(10).string(message.trackingId);
        }
        for (const v of message.lastPriceSubscriptions) {
            LastPriceSubscription.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubscribeLastPriceResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.trackingId = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.lastPriceSubscriptions.push(LastPriceSubscription.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            trackingId: isSet(object.trackingId) ? globalThis.String(object.trackingId) : "",
            lastPriceSubscriptions: globalThis.Array.isArray(object?.lastPriceSubscriptions)
                ? object.lastPriceSubscriptions.map((e) => LastPriceSubscription.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.trackingId !== "") {
            obj.trackingId = message.trackingId;
        }
        if (message.lastPriceSubscriptions?.length) {
            obj.lastPriceSubscriptions = message.lastPriceSubscriptions.map((e) => LastPriceSubscription.toJSON(e));
        }
        return obj;
    },
};
function createBaseLastPriceSubscription() {
    return {
        figi: "",
        subscriptionStatus: 0,
        instrumentUid: "",
        streamId: "",
        subscriptionId: "",
        subscriptionAction: 0,
        ticker: "",
        classCode: "",
    };
}
export const LastPriceSubscription = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.subscriptionStatus !== 0) {
            writer.uint32(16).int32(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(26).string(message.instrumentUid);
        }
        if (message.streamId !== "") {
            writer.uint32(34).string(message.streamId);
        }
        if (message.subscriptionId !== "") {
            writer.uint32(42).string(message.subscriptionId);
        }
        if (message.subscriptionAction !== 0) {
            writer.uint32(48).int32(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            writer.uint32(58).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(66).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseLastPriceSubscription();
        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.subscriptionStatus = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.streamId = reader.string();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.subscriptionId = reader.string();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.subscriptionAction = reader.int32();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.classCode = 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) : "",
            subscriptionStatus: isSet(object.subscriptionStatus) ? subscriptionStatusFromJSON(object.subscriptionStatus) : 0,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            streamId: isSet(object.streamId) ? globalThis.String(object.streamId) : "",
            subscriptionId: isSet(object.subscriptionId) ? globalThis.String(object.subscriptionId) : "",
            subscriptionAction: isSet(object.subscriptionAction) ? subscriptionActionFromJSON(object.subscriptionAction) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.subscriptionStatus !== 0) {
            obj.subscriptionStatus = subscriptionStatusToJSON(message.subscriptionStatus);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.streamId !== "") {
            obj.streamId = message.streamId;
        }
        if (message.subscriptionId !== "") {
            obj.subscriptionId = message.subscriptionId;
        }
        if (message.subscriptionAction !== 0) {
            obj.subscriptionAction = subscriptionActionToJSON(message.subscriptionAction);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseCandle() {
    return {
        figi: "",
        interval: 0,
        open: undefined,
        high: undefined,
        low: undefined,
        close: undefined,
        volume: 0,
        time: undefined,
        lastTradeTs: undefined,
        instrumentUid: "",
        ticker: "",
        classCode: "",
        volumeBuy: 0,
        volumeSell: 0,
        candleSourceType: 0,
    };
}
export const Candle = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.interval !== 0) {
            writer.uint32(16).int32(message.interval);
        }
        if (message.open !== undefined) {
            Quotation.encode(message.open, writer.uint32(26).fork()).ldelim();
        }
        if (message.high !== undefined) {
            Quotation.encode(message.high, writer.uint32(34).fork()).ldelim();
        }
        if (message.low !== undefined) {
            Quotation.encode(message.low, writer.uint32(42).fork()).ldelim();
        }
        if (message.close !== undefined) {
            Quotation.encode(message.close, writer.uint32(50).fork()).ldelim();
        }
        if (message.volume !== 0) {
            writer.uint32(56).int64(message.volume);
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(66).fork()).ldelim();
        }
        if (message.lastTradeTs !== undefined) {
            Timestamp.encode(toTimestamp(message.lastTradeTs), writer.uint32(74).fork()).ldelim();
        }
        if (message.instrumentUid !== "") {
            writer.uint32(82).string(message.instrumentUid);
        }
        if (message.ticker !== "") {
            writer.uint32(90).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(98).string(message.classCode);
        }
        if (message.volumeBuy !== 0) {
            writer.uint32(104).int64(message.volumeBuy);
        }
        if (message.volumeSell !== 0) {
            writer.uint32(112).int64(message.volumeSell);
        }
        if (message.candleSourceType !== 0) {
            writer.uint32(152).int32(message.candleSourceType);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCandle();
        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.interval = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.open = Quotation.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.high = Quotation.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.low = Quotation.decode(reader, reader.uint32());
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.close = Quotation.decode(reader, reader.uint32());
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.volume = longToNumber(reader.int64());
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.lastTradeTs = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 12:
                    if (tag !== 98) {
                        break;
                    }
                    message.classCode = reader.string();
                    continue;
                case 13:
                    if (tag !== 104) {
                        break;
                    }
                    message.volumeBuy = longToNumber(reader.int64());
                    continue;
                case 14:
                    if (tag !== 112) {
                        break;
                    }
                    message.volumeSell = longToNumber(reader.int64());
                    continue;
                case 19:
                    if (tag !== 152) {
                        break;
                    }
                    message.candleSourceType = reader.int32();
                    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) : "",
            interval: isSet(object.interval) ? subscriptionIntervalFromJSON(object.interval) : 0,
            open: isSet(object.open) ? Quotation.fromJSON(object.open) : undefined,
            high: isSet(object.high) ? Quotation.fromJSON(object.high) : undefined,
            low: isSet(object.low) ? Quotation.fromJSON(object.low) : undefined,
            close: isSet(object.close) ? Quotation.fromJSON(object.close) : undefined,
            volume: isSet(object.volume) ? globalThis.Number(object.volume) : 0,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            lastTradeTs: isSet(object.lastTradeTs) ? fromJsonTimestamp(object.lastTradeTs) : undefined,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
            volumeBuy: isSet(object.volumeBuy) ? globalThis.Number(object.volumeBuy) : 0,
            volumeSell: isSet(object.volumeSell) ? globalThis.Number(object.volumeSell) : 0,
            candleSourceType: isSet(object.candleSourceType) ? candleSourceFromJSON(object.candleSourceType) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.interval !== 0) {
            obj.interval = subscriptionIntervalToJSON(message.interval);
        }
        if (message.open !== undefined) {
            obj.open = Quotation.toJSON(message.open);
        }
        if (message.high !== undefined) {
            obj.high = Quotation.toJSON(message.high);
        }
        if (message.low !== undefined) {
            obj.low = Quotation.toJSON(message.low);
        }
        if (message.close !== undefined) {
            obj.close = Quotation.toJSON(message.close);
        }
        if (message.volume !== 0) {
            obj.volume = Math.round(message.volume);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.lastTradeTs !== undefined) {
            obj.lastTradeTs = message.lastTradeTs.toISOString();
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        if (message.volumeBuy !== 0) {
            obj.volumeBuy = Math.round(message.volumeBuy);
        }
        if (message.volumeSell !== 0) {
            obj.volumeSell = Math.round(message.volumeSell);
        }
        if (message.candleSourceType !== 0) {
            obj.candleSourceType = candleSourceToJSON(message.candleSourceType);
        }
        return obj;
    },
};
function createBaseOrderBook() {
    return {
        figi: "",
        depth: 0,
        isConsistent: false,
        bids: [],
        asks: [],
        time: undefined,
        limitUp: undefined,
        limitDown: undefined,
        instrumentUid: "",
        orderBookType: 0,
        ticker: "",
        classCode: "",
    };
}
export const OrderBook = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.depth !== 0) {
            writer.uint32(16).int32(message.depth);
        }
        if (message.isConsistent === true) {
            writer.uint32(24).bool(message.isConsistent);
        }
        for (const v of message.bids) {
            Order.encode(v, writer.uint32(34).fork()).ldelim();
        }
        for (const v of message.asks) {
            Order.encode(v, writer.uint32(42).fork()).ldelim();
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(50).fork()).ldelim();
        }
        if (message.limitUp !== undefined) {
            Quotation.encode(message.limitUp, writer.uint32(58).fork()).ldelim();
        }
        if (message.limitDown !== undefined) {
            Quotation.encode(message.limitDown, writer.uint32(66).fork()).ldelim();
        }
        if (message.instrumentUid !== "") {
            writer.uint32(74).string(message.instrumentUid);
        }
        if (message.orderBookType !== 0) {
            writer.uint32(80).int32(message.orderBookType);
        }
        if (message.ticker !== "") {
            writer.uint32(90).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(98).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseOrderBook();
        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.depth = reader.int32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.isConsistent = reader.bool();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.bids.push(Order.decode(reader, reader.uint32()));
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.asks.push(Order.decode(reader, reader.uint32()));
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.limitUp = Quotation.decode(reader, reader.uint32());
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.limitDown = Quotation.decode(reader, reader.uint32());
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.orderBookType = reader.int32();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 12:
                    if (tag !== 98) {
                        break;
                    }
                    message.classCode = 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) : "",
            depth: isSet(object.depth) ? globalThis.Number(object.depth) : 0,
            isConsistent: isSet(object.isConsistent) ? globalThis.Boolean(object.isConsistent) : false,
            bids: globalThis.Array.isArray(object?.bids) ? object.bids.map((e) => Order.fromJSON(e)) : [],
            asks: globalThis.Array.isArray(object?.asks) ? object.asks.map((e) => Order.fromJSON(e)) : [],
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            limitUp: isSet(object.limitUp) ? Quotation.fromJSON(object.limitUp) : undefined,
            limitDown: isSet(object.limitDown) ? Quotation.fromJSON(object.limitDown) : undefined,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            orderBookType: isSet(object.orderBookType) ? orderBookTypeFromJSON(object.orderBookType) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.depth !== 0) {
            obj.depth = Math.round(message.depth);
        }
        if (message.isConsistent === true) {
            obj.isConsistent = message.isConsistent;
        }
        if (message.bids?.length) {
            obj.bids = message.bids.map((e) => Order.toJSON(e));
        }
        if (message.asks?.length) {
            obj.asks = message.asks.map((e) => Order.toJSON(e));
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.limitUp !== undefined) {
            obj.limitUp = Quotation.toJSON(message.limitUp);
        }
        if (message.limitDown !== undefined) {
            obj.limitDown = Quotation.toJSON(message.limitDown);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.orderBookType !== 0) {
            obj.orderBookType = orderBookTypeToJSON(message.orderBookType);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseOrder() {
    return { price: undefined, quantity: 0 };
}
export const Order = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.price !== undefined) {
            Quotation.encode(message.price, writer.uint32(10).fork()).ldelim();
        }
        if (message.quantity !== 0) {
            writer.uint32(16).int64(message.quantity);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseOrder();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.price = Quotation.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.quantity = longToNumber(reader.int64());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            price: isSet(object.price) ? Quotation.fromJSON(object.price) : undefined,
            quantity: isSet(object.quantity) ? globalThis.Number(object.quantity) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.price !== undefined) {
            obj.price = Quotation.toJSON(message.price);
        }
        if (message.quantity !== 0) {
            obj.quantity = Math.round(message.quantity);
        }
        return obj;
    },
};
function createBaseTrade() {
    return {
        figi: "",
        direction: 0,
        price: undefined,
        quantity: 0,
        time: undefined,
        instrumentUid: "",
        tradeSource: 0,
        ticker: "",
        classCode: "",
    };
}
export const Trade = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.direction !== 0) {
            writer.uint32(16).int32(message.direction);
        }
        if (message.price !== undefined) {
            Quotation.encode(message.price, writer.uint32(26).fork()).ldelim();
        }
        if (message.quantity !== 0) {
            writer.uint32(32).int64(message.quantity);
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(42).fork()).ldelim();
        }
        if (message.instrumentUid !== "") {
            writer.uint32(50).string(message.instrumentUid);
        }
        if (message.tradeSource !== 0) {
            writer.uint32(56).int32(message.tradeSource);
        }
        if (message.ticker !== "") {
            writer.uint32(66).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(74).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTrade();
        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.direction = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.price = Quotation.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.quantity = longToNumber(reader.int64());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.tradeSource = reader.int32();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.classCode = 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) : "",
            direction: isSet(object.direction) ? tradeDirectionFromJSON(object.direction) : 0,
            price: isSet(object.price) ? Quotation.fromJSON(object.price) : undefined,
            quantity: isSet(object.quantity) ? globalThis.Number(object.quantity) : 0,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            tradeSource: isSet(object.tradeSource) ? tradeSourceTypeFromJSON(object.tradeSource) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.direction !== 0) {
            obj.direction = tradeDirectionToJSON(message.direction);
        }
        if (message.price !== undefined) {
            obj.price = Quotation.toJSON(message.price);
        }
        if (message.quantity !== 0) {
            obj.quantity = Math.round(message.quantity);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.tradeSource !== 0) {
            obj.tradeSource = tradeSourceTypeToJSON(message.tradeSource);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseTradingStatus() {
    return {
        figi: "",
        tradingStatus: 0,
        time: undefined,
        limitOrderAvailableFlag: false,
        marketOrderAvailableFlag: false,
        instrumentUid: "",
        ticker: "",
        classCode: "",
    };
}
export const TradingStatus = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.tradingStatus !== 0) {
            writer.uint32(16).int32(message.tradingStatus);
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(26).fork()).ldelim();
        }
        if (message.limitOrderAvailableFlag === true) {
            writer.uint32(32).bool(message.limitOrderAvailableFlag);
        }
        if (message.marketOrderAvailableFlag === true) {
            writer.uint32(40).bool(message.marketOrderAvailableFlag);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(50).string(message.instrumentUid);
        }
        if (message.ticker !== "") {
            writer.uint32(58).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(66).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTradingStatus();
        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.tradingStatus = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.limitOrderAvailableFlag = reader.bool();
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.marketOrderAvailableFlag = reader.bool();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.classCode = 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) : "",
            tradingStatus: isSet(object.tradingStatus) ? securityTradingStatusFromJSON(object.tradingStatus) : 0,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            limitOrderAvailableFlag: isSet(object.limitOrderAvailableFlag)
                ? globalThis.Boolean(object.limitOrderAvailableFlag)
                : false,
            marketOrderAvailableFlag: isSet(object.marketOrderAvailableFlag)
                ? globalThis.Boolean(object.marketOrderAvailableFlag)
                : false,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.tradingStatus !== 0) {
            obj.tradingStatus = securityTradingStatusToJSON(message.tradingStatus);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.limitOrderAvailableFlag === true) {
            obj.limitOrderAvailableFlag = message.limitOrderAvailableFlag;
        }
        if (message.marketOrderAvailableFlag === true) {
            obj.marketOrderAvailableFlag = message.marketOrderAvailableFlag;
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseGetCandlesRequest() {
    return {
        figi: undefined,
        from: undefined,
        to: undefined,
        interval: 0,
        instrumentId: undefined,
        candleSourceType: undefined,
        limit: undefined,
    };
}
export const GetCandlesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== undefined) {
            writer.uint32(10).string(message.figi);
        }
        if (message.from !== undefined) {
            Timestamp.encode(toTimestamp(message.from), writer.uint32(18).fork()).ldelim();
        }
        if (message.to !== undefined) {
            Timestamp.encode(toTimestamp(message.to), writer.uint32(26).fork()).ldelim();
        }
        if (message.interval !== 0) {
            writer.uint32(32).int32(message.interval);
        }
        if (message.instrumentId !== undefined) {
            writer.uint32(42).string(message.instrumentId);
        }
        if (message.candleSourceType !== undefined) {
            writer.uint32(56).int32(message.candleSourceType);
        }
        if (message.limit !== undefined) {
            writer.uint32(80).int32(message.limit);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetCandlesRequest();
        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 !== 18) {
                        break;
                    }
                    message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.to = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.interval = reader.int32();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.instrumentId = reader.string();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.candleSourceType = reader.int32();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.limit = reader.int32();
                    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,
            from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined,
            to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined,
            interval: isSet(object.interval) ? candleIntervalFromJSON(object.interval) : 0,
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : undefined,
            candleSourceType: isSet(object.candleSourceType)
                ? getCandlesRequest_CandleSourceFromJSON(object.candleSourceType)
                : undefined,
            limit: isSet(object.limit) ? globalThis.Number(object.limit) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== undefined) {
            obj.figi = message.figi;
        }
        if (message.from !== undefined) {
            obj.from = message.from.toISOString();
        }
        if (message.to !== undefined) {
            obj.to = message.to.toISOString();
        }
        if (message.interval !== 0) {
            obj.interval = candleIntervalToJSON(message.interval);
        }
        if (message.instrumentId !== undefined) {
            obj.instrumentId = message.instrumentId;
        }
        if (message.candleSourceType !== undefined) {
            obj.candleSourceType = getCandlesRequest_CandleSourceToJSON(message.candleSourceType);
        }
        if (message.limit !== undefined) {
            obj.limit = Math.round(message.limit);
        }
        return obj;
    },
};
function createBaseGetCandlesResponse() {
    return { candles: [] };
}
export const GetCandlesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.candles) {
            HistoricCandle.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetCandlesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.candles.push(HistoricCandle.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            candles: globalThis.Array.isArray(object?.candles)
                ? object.candles.map((e) => HistoricCandle.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.candles?.length) {
            obj.candles = message.candles.map((e) => HistoricCandle.toJSON(e));
        }
        return obj;
    },
};
function createBaseHistoricCandle() {
    return {
        open: undefined,
        high: undefined,
        low: undefined,
        close: undefined,
        volume: 0,
        time: undefined,
        isComplete: false,
        candleSource: 0,
        volumeBuy: 0,
        volumeSell: 0,
    };
}
export const HistoricCandle = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.open !== undefined) {
            Quotation.encode(message.open, writer.uint32(10).fork()).ldelim();
        }
        if (message.high !== undefined) {
            Quotation.encode(message.high, writer.uint32(18).fork()).ldelim();
        }
        if (message.low !== undefined) {
            Quotation.encode(message.low, writer.uint32(26).fork()).ldelim();
        }
        if (message.close !== undefined) {
            Quotation.encode(message.close, writer.uint32(34).fork()).ldelim();
        }
        if (message.volume !== 0) {
            writer.uint32(40).int64(message.volume);
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(50).fork()).ldelim();
        }
        if (message.isComplete === true) {
            writer.uint32(56).bool(message.isComplete);
        }
        if (message.candleSource !== 0) {
            writer.uint32(72).int32(message.candleSource);
        }
        if (message.volumeBuy !== 0) {
            writer.uint32(80).int64(message.volumeBuy);
        }
        if (message.volumeSell !== 0) {
            writer.uint32(88).int64(message.volumeSell);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHistoricCandle();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.open = Quotation.decode(reader, reader.uint32());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.high = Quotation.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.low = Quotation.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.close = Quotation.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.volume = longToNumber(reader.int64());
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.isComplete = reader.bool();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.candleSource = reader.int32();
                    continue;
                case 10:
                    if (tag !== 80) {
                        break;
                    }
                    message.volumeBuy = longToNumber(reader.int64());
                    continue;
                case 11:
                    if (tag !== 88) {
                        break;
                    }
                    message.volumeSell = longToNumber(reader.int64());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            open: isSet(object.open) ? Quotation.fromJSON(object.open) : undefined,
            high: isSet(object.high) ? Quotation.fromJSON(object.high) : undefined,
            low: isSet(object.low) ? Quotation.fromJSON(object.low) : undefined,
            close: isSet(object.close) ? Quotation.fromJSON(object.close) : undefined,
            volume: isSet(object.volume) ? globalThis.Number(object.volume) : 0,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            isComplete: isSet(object.isComplete) ? globalThis.Boolean(object.isComplete) : false,
            candleSource: isSet(object.candleSource) ? candleSourceFromJSON(object.candleSource) : 0,
            volumeBuy: isSet(object.volumeBuy) ? globalThis.Number(object.volumeBuy) : 0,
            volumeSell: isSet(object.volumeSell) ? globalThis.Number(object.volumeSell) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.open !== undefined) {
            obj.open = Quotation.toJSON(message.open);
        }
        if (message.high !== undefined) {
            obj.high = Quotation.toJSON(message.high);
        }
        if (message.low !== undefined) {
            obj.low = Quotation.toJSON(message.low);
        }
        if (message.close !== undefined) {
            obj.close = Quotation.toJSON(message.close);
        }
        if (message.volume !== 0) {
            obj.volume = Math.round(message.volume);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.isComplete === true) {
            obj.isComplete = message.isComplete;
        }
        if (message.candleSource !== 0) {
            obj.candleSource = candleSourceToJSON(message.candleSource);
        }
        if (message.volumeBuy !== 0) {
            obj.volumeBuy = Math.round(message.volumeBuy);
        }
        if (message.volumeSell !== 0) {
            obj.volumeSell = Math.round(message.volumeSell);
        }
        return obj;
    },
};
function createBaseGetLastPricesRequest() {
    return { figi: [], instrumentId: [], lastPriceType: 0, instrumentStatus: undefined };
}
export const GetLastPricesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.figi) {
            writer.uint32(10).string(v);
        }
        for (const v of message.instrumentId) {
            writer.uint32(18).string(v);
        }
        if (message.lastPriceType !== 0) {
            writer.uint32(24).int32(message.lastPriceType);
        }
        if (message.instrumentStatus !== undefined) {
            writer.uint32(72).int32(message.instrumentStatus);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetLastPricesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.figi.push(reader.string());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instrumentId.push(reader.string());
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.lastPriceType = reader.int32();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.instrumentStatus = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            figi: globalThis.Array.isArray(object?.figi) ? object.figi.map((e) => globalThis.String(e)) : [],
            instrumentId: globalThis.Array.isArray(object?.instrumentId)
                ? object.instrumentId.map((e) => globalThis.String(e))
                : [],
            lastPriceType: isSet(object.lastPriceType) ? lastPriceTypeFromJSON(object.lastPriceType) : 0,
            instrumentStatus: isSet(object.instrumentStatus) ? instrumentStatusFromJSON(object.instrumentStatus) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi?.length) {
            obj.figi = message.figi;
        }
        if (message.instrumentId?.length) {
            obj.instrumentId = message.instrumentId;
        }
        if (message.lastPriceType !== 0) {
            obj.lastPriceType = lastPriceTypeToJSON(message.lastPriceType);
        }
        if (message.instrumentStatus !== undefined) {
            obj.instrumentStatus = instrumentStatusToJSON(message.instrumentStatus);
        }
        return obj;
    },
};
function createBaseGetLastPricesResponse() {
    return { lastPrices: [] };
}
export const GetLastPricesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.lastPrices) {
            LastPrice.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetLastPricesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.lastPrices.push(LastPrice.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            lastPrices: globalThis.Array.isArray(object?.lastPrices)
                ? object.lastPrices.map((e) => LastPrice.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.lastPrices?.length) {
            obj.lastPrices = message.lastPrices.map((e) => LastPrice.toJSON(e));
        }
        return obj;
    },
};
function createBaseLastPrice() {
    return {
        figi: "",
        price: undefined,
        time: undefined,
        ticker: "",
        classCode: "",
        instrumentUid: "",
        lastPriceType: 0,
    };
}
export const LastPrice = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.price !== undefined) {
            Quotation.encode(message.price, writer.uint32(18).fork()).ldelim();
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(26).fork()).ldelim();
        }
        if (message.ticker !== "") {
            writer.uint32(74).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(82).string(message.classCode);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(90).string(message.instrumentUid);
        }
        if (message.lastPriceType !== 0) {
            writer.uint32(96).int32(message.lastPriceType);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseLastPrice();
        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 !== 18) {
                        break;
                    }
                    message.price = Quotation.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.classCode = reader.string();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 12:
                    if (tag !== 96) {
                        break;
                    }
                    message.lastPriceType = reader.int32();
                    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) : "",
            price: isSet(object.price) ? Quotation.fromJSON(object.price) : undefined,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            lastPriceType: isSet(object.lastPriceType) ? lastPriceTypeFromJSON(object.lastPriceType) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.price !== undefined) {
            obj.price = Quotation.toJSON(message.price);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.lastPriceType !== 0) {
            obj.lastPriceType = lastPriceTypeToJSON(message.lastPriceType);
        }
        return obj;
    },
};
function createBaseOpenInterest() {
    return { instrumentUid: "", time: undefined, openInterest: 0, ticker: "", classCode: "" };
}
export const OpenInterest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.instrumentUid !== "") {
            writer.uint32(10).string(message.instrumentUid);
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(18).fork()).ldelim();
        }
        if (message.openInterest !== 0) {
            writer.uint32(24).int64(message.openInterest);
        }
        if (message.ticker !== "") {
            writer.uint32(34).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(42).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseOpenInterest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.openInterest = longToNumber(reader.int64());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.classCode = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            openInterest: isSet(object.openInterest) ? globalThis.Number(object.openInterest) : 0,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.openInterest !== 0) {
            obj.openInterest = Math.round(message.openInterest);
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseGetOrderBookRequest() {
    return { figi: undefined, depth: 0, instrumentId: undefined };
}
export const GetOrderBookRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== undefined) {
            writer.uint32(10).string(message.figi);
        }
        if (message.depth !== 0) {
            writer.uint32(16).int32(message.depth);
        }
        if (message.instrumentId !== undefined) {
            writer.uint32(26).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetOrderBookRequest();
        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.depth = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.instrumentId = 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,
            depth: isSet(object.depth) ? globalThis.Number(object.depth) : 0,
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== undefined) {
            obj.figi = message.figi;
        }
        if (message.depth !== 0) {
            obj.depth = Math.round(message.depth);
        }
        if (message.instrumentId !== undefined) {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseGetOrderBookResponse() {
    return {
        figi: "",
        depth: 0,
        bids: [],
        asks: [],
        lastPrice: undefined,
        closePrice: undefined,
        limitUp: undefined,
        limitDown: undefined,
        instrumentUid: "",
        ticker: "",
        classCode: "",
        lastPriceTs: undefined,
        closePriceTs: undefined,
        orderbookTs: undefined,
    };
}
export const GetOrderBookResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.depth !== 0) {
            writer.uint32(16).int32(message.depth);
        }
        for (const v of message.bids) {
            Order.encode(v, writer.uint32(26).fork()).ldelim();
        }
        for (const v of message.asks) {
            Order.encode(v, writer.uint32(34).fork()).ldelim();
        }
        if (message.lastPrice !== undefined) {
            Quotation.encode(message.lastPrice, writer.uint32(42).fork()).ldelim();
        }
        if (message.closePrice !== undefined) {
            Quotation.encode(message.closePrice, writer.uint32(50).fork()).ldelim();
        }
        if (message.limitUp !== undefined) {
            Quotation.encode(message.limitUp, writer.uint32(58).fork()).ldelim();
        }
        if (message.limitDown !== undefined) {
            Quotation.encode(message.limitDown, writer.uint32(66).fork()).ldelim();
        }
        if (message.instrumentUid !== "") {
            writer.uint32(74).string(message.instrumentUid);
        }
        if (message.ticker !== "") {
            writer.uint32(82).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(90).string(message.classCode);
        }
        if (message.lastPriceTs !== undefined) {
            Timestamp.encode(toTimestamp(message.lastPriceTs), writer.uint32(170).fork()).ldelim();
        }
        if (message.closePriceTs !== undefined) {
            Timestamp.encode(toTimestamp(message.closePriceTs), writer.uint32(178).fork()).ldelim();
        }
        if (message.orderbookTs !== undefined) {
            Timestamp.encode(toTimestamp(message.orderbookTs), writer.uint32(186).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetOrderBookResponse();
        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.depth = reader.int32();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.bids.push(Order.decode(reader, reader.uint32()));
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.asks.push(Order.decode(reader, reader.uint32()));
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.lastPrice = Quotation.decode(reader, reader.uint32());
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.closePrice = Quotation.decode(reader, reader.uint32());
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.limitUp = Quotation.decode(reader, reader.uint32());
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.limitDown = Quotation.decode(reader, reader.uint32());
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.classCode = reader.string();
                    continue;
                case 21:
                    if (tag !== 170) {
                        break;
                    }
                    message.lastPriceTs = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 22:
                    if (tag !== 178) {
                        break;
                    }
                    message.closePriceTs = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 23:
                    if (tag !== 186) {
                        break;
                    }
                    message.orderbookTs = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    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) : "",
            depth: isSet(object.depth) ? globalThis.Number(object.depth) : 0,
            bids: globalThis.Array.isArray(object?.bids) ? object.bids.map((e) => Order.fromJSON(e)) : [],
            asks: globalThis.Array.isArray(object?.asks) ? object.asks.map((e) => Order.fromJSON(e)) : [],
            lastPrice: isSet(object.lastPrice) ? Quotation.fromJSON(object.lastPrice) : undefined,
            closePrice: isSet(object.closePrice) ? Quotation.fromJSON(object.closePrice) : undefined,
            limitUp: isSet(object.limitUp) ? Quotation.fromJSON(object.limitUp) : undefined,
            limitDown: isSet(object.limitDown) ? Quotation.fromJSON(object.limitDown) : undefined,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
            lastPriceTs: isSet(object.lastPriceTs) ? fromJsonTimestamp(object.lastPriceTs) : undefined,
            closePriceTs: isSet(object.closePriceTs) ? fromJsonTimestamp(object.closePriceTs) : undefined,
            orderbookTs: isSet(object.orderbookTs) ? fromJsonTimestamp(object.orderbookTs) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.depth !== 0) {
            obj.depth = Math.round(message.depth);
        }
        if (message.bids?.length) {
            obj.bids = message.bids.map((e) => Order.toJSON(e));
        }
        if (message.asks?.length) {
            obj.asks = message.asks.map((e) => Order.toJSON(e));
        }
        if (message.lastPrice !== undefined) {
            obj.lastPrice = Quotation.toJSON(message.lastPrice);
        }
        if (message.closePrice !== undefined) {
            obj.closePrice = Quotation.toJSON(message.closePrice);
        }
        if (message.limitUp !== undefined) {
            obj.limitUp = Quotation.toJSON(message.limitUp);
        }
        if (message.limitDown !== undefined) {
            obj.limitDown = Quotation.toJSON(message.limitDown);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        if (message.lastPriceTs !== undefined) {
            obj.lastPriceTs = message.lastPriceTs.toISOString();
        }
        if (message.closePriceTs !== undefined) {
            obj.closePriceTs = message.closePriceTs.toISOString();
        }
        if (message.orderbookTs !== undefined) {
            obj.orderbookTs = message.orderbookTs.toISOString();
        }
        return obj;
    },
};
function createBaseGetTradingStatusRequest() {
    return { figi: undefined, instrumentId: undefined };
}
export const GetTradingStatusRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== undefined) {
            writer.uint32(10).string(message.figi);
        }
        if (message.instrumentId !== undefined) {
            writer.uint32(18).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTradingStatusRequest();
        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 !== 18) {
                        break;
                    }
                    message.instrumentId = 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,
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== undefined) {
            obj.figi = message.figi;
        }
        if (message.instrumentId !== undefined) {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseGetTradingStatusesRequest() {
    return { instrumentId: [] };
}
export const GetTradingStatusesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.instrumentId) {
            writer.uint32(10).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTradingStatusesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instrumentId.push(reader.string());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            instrumentId: globalThis.Array.isArray(object?.instrumentId)
                ? object.instrumentId.map((e) => globalThis.String(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.instrumentId?.length) {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseGetTradingStatusesResponse() {
    return { tradingStatuses: [] };
}
export const GetTradingStatusesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.tradingStatuses) {
            GetTradingStatusResponse.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTradingStatusesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.tradingStatuses.push(GetTradingStatusResponse.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            tradingStatuses: globalThis.Array.isArray(object?.tradingStatuses)
                ? object.tradingStatuses.map((e) => GetTradingStatusResponse.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.tradingStatuses?.length) {
            obj.tradingStatuses = message.tradingStatuses.map((e) => GetTradingStatusResponse.toJSON(e));
        }
        return obj;
    },
};
function createBaseGetTradingStatusResponse() {
    return {
        figi: "",
        tradingStatus: 0,
        limitOrderAvailableFlag: false,
        marketOrderAvailableFlag: false,
        apiTradeAvailableFlag: false,
        instrumentUid: "",
        bestpriceOrderAvailableFlag: false,
        onlyBestPrice: false,
        ticker: "",
        classCode: "",
    };
}
export const GetTradingStatusResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.tradingStatus !== 0) {
            writer.uint32(16).int32(message.tradingStatus);
        }
        if (message.limitOrderAvailableFlag === true) {
            writer.uint32(24).bool(message.limitOrderAvailableFlag);
        }
        if (message.marketOrderAvailableFlag === true) {
            writer.uint32(32).bool(message.marketOrderAvailableFlag);
        }
        if (message.apiTradeAvailableFlag === true) {
            writer.uint32(40).bool(message.apiTradeAvailableFlag);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(50).string(message.instrumentUid);
        }
        if (message.bestpriceOrderAvailableFlag === true) {
            writer.uint32(64).bool(message.bestpriceOrderAvailableFlag);
        }
        if (message.onlyBestPrice === true) {
            writer.uint32(72).bool(message.onlyBestPrice);
        }
        if (message.ticker !== "") {
            writer.uint32(82).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(90).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTradingStatusResponse();
        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.tradingStatus = reader.int32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.limitOrderAvailableFlag = reader.bool();
                    continue;
                case 4:
                    if (tag !== 32) {
                        break;
                    }
                    message.marketOrderAvailableFlag = reader.bool();
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.apiTradeAvailableFlag = reader.bool();
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 8:
                    if (tag !== 64) {
                        break;
                    }
                    message.bestpriceOrderAvailableFlag = reader.bool();
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.onlyBestPrice = reader.bool();
                    continue;
                case 10:
                    if (tag !== 82) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.classCode = 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) : "",
            tradingStatus: isSet(object.tradingStatus) ? securityTradingStatusFromJSON(object.tradingStatus) : 0,
            limitOrderAvailableFlag: isSet(object.limitOrderAvailableFlag)
                ? globalThis.Boolean(object.limitOrderAvailableFlag)
                : false,
            marketOrderAvailableFlag: isSet(object.marketOrderAvailableFlag)
                ? globalThis.Boolean(object.marketOrderAvailableFlag)
                : false,
            apiTradeAvailableFlag: isSet(object.apiTradeAvailableFlag)
                ? globalThis.Boolean(object.apiTradeAvailableFlag)
                : false,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            bestpriceOrderAvailableFlag: isSet(object.bestpriceOrderAvailableFlag)
                ? globalThis.Boolean(object.bestpriceOrderAvailableFlag)
                : false,
            onlyBestPrice: isSet(object.onlyBestPrice) ? globalThis.Boolean(object.onlyBestPrice) : false,
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.tradingStatus !== 0) {
            obj.tradingStatus = securityTradingStatusToJSON(message.tradingStatus);
        }
        if (message.limitOrderAvailableFlag === true) {
            obj.limitOrderAvailableFlag = message.limitOrderAvailableFlag;
        }
        if (message.marketOrderAvailableFlag === true) {
            obj.marketOrderAvailableFlag = message.marketOrderAvailableFlag;
        }
        if (message.apiTradeAvailableFlag === true) {
            obj.apiTradeAvailableFlag = message.apiTradeAvailableFlag;
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.bestpriceOrderAvailableFlag === true) {
            obj.bestpriceOrderAvailableFlag = message.bestpriceOrderAvailableFlag;
        }
        if (message.onlyBestPrice === true) {
            obj.onlyBestPrice = message.onlyBestPrice;
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseGetLastTradesRequest() {
    return { figi: undefined, from: undefined, to: undefined, instrumentId: undefined, tradeSource: 0 };
}
export const GetLastTradesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== undefined) {
            writer.uint32(10).string(message.figi);
        }
        if (message.from !== undefined) {
            Timestamp.encode(toTimestamp(message.from), writer.uint32(18).fork()).ldelim();
        }
        if (message.to !== undefined) {
            Timestamp.encode(toTimestamp(message.to), writer.uint32(26).fork()).ldelim();
        }
        if (message.instrumentId !== undefined) {
            writer.uint32(34).string(message.instrumentId);
        }
        if (message.tradeSource !== 0) {
            writer.uint32(40).int32(message.tradeSource);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetLastTradesRequest();
        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 !== 18) {
                        break;
                    }
                    message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.to = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.instrumentId = reader.string();
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.tradeSource = reader.int32();
                    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,
            from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined,
            to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined,
            instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : undefined,
            tradeSource: isSet(object.tradeSource) ? tradeSourceTypeFromJSON(object.tradeSource) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== undefined) {
            obj.figi = message.figi;
        }
        if (message.from !== undefined) {
            obj.from = message.from.toISOString();
        }
        if (message.to !== undefined) {
            obj.to = message.to.toISOString();
        }
        if (message.instrumentId !== undefined) {
            obj.instrumentId = message.instrumentId;
        }
        if (message.tradeSource !== 0) {
            obj.tradeSource = tradeSourceTypeToJSON(message.tradeSource);
        }
        return obj;
    },
};
function createBaseGetLastTradesResponse() {
    return { trades: [] };
}
export const GetLastTradesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.trades) {
            Trade.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetLastTradesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.trades.push(Trade.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { trades: globalThis.Array.isArray(object?.trades) ? object.trades.map((e) => Trade.fromJSON(e)) : [] };
    },
    toJSON(message) {
        const obj = {};
        if (message.trades?.length) {
            obj.trades = message.trades.map((e) => Trade.toJSON(e));
        }
        return obj;
    },
};
function createBaseGetMySubscriptions() {
    return {};
}
export const GetMySubscriptions = {
    encode(_, writer = _m0.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetMySubscriptions();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(_) {
        return {};
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
};
function createBaseGetClosePricesRequest() {
    return { instruments: [], instrumentStatus: undefined };
}
export const GetClosePricesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.instruments) {
            InstrumentClosePriceRequest.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.instrumentStatus !== undefined) {
            writer.uint32(72).int32(message.instrumentStatus);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetClosePricesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instruments.push(InstrumentClosePriceRequest.decode(reader, reader.uint32()));
                    continue;
                case 9:
                    if (tag !== 72) {
                        break;
                    }
                    message.instrumentStatus = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => InstrumentClosePriceRequest.fromJSON(e))
                : [],
            instrumentStatus: isSet(object.instrumentStatus) ? instrumentStatusFromJSON(object.instrumentStatus) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => InstrumentClosePriceRequest.toJSON(e));
        }
        if (message.instrumentStatus !== undefined) {
            obj.instrumentStatus = instrumentStatusToJSON(message.instrumentStatus);
        }
        return obj;
    },
};
function createBaseInstrumentClosePriceRequest() {
    return { instrumentId: "" };
}
export const InstrumentClosePriceRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.instrumentId !== "") {
            writer.uint32(10).string(message.instrumentId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseInstrumentClosePriceRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instrumentId = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { instrumentId: isSet(object.instrumentId) ? globalThis.String(object.instrumentId) : "" };
    },
    toJSON(message) {
        const obj = {};
        if (message.instrumentId !== "") {
            obj.instrumentId = message.instrumentId;
        }
        return obj;
    },
};
function createBaseGetClosePricesResponse() {
    return { closePrices: [] };
}
export const GetClosePricesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.closePrices) {
            InstrumentClosePriceResponse.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetClosePricesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.closePrices.push(InstrumentClosePriceResponse.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            closePrices: globalThis.Array.isArray(object?.closePrices)
                ? object.closePrices.map((e) => InstrumentClosePriceResponse.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.closePrices?.length) {
            obj.closePrices = message.closePrices.map((e) => InstrumentClosePriceResponse.toJSON(e));
        }
        return obj;
    },
};
function createBaseInstrumentClosePriceResponse() {
    return {
        figi: "",
        instrumentUid: "",
        ticker: "",
        classCode: "",
        price: undefined,
        eveningSessionPrice: undefined,
        time: undefined,
        eveningSessionPriceTime: undefined,
    };
}
export const InstrumentClosePriceResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.figi !== "") {
            writer.uint32(10).string(message.figi);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(18).string(message.instrumentUid);
        }
        if (message.ticker !== "") {
            writer.uint32(26).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(34).string(message.classCode);
        }
        if (message.price !== undefined) {
            Quotation.encode(message.price, writer.uint32(90).fork()).ldelim();
        }
        if (message.eveningSessionPrice !== undefined) {
            Quotation.encode(message.eveningSessionPrice, writer.uint32(98).fork()).ldelim();
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(170).fork()).ldelim();
        }
        if (message.eveningSessionPriceTime !== undefined) {
            Timestamp.encode(toTimestamp(message.eveningSessionPriceTime), writer.uint32(186).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseInstrumentClosePriceResponse();
        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 !== 18) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.classCode = reader.string();
                    continue;
                case 11:
                    if (tag !== 90) {
                        break;
                    }
                    message.price = Quotation.decode(reader, reader.uint32());
                    continue;
                case 12:
                    if (tag !== 98) {
                        break;
                    }
                    message.eveningSessionPrice = Quotation.decode(reader, reader.uint32());
                    continue;
                case 21:
                    if (tag !== 170) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 23:
                    if (tag !== 186) {
                        break;
                    }
                    message.eveningSessionPriceTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    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) : "",
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
            price: isSet(object.price) ? Quotation.fromJSON(object.price) : undefined,
            eveningSessionPrice: isSet(object.eveningSessionPrice)
                ? Quotation.fromJSON(object.eveningSessionPrice)
                : undefined,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
            eveningSessionPriceTime: isSet(object.eveningSessionPriceTime)
                ? fromJsonTimestamp(object.eveningSessionPriceTime)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.figi !== "") {
            obj.figi = message.figi;
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        if (message.price !== undefined) {
            obj.price = Quotation.toJSON(message.price);
        }
        if (message.eveningSessionPrice !== undefined) {
            obj.eveningSessionPrice = Quotation.toJSON(message.eveningSessionPrice);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        if (message.eveningSessionPriceTime !== undefined) {
            obj.eveningSessionPriceTime = message.eveningSessionPriceTime.toISOString();
        }
        return obj;
    },
};
function createBaseGetTechAnalysisRequest() {
    return {
        indicatorType: 0,
        instrumentUid: "",
        from: undefined,
        to: undefined,
        interval: 0,
        typeOfPrice: 0,
        length: 0,
        deviation: undefined,
        smoothing: undefined,
    };
}
export const GetTechAnalysisRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.indicatorType !== 0) {
            writer.uint32(8).int32(message.indicatorType);
        }
        if (message.instrumentUid !== "") {
            writer.uint32(18).string(message.instrumentUid);
        }
        if (message.from !== undefined) {
            Timestamp.encode(toTimestamp(message.from), writer.uint32(26).fork()).ldelim();
        }
        if (message.to !== undefined) {
            Timestamp.encode(toTimestamp(message.to), writer.uint32(34).fork()).ldelim();
        }
        if (message.interval !== 0) {
            writer.uint32(40).int32(message.interval);
        }
        if (message.typeOfPrice !== 0) {
            writer.uint32(48).int32(message.typeOfPrice);
        }
        if (message.length !== 0) {
            writer.uint32(56).int32(message.length);
        }
        if (message.deviation !== undefined) {
            GetTechAnalysisRequest_Deviation.encode(message.deviation, writer.uint32(66).fork()).ldelim();
        }
        if (message.smoothing !== undefined) {
            GetTechAnalysisRequest_Smoothing.encode(message.smoothing, writer.uint32(74).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTechAnalysisRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.indicatorType = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.to = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 5:
                    if (tag !== 40) {
                        break;
                    }
                    message.interval = reader.int32();
                    continue;
                case 6:
                    if (tag !== 48) {
                        break;
                    }
                    message.typeOfPrice = reader.int32();
                    continue;
                case 7:
                    if (tag !== 56) {
                        break;
                    }
                    message.length = reader.int32();
                    continue;
                case 8:
                    if (tag !== 66) {
                        break;
                    }
                    message.deviation = GetTechAnalysisRequest_Deviation.decode(reader, reader.uint32());
                    continue;
                case 9:
                    if (tag !== 74) {
                        break;
                    }
                    message.smoothing = GetTechAnalysisRequest_Smoothing.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            indicatorType: isSet(object.indicatorType)
                ? getTechAnalysisRequest_IndicatorTypeFromJSON(object.indicatorType)
                : 0,
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined,
            to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined,
            interval: isSet(object.interval) ? getTechAnalysisRequest_IndicatorIntervalFromJSON(object.interval) : 0,
            typeOfPrice: isSet(object.typeOfPrice) ? getTechAnalysisRequest_TypeOfPriceFromJSON(object.typeOfPrice) : 0,
            length: isSet(object.length) ? globalThis.Number(object.length) : 0,
            deviation: isSet(object.deviation) ? GetTechAnalysisRequest_Deviation.fromJSON(object.deviation) : undefined,
            smoothing: isSet(object.smoothing) ? GetTechAnalysisRequest_Smoothing.fromJSON(object.smoothing) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.indicatorType !== 0) {
            obj.indicatorType = getTechAnalysisRequest_IndicatorTypeToJSON(message.indicatorType);
        }
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.from !== undefined) {
            obj.from = message.from.toISOString();
        }
        if (message.to !== undefined) {
            obj.to = message.to.toISOString();
        }
        if (message.interval !== 0) {
            obj.interval = getTechAnalysisRequest_IndicatorIntervalToJSON(message.interval);
        }
        if (message.typeOfPrice !== 0) {
            obj.typeOfPrice = getTechAnalysisRequest_TypeOfPriceToJSON(message.typeOfPrice);
        }
        if (message.length !== 0) {
            obj.length = Math.round(message.length);
        }
        if (message.deviation !== undefined) {
            obj.deviation = GetTechAnalysisRequest_Deviation.toJSON(message.deviation);
        }
        if (message.smoothing !== undefined) {
            obj.smoothing = GetTechAnalysisRequest_Smoothing.toJSON(message.smoothing);
        }
        return obj;
    },
};
function createBaseGetTechAnalysisRequest_Smoothing() {
    return { fastLength: 0, slowLength: 0, signalSmoothing: 0 };
}
export const GetTechAnalysisRequest_Smoothing = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.fastLength !== 0) {
            writer.uint32(8).int32(message.fastLength);
        }
        if (message.slowLength !== 0) {
            writer.uint32(16).int32(message.slowLength);
        }
        if (message.signalSmoothing !== 0) {
            writer.uint32(24).int32(message.signalSmoothing);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTechAnalysisRequest_Smoothing();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.fastLength = reader.int32();
                    continue;
                case 2:
                    if (tag !== 16) {
                        break;
                    }
                    message.slowLength = reader.int32();
                    continue;
                case 3:
                    if (tag !== 24) {
                        break;
                    }
                    message.signalSmoothing = reader.int32();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            fastLength: isSet(object.fastLength) ? globalThis.Number(object.fastLength) : 0,
            slowLength: isSet(object.slowLength) ? globalThis.Number(object.slowLength) : 0,
            signalSmoothing: isSet(object.signalSmoothing) ? globalThis.Number(object.signalSmoothing) : 0,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.fastLength !== 0) {
            obj.fastLength = Math.round(message.fastLength);
        }
        if (message.slowLength !== 0) {
            obj.slowLength = Math.round(message.slowLength);
        }
        if (message.signalSmoothing !== 0) {
            obj.signalSmoothing = Math.round(message.signalSmoothing);
        }
        return obj;
    },
};
function createBaseGetTechAnalysisRequest_Deviation() {
    return { deviationMultiplier: undefined };
}
export const GetTechAnalysisRequest_Deviation = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.deviationMultiplier !== undefined) {
            Quotation.encode(message.deviationMultiplier, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTechAnalysisRequest_Deviation();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.deviationMultiplier = Quotation.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            deviationMultiplier: isSet(object.deviationMultiplier)
                ? Quotation.fromJSON(object.deviationMultiplier)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.deviationMultiplier !== undefined) {
            obj.deviationMultiplier = Quotation.toJSON(message.deviationMultiplier);
        }
        return obj;
    },
};
function createBaseGetTechAnalysisResponse() {
    return { technicalIndicators: [] };
}
export const GetTechAnalysisResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.technicalIndicators) {
            GetTechAnalysisResponse_TechAnalysisItem.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTechAnalysisResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.technicalIndicators.push(GetTechAnalysisResponse_TechAnalysisItem.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            technicalIndicators: globalThis.Array.isArray(object?.technicalIndicators)
                ? object.technicalIndicators.map((e) => GetTechAnalysisResponse_TechAnalysisItem.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.technicalIndicators?.length) {
            obj.technicalIndicators = message.technicalIndicators.map((e) => GetTechAnalysisResponse_TechAnalysisItem.toJSON(e));
        }
        return obj;
    },
};
function createBaseGetTechAnalysisResponse_TechAnalysisItem() {
    return {
        timestamp: undefined,
        middleBand: undefined,
        upperBand: undefined,
        lowerBand: undefined,
        signal: undefined,
        macd: undefined,
    };
}
export const GetTechAnalysisResponse_TechAnalysisItem = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.timestamp !== undefined) {
            Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim();
        }
        if (message.middleBand !== undefined) {
            Quotation.encode(message.middleBand, writer.uint32(18).fork()).ldelim();
        }
        if (message.upperBand !== undefined) {
            Quotation.encode(message.upperBand, writer.uint32(26).fork()).ldelim();
        }
        if (message.lowerBand !== undefined) {
            Quotation.encode(message.lowerBand, writer.uint32(34).fork()).ldelim();
        }
        if (message.signal !== undefined) {
            Quotation.encode(message.signal, writer.uint32(42).fork()).ldelim();
        }
        if (message.macd !== undefined) {
            Quotation.encode(message.macd, writer.uint32(50).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetTechAnalysisResponse_TechAnalysisItem();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.middleBand = Quotation.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.upperBand = Quotation.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.lowerBand = Quotation.decode(reader, reader.uint32());
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.signal = Quotation.decode(reader, reader.uint32());
                    continue;
                case 6:
                    if (tag !== 50) {
                        break;
                    }
                    message.macd = Quotation.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
            middleBand: isSet(object.middleBand) ? Quotation.fromJSON(object.middleBand) : undefined,
            upperBand: isSet(object.upperBand) ? Quotation.fromJSON(object.upperBand) : undefined,
            lowerBand: isSet(object.lowerBand) ? Quotation.fromJSON(object.lowerBand) : undefined,
            signal: isSet(object.signal) ? Quotation.fromJSON(object.signal) : undefined,
            macd: isSet(object.macd) ? Quotation.fromJSON(object.macd) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.timestamp !== undefined) {
            obj.timestamp = message.timestamp.toISOString();
        }
        if (message.middleBand !== undefined) {
            obj.middleBand = Quotation.toJSON(message.middleBand);
        }
        if (message.upperBand !== undefined) {
            obj.upperBand = Quotation.toJSON(message.upperBand);
        }
        if (message.lowerBand !== undefined) {
            obj.lowerBand = Quotation.toJSON(message.lowerBand);
        }
        if (message.signal !== undefined) {
            obj.signal = Quotation.toJSON(message.signal);
        }
        if (message.macd !== undefined) {
            obj.macd = Quotation.toJSON(message.macd);
        }
        return obj;
    },
};
function createBaseGetMarketValuesRequest() {
    return { instrumentId: [], values: [] };
}
export const GetMarketValuesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.instrumentId) {
            writer.uint32(10).string(v);
        }
        writer.uint32(18).fork();
        for (const v of message.values) {
            writer.int32(v);
        }
        writer.ldelim();
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetMarketValuesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instrumentId.push(reader.string());
                    continue;
                case 2:
                    if (tag === 16) {
                        message.values.push(reader.int32());
                        continue;
                    }
                    if (tag === 18) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.values.push(reader.int32());
                        }
                        continue;
                    }
                    break;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            instrumentId: globalThis.Array.isArray(object?.instrumentId)
                ? object.instrumentId.map((e) => globalThis.String(e))
                : [],
            values: globalThis.Array.isArray(object?.values) ? object.values.map((e) => marketValueTypeFromJSON(e)) : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.instrumentId?.length) {
            obj.instrumentId = message.instrumentId;
        }
        if (message.values?.length) {
            obj.values = message.values.map((e) => marketValueTypeToJSON(e));
        }
        return obj;
    },
};
function createBaseGetMarketValuesResponse() {
    return { instruments: [] };
}
export const GetMarketValuesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.instruments) {
            MarketValueInstrument.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGetMarketValuesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instruments.push(MarketValueInstrument.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            instruments: globalThis.Array.isArray(object?.instruments)
                ? object.instruments.map((e) => MarketValueInstrument.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.instruments?.length) {
            obj.instruments = message.instruments.map((e) => MarketValueInstrument.toJSON(e));
        }
        return obj;
    },
};
function createBaseMarketValueInstrument() {
    return { instrumentUid: "", values: [], ticker: "", classCode: "" };
}
export const MarketValueInstrument = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.instrumentUid !== "") {
            writer.uint32(10).string(message.instrumentUid);
        }
        for (const v of message.values) {
            MarketValue.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.ticker !== "") {
            writer.uint32(26).string(message.ticker);
        }
        if (message.classCode !== "") {
            writer.uint32(34).string(message.classCode);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMarketValueInstrument();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 10) {
                        break;
                    }
                    message.instrumentUid = reader.string();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.values.push(MarketValue.decode(reader, reader.uint32()));
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.ticker = reader.string();
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.classCode = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            instrumentUid: isSet(object.instrumentUid) ? globalThis.String(object.instrumentUid) : "",
            values: globalThis.Array.isArray(object?.values) ? object.values.map((e) => MarketValue.fromJSON(e)) : [],
            ticker: isSet(object.ticker) ? globalThis.String(object.ticker) : "",
            classCode: isSet(object.classCode) ? globalThis.String(object.classCode) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.instrumentUid !== "") {
            obj.instrumentUid = message.instrumentUid;
        }
        if (message.values?.length) {
            obj.values = message.values.map((e) => MarketValue.toJSON(e));
        }
        if (message.ticker !== "") {
            obj.ticker = message.ticker;
        }
        if (message.classCode !== "") {
            obj.classCode = message.classCode;
        }
        return obj;
    },
};
function createBaseMarketValue() {
    return { type: undefined, value: undefined, time: undefined };
}
export const MarketValue = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.type !== undefined) {
            writer.uint32(8).int32(message.type);
        }
        if (message.value !== undefined) {
            Quotation.encode(message.value, writer.uint32(18).fork()).ldelim();
        }
        if (message.time !== undefined) {
            Timestamp.encode(toTimestamp(message.time), writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMarketValue();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.type = reader.int32();
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.value = Quotation.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            type: isSet(object.type) ? marketValueTypeFromJSON(object.type) : undefined,
            value: isSet(object.value) ? Quotation.fromJSON(object.value) : undefined,
            time: isSet(object.time) ? fromJsonTimestamp(object.time) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.type !== undefined) {
            obj.type = marketValueTypeToJSON(message.type);
        }
        if (message.value !== undefined) {
            obj.value = Quotation.toJSON(message.value);
        }
        if (message.time !== undefined) {
            obj.time = message.time.toISOString();
        }
        return obj;
    },
};
export const MarketDataServiceDefinition = {
    name: "MarketDataService",
    fullName: "tinkoff.public.invest.api.contract.v1.MarketDataService",
    methods: {
        /** GetCandles — исторические свечи по инструменту */
        getCandles: {
            name: "GetCandles",
            requestType: GetCandlesRequest,
            requestStream: false,
            responseType: GetCandlesResponse,
            responseStream: false,
            options: {},
        },
        /** GetLastPrices — цены последних сделок по инструментам */
        getLastPrices: {
            name: "GetLastPrices",
            requestType: GetLastPricesRequest,
            requestStream: false,
            responseType: GetLastPricesResponse,
            responseStream: false,
            options: {},
        },
        /** GetOrderBook — стакан по инструменту */
        getOrderBook: {
            name: "GetOrderBook",
            requestType: GetOrderBookRequest,
            requestStream: false,
            responseType: GetOrderBookResponse,
            responseStream: false,
            options: {},
        },
        /** GetTradingStatus — статус торгов по инструменту */
        getTradingStatus: {
            name: "GetTradingStatus",
            requestType: GetTradingStatusRequest,
            requestStream: false,
            responseType: GetTradingStatusResponse,
            responseStream: false,
            options: {},
        },
        /** GetTradingStatuses — статус торгов по инструментам */
        getTradingStatuses: {
            name: "GetTradingStatuses",
            requestType: GetTradingStatusesRequest,
            requestStream: false,
            responseType: GetTradingStatusesResponse,
            responseStream: false,
            options: {},
        },
        /**
         * GetLastTrades — обезличенные сделки
         * Обезличенные сделки по инструменту. Метод гарантирует получение информации за последний час.
         */
        getLastTrades: {
            name: "GetLastTrades",
            requestType: GetLastTradesRequest,
            requestStream: false,
            responseType: GetLastTradesResponse,
            responseStream: false,
            options: {},
        },
        /** GetClosePrices — цены закрытия торговой сессии по инструментам */
        getClosePrices: {
            name: "GetClosePrices",
            requestType: GetClosePricesRequest,
            requestStream: false,
            responseType: GetClosePricesResponse,
            responseStream: false,
            options: {},
        },
        /** GetTechAnalysis — технические индикаторы по инструменту */
        getTechAnalysis: {
            name: "GetTechAnalysis",
            requestType: GetTechAnalysisRequest,
            requestStream: false,
            responseType: GetTechAnalysisResponse,
            responseStream: false,
            options: {},
        },
        /** GetMarketValues — рыночные данные по инструментам */
        getMarketValues: {
            name: "GetMarketValues",
            requestType: GetMarketValuesRequest,
            requestStream: false,
            responseType: GetMarketValuesResponse,
            responseStream: false,
            options: {},
        },
    },
};
export const MarketDataStreamServiceDefinition = {
    name: "MarketDataStreamService",
    fullName: "tinkoff.public.invest.api.contract.v1.MarketDataStreamService",
    methods: {
        /** MarketDataStream — bidirectional стрим предоставления биржевой информации */
        marketDataStream: {
            name: "MarketDataStream",
            requestType: MarketDataRequest,
            requestStream: true,
            responseType: MarketDataResponse,
            responseStream: true,
            options: {},
        },
        /** MarketDataServerSideStream — server-side стрим предоставления биржевой информации */
        marketDataServerSideStream: {
            name: "MarketDataServerSideStream",
            requestType: MarketDataServerSideStreamRequest,
            requestStream: false,
            responseType: MarketDataResponse,
            responseStream: true,
            options: {},
        },
    },
};
function toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = (t.seconds || 0) * 1000;
    millis += (t.nanos || 0) / 1000000;
    return new globalThis.Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof globalThis.Date) {
        return o;
    }
    else if (typeof o === "string") {
        return new globalThis.Date(o);
    }
    else {
        return fromTimestamp(Timestamp.fromJSON(o));
    }
}
function longToNumber(long) {
    if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    return long.toNumber();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=marketdata.js.map