// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.5
//   protoc               v7.34.1
// source: Order.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { OrderCondition } from "./OrderCondition.js";
import { SoftDollarTier } from "./SoftDollarTier.js";

export const protobufPackage = "protobuf";

export interface Order {
  /** order ids */
  clientId?: number | undefined;
  orderId?: number | undefined;
  permId?: number | undefined;
  parentId?:
    | number
    | undefined;
  /** primary attributes */
  action?: string | undefined;
  totalQuantity?: string | undefined;
  displaySize?: number | undefined;
  orderType?: string | undefined;
  lmtPrice?: number | undefined;
  auxPrice?: number | undefined;
  tif?:
    | string
    | undefined;
  /** clearing info */
  account?: string | undefined;
  settlingFirm?: string | undefined;
  clearingAccount?: string | undefined;
  clearingIntent?:
    | string
    | undefined;
  /** secondary attributes */
  allOrNone?: boolean | undefined;
  blockOrder?: boolean | undefined;
  hidden?: boolean | undefined;
  outsideRth?: boolean | undefined;
  sweepToFill?: boolean | undefined;
  percentOffset?: number | undefined;
  trailingPercent?: number | undefined;
  trailStopPrice?: number | undefined;
  minQty?: number | undefined;
  goodAfterTime?: string | undefined;
  goodTillDate?: string | undefined;
  ocaGroup?: string | undefined;
  orderRef?: string | undefined;
  rule80A?: string | undefined;
  ocaType?: number | undefined;
  triggerMethod?:
    | number
    | undefined;
  /** extended order fields */
  activeStartTime?: string | undefined;
  activeStopTime?:
    | string
    | undefined;
  /** advisor allocation orders */
  faGroup?: string | undefined;
  faMethod?: string | undefined;
  faPercentage?:
    | string
    | undefined;
  /** volatility orders */
  volatility?: number | undefined;
  volatilityType?: number | undefined;
  continuousUpdate?: boolean | undefined;
  referencePriceType?: number | undefined;
  deltaNeutralOrderType?: string | undefined;
  deltaNeutralAuxPrice?: number | undefined;
  deltaNeutralConId?: number | undefined;
  deltaNeutralOpenClose?: string | undefined;
  deltaNeutralShortSale?: boolean | undefined;
  deltaNeutralShortSaleSlot?: number | undefined;
  deltaNeutralDesignatedLocation?:
    | string
    | undefined;
  /** scale orders */
  scaleInitLevelSize?: number | undefined;
  scaleSubsLevelSize?: number | undefined;
  scalePriceIncrement?: number | undefined;
  scalePriceAdjustValue?: number | undefined;
  scalePriceAdjustInterval?: number | undefined;
  scaleProfitOffset?: number | undefined;
  scaleAutoReset?: boolean | undefined;
  scaleInitPosition?: number | undefined;
  scaleInitFillQty?: number | undefined;
  scaleRandomPercent?: boolean | undefined;
  scaleTable?:
    | string
    | undefined;
  /** hedge orders */
  hedgeType?: string | undefined;
  hedgeParam?:
    | string
    | undefined;
  /** algo orders */
  algoStrategy?: string | undefined;
  algoParams: { [key: string]: string };
  algoId?:
    | string
    | undefined;
  /** combo orders */
  smartComboRoutingParams: { [key: string]: string };
  /** processing control */
  whatIf?: boolean | undefined;
  transmit?: boolean | undefined;
  overridePercentageConstraints?:
    | boolean
    | undefined;
  /** Institutional orders only */
  openClose?: string | undefined;
  origin?: number | undefined;
  shortSaleSlot?: number | undefined;
  designatedLocation?: string | undefined;
  exemptCode?: number | undefined;
  deltaNeutralSettlingFirm?: string | undefined;
  deltaNeutralClearingAccount?: string | undefined;
  deltaNeutralClearingIntent?:
    | string
    | undefined;
  /** SMART routing only */
  discretionaryAmt?: number | undefined;
  optOutSmartRouting?:
    | boolean
    | undefined;
  /** BOX ORDERS ONLY */
  startingPrice?: number | undefined;
  stockRefPrice?: number | undefined;
  delta?:
    | number
    | undefined;
  /** pegged to stock or VOL orders */
  stockRangeLower?: number | undefined;
  stockRangeUpper?:
    | number
    | undefined;
  /** Not Held */
  notHeld?:
    | boolean
    | undefined;
  /** order misc options */
  orderMiscOptions: { [key: string]: string };
  /** order algo id */
  solicited?: boolean | undefined;
  randomizeSize?: boolean | undefined;
  randomizePrice?:
    | boolean
    | undefined;
  /** PEG2BENCH fields */
  referenceContractId?: number | undefined;
  peggedChangeAmount?: number | undefined;
  isPeggedChangeAmountDecrease?: boolean | undefined;
  referenceChangeAmount?: number | undefined;
  referenceExchangeId?: string | undefined;
  adjustedOrderType?: string | undefined;
  triggerPrice?: number | undefined;
  adjustedStopPrice?: number | undefined;
  adjustedStopLimitPrice?: number | undefined;
  adjustedTrailingAmount?: number | undefined;
  adjustableTrailingUnit?: number | undefined;
  lmtPriceOffset?: number | undefined;
  conditions: OrderCondition[];
  conditionsCancelOrder?: boolean | undefined;
  conditionsIgnoreRth?:
    | boolean
    | undefined;
  /** models */
  modelCode?: string | undefined;
  extOperator?: string | undefined;
  softDollarTier?:
    | SoftDollarTier
    | undefined;
  /** native cash quantity */
  cashQty?: number | undefined;
  mifid2DecisionMaker?: string | undefined;
  mifid2DecisionAlgo?: string | undefined;
  mifid2ExecutionTrader?: string | undefined;
  mifid2ExecutionAlgo?:
    | string
    | undefined;
  /** don't use auto price for hedge */
  dontUseAutoPriceForHedge?: boolean | undefined;
  isOmsContainer?: boolean | undefined;
  discretionaryUpToLimitPrice?: boolean | undefined;
  autoCancelDate?: string | undefined;
  filledQuantity?: string | undefined;
  refFuturesConId?: number | undefined;
  autoCancelParent?: boolean | undefined;
  shareholder?: string | undefined;
  imbalanceOnly?: boolean | undefined;
  routeMarketableToBbo?: number | undefined;
  parentPermId?: number | undefined;
  usePriceMgmtAlgo?: number | undefined;
  duration?: number | undefined;
  postToAts?: number | undefined;
  advancedErrorOverride?: string | undefined;
  manualOrderTime?: string | undefined;
  minTradeQty?: number | undefined;
  minCompeteSize?: number | undefined;
  competeAgainstBestOffset?: number | undefined;
  midOffsetAtWhole?: number | undefined;
  midOffsetAtHalf?: number | undefined;
  customerAccount?: string | undefined;
  professionalCustomer?: boolean | undefined;
  bondAccruedInterest?: string | undefined;
  includeOvernight?: boolean | undefined;
  manualOrderIndicator?: number | undefined;
  submitter?: string | undefined;
  deactivate?: boolean | undefined;
  postOnly?: boolean | undefined;
  allowPreOpen?: boolean | undefined;
  ignoreOpenAuction?: boolean | undefined;
  seekPriceImprovement?: number | undefined;
  whatIfType?: number | undefined;
}

export interface Order_AlgoParamsEntry {
  key: string;
  value: string;
}

export interface Order_SmartComboRoutingParamsEntry {
  key: string;
  value: string;
}

export interface Order_OrderMiscOptionsEntry {
  key: string;
  value: string;
}

function createBaseOrder(): Order {
  return {
    clientId: undefined,
    orderId: undefined,
    permId: undefined,
    parentId: undefined,
    action: undefined,
    totalQuantity: undefined,
    displaySize: undefined,
    orderType: undefined,
    lmtPrice: undefined,
    auxPrice: undefined,
    tif: undefined,
    account: undefined,
    settlingFirm: undefined,
    clearingAccount: undefined,
    clearingIntent: undefined,
    allOrNone: undefined,
    blockOrder: undefined,
    hidden: undefined,
    outsideRth: undefined,
    sweepToFill: undefined,
    percentOffset: undefined,
    trailingPercent: undefined,
    trailStopPrice: undefined,
    minQty: undefined,
    goodAfterTime: undefined,
    goodTillDate: undefined,
    ocaGroup: undefined,
    orderRef: undefined,
    rule80A: undefined,
    ocaType: undefined,
    triggerMethod: undefined,
    activeStartTime: undefined,
    activeStopTime: undefined,
    faGroup: undefined,
    faMethod: undefined,
    faPercentage: undefined,
    volatility: undefined,
    volatilityType: undefined,
    continuousUpdate: undefined,
    referencePriceType: undefined,
    deltaNeutralOrderType: undefined,
    deltaNeutralAuxPrice: undefined,
    deltaNeutralConId: undefined,
    deltaNeutralOpenClose: undefined,
    deltaNeutralShortSale: undefined,
    deltaNeutralShortSaleSlot: undefined,
    deltaNeutralDesignatedLocation: undefined,
    scaleInitLevelSize: undefined,
    scaleSubsLevelSize: undefined,
    scalePriceIncrement: undefined,
    scalePriceAdjustValue: undefined,
    scalePriceAdjustInterval: undefined,
    scaleProfitOffset: undefined,
    scaleAutoReset: undefined,
    scaleInitPosition: undefined,
    scaleInitFillQty: undefined,
    scaleRandomPercent: undefined,
    scaleTable: undefined,
    hedgeType: undefined,
    hedgeParam: undefined,
    algoStrategy: undefined,
    algoParams: {},
    algoId: undefined,
    smartComboRoutingParams: {},
    whatIf: undefined,
    transmit: undefined,
    overridePercentageConstraints: undefined,
    openClose: undefined,
    origin: undefined,
    shortSaleSlot: undefined,
    designatedLocation: undefined,
    exemptCode: undefined,
    deltaNeutralSettlingFirm: undefined,
    deltaNeutralClearingAccount: undefined,
    deltaNeutralClearingIntent: undefined,
    discretionaryAmt: undefined,
    optOutSmartRouting: undefined,
    startingPrice: undefined,
    stockRefPrice: undefined,
    delta: undefined,
    stockRangeLower: undefined,
    stockRangeUpper: undefined,
    notHeld: undefined,
    orderMiscOptions: {},
    solicited: undefined,
    randomizeSize: undefined,
    randomizePrice: undefined,
    referenceContractId: undefined,
    peggedChangeAmount: undefined,
    isPeggedChangeAmountDecrease: undefined,
    referenceChangeAmount: undefined,
    referenceExchangeId: undefined,
    adjustedOrderType: undefined,
    triggerPrice: undefined,
    adjustedStopPrice: undefined,
    adjustedStopLimitPrice: undefined,
    adjustedTrailingAmount: undefined,
    adjustableTrailingUnit: undefined,
    lmtPriceOffset: undefined,
    conditions: [],
    conditionsCancelOrder: undefined,
    conditionsIgnoreRth: undefined,
    modelCode: undefined,
    extOperator: undefined,
    softDollarTier: undefined,
    cashQty: undefined,
    mifid2DecisionMaker: undefined,
    mifid2DecisionAlgo: undefined,
    mifid2ExecutionTrader: undefined,
    mifid2ExecutionAlgo: undefined,
    dontUseAutoPriceForHedge: undefined,
    isOmsContainer: undefined,
    discretionaryUpToLimitPrice: undefined,
    autoCancelDate: undefined,
    filledQuantity: undefined,
    refFuturesConId: undefined,
    autoCancelParent: undefined,
    shareholder: undefined,
    imbalanceOnly: undefined,
    routeMarketableToBbo: undefined,
    parentPermId: undefined,
    usePriceMgmtAlgo: undefined,
    duration: undefined,
    postToAts: undefined,
    advancedErrorOverride: undefined,
    manualOrderTime: undefined,
    minTradeQty: undefined,
    minCompeteSize: undefined,
    competeAgainstBestOffset: undefined,
    midOffsetAtWhole: undefined,
    midOffsetAtHalf: undefined,
    customerAccount: undefined,
    professionalCustomer: undefined,
    bondAccruedInterest: undefined,
    includeOvernight: undefined,
    manualOrderIndicator: undefined,
    submitter: undefined,
    deactivate: undefined,
    postOnly: undefined,
    allowPreOpen: undefined,
    ignoreOpenAuction: undefined,
    seekPriceImprovement: undefined,
    whatIfType: undefined,
  };
}

export const Order: MessageFns<Order> = {
  encode(message: Order, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.clientId !== undefined) {
      writer.uint32(8).int32(message.clientId);
    }
    if (message.orderId !== undefined) {
      writer.uint32(16).int32(message.orderId);
    }
    if (message.permId !== undefined) {
      writer.uint32(24).int64(message.permId);
    }
    if (message.parentId !== undefined) {
      writer.uint32(32).int32(message.parentId);
    }
    if (message.action !== undefined) {
      writer.uint32(42).string(message.action);
    }
    if (message.totalQuantity !== undefined) {
      writer.uint32(50).string(message.totalQuantity);
    }
    if (message.displaySize !== undefined) {
      writer.uint32(56).int32(message.displaySize);
    }
    if (message.orderType !== undefined) {
      writer.uint32(66).string(message.orderType);
    }
    if (message.lmtPrice !== undefined) {
      writer.uint32(73).double(message.lmtPrice);
    }
    if (message.auxPrice !== undefined) {
      writer.uint32(81).double(message.auxPrice);
    }
    if (message.tif !== undefined) {
      writer.uint32(90).string(message.tif);
    }
    if (message.account !== undefined) {
      writer.uint32(98).string(message.account);
    }
    if (message.settlingFirm !== undefined) {
      writer.uint32(106).string(message.settlingFirm);
    }
    if (message.clearingAccount !== undefined) {
      writer.uint32(114).string(message.clearingAccount);
    }
    if (message.clearingIntent !== undefined) {
      writer.uint32(122).string(message.clearingIntent);
    }
    if (message.allOrNone !== undefined) {
      writer.uint32(128).bool(message.allOrNone);
    }
    if (message.blockOrder !== undefined) {
      writer.uint32(136).bool(message.blockOrder);
    }
    if (message.hidden !== undefined) {
      writer.uint32(144).bool(message.hidden);
    }
    if (message.outsideRth !== undefined) {
      writer.uint32(152).bool(message.outsideRth);
    }
    if (message.sweepToFill !== undefined) {
      writer.uint32(160).bool(message.sweepToFill);
    }
    if (message.percentOffset !== undefined) {
      writer.uint32(169).double(message.percentOffset);
    }
    if (message.trailingPercent !== undefined) {
      writer.uint32(177).double(message.trailingPercent);
    }
    if (message.trailStopPrice !== undefined) {
      writer.uint32(185).double(message.trailStopPrice);
    }
    if (message.minQty !== undefined) {
      writer.uint32(192).int32(message.minQty);
    }
    if (message.goodAfterTime !== undefined) {
      writer.uint32(202).string(message.goodAfterTime);
    }
    if (message.goodTillDate !== undefined) {
      writer.uint32(210).string(message.goodTillDate);
    }
    if (message.ocaGroup !== undefined) {
      writer.uint32(218).string(message.ocaGroup);
    }
    if (message.orderRef !== undefined) {
      writer.uint32(226).string(message.orderRef);
    }
    if (message.rule80A !== undefined) {
      writer.uint32(234).string(message.rule80A);
    }
    if (message.ocaType !== undefined) {
      writer.uint32(240).int32(message.ocaType);
    }
    if (message.triggerMethod !== undefined) {
      writer.uint32(248).int32(message.triggerMethod);
    }
    if (message.activeStartTime !== undefined) {
      writer.uint32(258).string(message.activeStartTime);
    }
    if (message.activeStopTime !== undefined) {
      writer.uint32(266).string(message.activeStopTime);
    }
    if (message.faGroup !== undefined) {
      writer.uint32(274).string(message.faGroup);
    }
    if (message.faMethod !== undefined) {
      writer.uint32(282).string(message.faMethod);
    }
    if (message.faPercentage !== undefined) {
      writer.uint32(290).string(message.faPercentage);
    }
    if (message.volatility !== undefined) {
      writer.uint32(297).double(message.volatility);
    }
    if (message.volatilityType !== undefined) {
      writer.uint32(304).int32(message.volatilityType);
    }
    if (message.continuousUpdate !== undefined) {
      writer.uint32(312).bool(message.continuousUpdate);
    }
    if (message.referencePriceType !== undefined) {
      writer.uint32(320).int32(message.referencePriceType);
    }
    if (message.deltaNeutralOrderType !== undefined) {
      writer.uint32(330).string(message.deltaNeutralOrderType);
    }
    if (message.deltaNeutralAuxPrice !== undefined) {
      writer.uint32(337).double(message.deltaNeutralAuxPrice);
    }
    if (message.deltaNeutralConId !== undefined) {
      writer.uint32(344).int32(message.deltaNeutralConId);
    }
    if (message.deltaNeutralOpenClose !== undefined) {
      writer.uint32(354).string(message.deltaNeutralOpenClose);
    }
    if (message.deltaNeutralShortSale !== undefined) {
      writer.uint32(360).bool(message.deltaNeutralShortSale);
    }
    if (message.deltaNeutralShortSaleSlot !== undefined) {
      writer.uint32(368).int32(message.deltaNeutralShortSaleSlot);
    }
    if (message.deltaNeutralDesignatedLocation !== undefined) {
      writer.uint32(378).string(message.deltaNeutralDesignatedLocation);
    }
    if (message.scaleInitLevelSize !== undefined) {
      writer.uint32(384).int32(message.scaleInitLevelSize);
    }
    if (message.scaleSubsLevelSize !== undefined) {
      writer.uint32(392).int32(message.scaleSubsLevelSize);
    }
    if (message.scalePriceIncrement !== undefined) {
      writer.uint32(401).double(message.scalePriceIncrement);
    }
    if (message.scalePriceAdjustValue !== undefined) {
      writer.uint32(409).double(message.scalePriceAdjustValue);
    }
    if (message.scalePriceAdjustInterval !== undefined) {
      writer.uint32(416).int32(message.scalePriceAdjustInterval);
    }
    if (message.scaleProfitOffset !== undefined) {
      writer.uint32(425).double(message.scaleProfitOffset);
    }
    if (message.scaleAutoReset !== undefined) {
      writer.uint32(432).bool(message.scaleAutoReset);
    }
    if (message.scaleInitPosition !== undefined) {
      writer.uint32(440).int32(message.scaleInitPosition);
    }
    if (message.scaleInitFillQty !== undefined) {
      writer.uint32(448).int32(message.scaleInitFillQty);
    }
    if (message.scaleRandomPercent !== undefined) {
      writer.uint32(456).bool(message.scaleRandomPercent);
    }
    if (message.scaleTable !== undefined) {
      writer.uint32(466).string(message.scaleTable);
    }
    if (message.hedgeType !== undefined) {
      writer.uint32(474).string(message.hedgeType);
    }
    if (message.hedgeParam !== undefined) {
      writer.uint32(482).string(message.hedgeParam);
    }
    if (message.algoStrategy !== undefined) {
      writer.uint32(490).string(message.algoStrategy);
    }
    globalThis.Object.entries(message.algoParams).forEach(([key, value]: [string, string]) => {
      Order_AlgoParamsEntry.encode({ key: key as any, value }, writer.uint32(498).fork()).join();
    });
    if (message.algoId !== undefined) {
      writer.uint32(506).string(message.algoId);
    }
    globalThis.Object.entries(message.smartComboRoutingParams).forEach(([key, value]: [string, string]) => {
      Order_SmartComboRoutingParamsEntry.encode({ key: key as any, value }, writer.uint32(514).fork()).join();
    });
    if (message.whatIf !== undefined) {
      writer.uint32(520).bool(message.whatIf);
    }
    if (message.transmit !== undefined) {
      writer.uint32(528).bool(message.transmit);
    }
    if (message.overridePercentageConstraints !== undefined) {
      writer.uint32(536).bool(message.overridePercentageConstraints);
    }
    if (message.openClose !== undefined) {
      writer.uint32(546).string(message.openClose);
    }
    if (message.origin !== undefined) {
      writer.uint32(552).int32(message.origin);
    }
    if (message.shortSaleSlot !== undefined) {
      writer.uint32(560).int32(message.shortSaleSlot);
    }
    if (message.designatedLocation !== undefined) {
      writer.uint32(570).string(message.designatedLocation);
    }
    if (message.exemptCode !== undefined) {
      writer.uint32(576).int32(message.exemptCode);
    }
    if (message.deltaNeutralSettlingFirm !== undefined) {
      writer.uint32(586).string(message.deltaNeutralSettlingFirm);
    }
    if (message.deltaNeutralClearingAccount !== undefined) {
      writer.uint32(594).string(message.deltaNeutralClearingAccount);
    }
    if (message.deltaNeutralClearingIntent !== undefined) {
      writer.uint32(602).string(message.deltaNeutralClearingIntent);
    }
    if (message.discretionaryAmt !== undefined) {
      writer.uint32(609).double(message.discretionaryAmt);
    }
    if (message.optOutSmartRouting !== undefined) {
      writer.uint32(616).bool(message.optOutSmartRouting);
    }
    if (message.startingPrice !== undefined) {
      writer.uint32(625).double(message.startingPrice);
    }
    if (message.stockRefPrice !== undefined) {
      writer.uint32(633).double(message.stockRefPrice);
    }
    if (message.delta !== undefined) {
      writer.uint32(641).double(message.delta);
    }
    if (message.stockRangeLower !== undefined) {
      writer.uint32(649).double(message.stockRangeLower);
    }
    if (message.stockRangeUpper !== undefined) {
      writer.uint32(657).double(message.stockRangeUpper);
    }
    if (message.notHeld !== undefined) {
      writer.uint32(664).bool(message.notHeld);
    }
    globalThis.Object.entries(message.orderMiscOptions).forEach(([key, value]: [string, string]) => {
      Order_OrderMiscOptionsEntry.encode({ key: key as any, value }, writer.uint32(674).fork()).join();
    });
    if (message.solicited !== undefined) {
      writer.uint32(680).bool(message.solicited);
    }
    if (message.randomizeSize !== undefined) {
      writer.uint32(688).bool(message.randomizeSize);
    }
    if (message.randomizePrice !== undefined) {
      writer.uint32(696).bool(message.randomizePrice);
    }
    if (message.referenceContractId !== undefined) {
      writer.uint32(704).int32(message.referenceContractId);
    }
    if (message.peggedChangeAmount !== undefined) {
      writer.uint32(713).double(message.peggedChangeAmount);
    }
    if (message.isPeggedChangeAmountDecrease !== undefined) {
      writer.uint32(720).bool(message.isPeggedChangeAmountDecrease);
    }
    if (message.referenceChangeAmount !== undefined) {
      writer.uint32(729).double(message.referenceChangeAmount);
    }
    if (message.referenceExchangeId !== undefined) {
      writer.uint32(738).string(message.referenceExchangeId);
    }
    if (message.adjustedOrderType !== undefined) {
      writer.uint32(746).string(message.adjustedOrderType);
    }
    if (message.triggerPrice !== undefined) {
      writer.uint32(753).double(message.triggerPrice);
    }
    if (message.adjustedStopPrice !== undefined) {
      writer.uint32(761).double(message.adjustedStopPrice);
    }
    if (message.adjustedStopLimitPrice !== undefined) {
      writer.uint32(769).double(message.adjustedStopLimitPrice);
    }
    if (message.adjustedTrailingAmount !== undefined) {
      writer.uint32(777).double(message.adjustedTrailingAmount);
    }
    if (message.adjustableTrailingUnit !== undefined) {
      writer.uint32(784).int32(message.adjustableTrailingUnit);
    }
    if (message.lmtPriceOffset !== undefined) {
      writer.uint32(793).double(message.lmtPriceOffset);
    }
    for (const v of message.conditions) {
      OrderCondition.encode(v!, writer.uint32(802).fork()).join();
    }
    if (message.conditionsCancelOrder !== undefined) {
      writer.uint32(808).bool(message.conditionsCancelOrder);
    }
    if (message.conditionsIgnoreRth !== undefined) {
      writer.uint32(816).bool(message.conditionsIgnoreRth);
    }
    if (message.modelCode !== undefined) {
      writer.uint32(826).string(message.modelCode);
    }
    if (message.extOperator !== undefined) {
      writer.uint32(834).string(message.extOperator);
    }
    if (message.softDollarTier !== undefined) {
      SoftDollarTier.encode(message.softDollarTier, writer.uint32(842).fork()).join();
    }
    if (message.cashQty !== undefined) {
      writer.uint32(849).double(message.cashQty);
    }
    if (message.mifid2DecisionMaker !== undefined) {
      writer.uint32(858).string(message.mifid2DecisionMaker);
    }
    if (message.mifid2DecisionAlgo !== undefined) {
      writer.uint32(866).string(message.mifid2DecisionAlgo);
    }
    if (message.mifid2ExecutionTrader !== undefined) {
      writer.uint32(874).string(message.mifid2ExecutionTrader);
    }
    if (message.mifid2ExecutionAlgo !== undefined) {
      writer.uint32(882).string(message.mifid2ExecutionAlgo);
    }
    if (message.dontUseAutoPriceForHedge !== undefined) {
      writer.uint32(888).bool(message.dontUseAutoPriceForHedge);
    }
    if (message.isOmsContainer !== undefined) {
      writer.uint32(896).bool(message.isOmsContainer);
    }
    if (message.discretionaryUpToLimitPrice !== undefined) {
      writer.uint32(904).bool(message.discretionaryUpToLimitPrice);
    }
    if (message.autoCancelDate !== undefined) {
      writer.uint32(914).string(message.autoCancelDate);
    }
    if (message.filledQuantity !== undefined) {
      writer.uint32(922).string(message.filledQuantity);
    }
    if (message.refFuturesConId !== undefined) {
      writer.uint32(928).int32(message.refFuturesConId);
    }
    if (message.autoCancelParent !== undefined) {
      writer.uint32(936).bool(message.autoCancelParent);
    }
    if (message.shareholder !== undefined) {
      writer.uint32(946).string(message.shareholder);
    }
    if (message.imbalanceOnly !== undefined) {
      writer.uint32(952).bool(message.imbalanceOnly);
    }
    if (message.routeMarketableToBbo !== undefined) {
      writer.uint32(960).int32(message.routeMarketableToBbo);
    }
    if (message.parentPermId !== undefined) {
      writer.uint32(968).int64(message.parentPermId);
    }
    if (message.usePriceMgmtAlgo !== undefined) {
      writer.uint32(976).int32(message.usePriceMgmtAlgo);
    }
    if (message.duration !== undefined) {
      writer.uint32(984).int32(message.duration);
    }
    if (message.postToAts !== undefined) {
      writer.uint32(992).int32(message.postToAts);
    }
    if (message.advancedErrorOverride !== undefined) {
      writer.uint32(1002).string(message.advancedErrorOverride);
    }
    if (message.manualOrderTime !== undefined) {
      writer.uint32(1010).string(message.manualOrderTime);
    }
    if (message.minTradeQty !== undefined) {
      writer.uint32(1016).int32(message.minTradeQty);
    }
    if (message.minCompeteSize !== undefined) {
      writer.uint32(1024).int32(message.minCompeteSize);
    }
    if (message.competeAgainstBestOffset !== undefined) {
      writer.uint32(1033).double(message.competeAgainstBestOffset);
    }
    if (message.midOffsetAtWhole !== undefined) {
      writer.uint32(1041).double(message.midOffsetAtWhole);
    }
    if (message.midOffsetAtHalf !== undefined) {
      writer.uint32(1049).double(message.midOffsetAtHalf);
    }
    if (message.customerAccount !== undefined) {
      writer.uint32(1058).string(message.customerAccount);
    }
    if (message.professionalCustomer !== undefined) {
      writer.uint32(1064).bool(message.professionalCustomer);
    }
    if (message.bondAccruedInterest !== undefined) {
      writer.uint32(1074).string(message.bondAccruedInterest);
    }
    if (message.includeOvernight !== undefined) {
      writer.uint32(1080).bool(message.includeOvernight);
    }
    if (message.manualOrderIndicator !== undefined) {
      writer.uint32(1088).int32(message.manualOrderIndicator);
    }
    if (message.submitter !== undefined) {
      writer.uint32(1098).string(message.submitter);
    }
    if (message.deactivate !== undefined) {
      writer.uint32(1104).bool(message.deactivate);
    }
    if (message.postOnly !== undefined) {
      writer.uint32(1112).bool(message.postOnly);
    }
    if (message.allowPreOpen !== undefined) {
      writer.uint32(1120).bool(message.allowPreOpen);
    }
    if (message.ignoreOpenAuction !== undefined) {
      writer.uint32(1128).bool(message.ignoreOpenAuction);
    }
    if (message.seekPriceImprovement !== undefined) {
      writer.uint32(1136).int32(message.seekPriceImprovement);
    }
    if (message.whatIfType !== undefined) {
      writer.uint32(1144).int32(message.whatIfType);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): Order {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const 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 !== 8) {
            break;
          }

          message.clientId = reader.int32();
          continue;
        }
        case 2: {
          if (tag !== 16) {
            break;
          }

          message.orderId = reader.int32();
          continue;
        }
        case 3: {
          if (tag !== 24) {
            break;
          }

          message.permId = longToNumber(reader.int64());
          continue;
        }
        case 4: {
          if (tag !== 32) {
            break;
          }

          message.parentId = reader.int32();
          continue;
        }
        case 5: {
          if (tag !== 42) {
            break;
          }

          message.action = reader.string();
          continue;
        }
        case 6: {
          if (tag !== 50) {
            break;
          }

          message.totalQuantity = reader.string();
          continue;
        }
        case 7: {
          if (tag !== 56) {
            break;
          }

          message.displaySize = reader.int32();
          continue;
        }
        case 8: {
          if (tag !== 66) {
            break;
          }

          message.orderType = reader.string();
          continue;
        }
        case 9: {
          if (tag !== 73) {
            break;
          }

          message.lmtPrice = reader.double();
          continue;
        }
        case 10: {
          if (tag !== 81) {
            break;
          }

          message.auxPrice = reader.double();
          continue;
        }
        case 11: {
          if (tag !== 90) {
            break;
          }

          message.tif = reader.string();
          continue;
        }
        case 12: {
          if (tag !== 98) {
            break;
          }

          message.account = reader.string();
          continue;
        }
        case 13: {
          if (tag !== 106) {
            break;
          }

          message.settlingFirm = reader.string();
          continue;
        }
        case 14: {
          if (tag !== 114) {
            break;
          }

          message.clearingAccount = reader.string();
          continue;
        }
        case 15: {
          if (tag !== 122) {
            break;
          }

          message.clearingIntent = reader.string();
          continue;
        }
        case 16: {
          if (tag !== 128) {
            break;
          }

          message.allOrNone = reader.bool();
          continue;
        }
        case 17: {
          if (tag !== 136) {
            break;
          }

          message.blockOrder = reader.bool();
          continue;
        }
        case 18: {
          if (tag !== 144) {
            break;
          }

          message.hidden = reader.bool();
          continue;
        }
        case 19: {
          if (tag !== 152) {
            break;
          }

          message.outsideRth = reader.bool();
          continue;
        }
        case 20: {
          if (tag !== 160) {
            break;
          }

          message.sweepToFill = reader.bool();
          continue;
        }
        case 21: {
          if (tag !== 169) {
            break;
          }

          message.percentOffset = reader.double();
          continue;
        }
        case 22: {
          if (tag !== 177) {
            break;
          }

          message.trailingPercent = reader.double();
          continue;
        }
        case 23: {
          if (tag !== 185) {
            break;
          }

          message.trailStopPrice = reader.double();
          continue;
        }
        case 24: {
          if (tag !== 192) {
            break;
          }

          message.minQty = reader.int32();
          continue;
        }
        case 25: {
          if (tag !== 202) {
            break;
          }

          message.goodAfterTime = reader.string();
          continue;
        }
        case 26: {
          if (tag !== 210) {
            break;
          }

          message.goodTillDate = reader.string();
          continue;
        }
        case 27: {
          if (tag !== 218) {
            break;
          }

          message.ocaGroup = reader.string();
          continue;
        }
        case 28: {
          if (tag !== 226) {
            break;
          }

          message.orderRef = reader.string();
          continue;
        }
        case 29: {
          if (tag !== 234) {
            break;
          }

          message.rule80A = reader.string();
          continue;
        }
        case 30: {
          if (tag !== 240) {
            break;
          }

          message.ocaType = reader.int32();
          continue;
        }
        case 31: {
          if (tag !== 248) {
            break;
          }

          message.triggerMethod = reader.int32();
          continue;
        }
        case 32: {
          if (tag !== 258) {
            break;
          }

          message.activeStartTime = reader.string();
          continue;
        }
        case 33: {
          if (tag !== 266) {
            break;
          }

          message.activeStopTime = reader.string();
          continue;
        }
        case 34: {
          if (tag !== 274) {
            break;
          }

          message.faGroup = reader.string();
          continue;
        }
        case 35: {
          if (tag !== 282) {
            break;
          }

          message.faMethod = reader.string();
          continue;
        }
        case 36: {
          if (tag !== 290) {
            break;
          }

          message.faPercentage = reader.string();
          continue;
        }
        case 37: {
          if (tag !== 297) {
            break;
          }

          message.volatility = reader.double();
          continue;
        }
        case 38: {
          if (tag !== 304) {
            break;
          }

          message.volatilityType = reader.int32();
          continue;
        }
        case 39: {
          if (tag !== 312) {
            break;
          }

          message.continuousUpdate = reader.bool();
          continue;
        }
        case 40: {
          if (tag !== 320) {
            break;
          }

          message.referencePriceType = reader.int32();
          continue;
        }
        case 41: {
          if (tag !== 330) {
            break;
          }

          message.deltaNeutralOrderType = reader.string();
          continue;
        }
        case 42: {
          if (tag !== 337) {
            break;
          }

          message.deltaNeutralAuxPrice = reader.double();
          continue;
        }
        case 43: {
          if (tag !== 344) {
            break;
          }

          message.deltaNeutralConId = reader.int32();
          continue;
        }
        case 44: {
          if (tag !== 354) {
            break;
          }

          message.deltaNeutralOpenClose = reader.string();
          continue;
        }
        case 45: {
          if (tag !== 360) {
            break;
          }

          message.deltaNeutralShortSale = reader.bool();
          continue;
        }
        case 46: {
          if (tag !== 368) {
            break;
          }

          message.deltaNeutralShortSaleSlot = reader.int32();
          continue;
        }
        case 47: {
          if (tag !== 378) {
            break;
          }

          message.deltaNeutralDesignatedLocation = reader.string();
          continue;
        }
        case 48: {
          if (tag !== 384) {
            break;
          }

          message.scaleInitLevelSize = reader.int32();
          continue;
        }
        case 49: {
          if (tag !== 392) {
            break;
          }

          message.scaleSubsLevelSize = reader.int32();
          continue;
        }
        case 50: {
          if (tag !== 401) {
            break;
          }

          message.scalePriceIncrement = reader.double();
          continue;
        }
        case 51: {
          if (tag !== 409) {
            break;
          }

          message.scalePriceAdjustValue = reader.double();
          continue;
        }
        case 52: {
          if (tag !== 416) {
            break;
          }

          message.scalePriceAdjustInterval = reader.int32();
          continue;
        }
        case 53: {
          if (tag !== 425) {
            break;
          }

          message.scaleProfitOffset = reader.double();
          continue;
        }
        case 54: {
          if (tag !== 432) {
            break;
          }

          message.scaleAutoReset = reader.bool();
          continue;
        }
        case 55: {
          if (tag !== 440) {
            break;
          }

          message.scaleInitPosition = reader.int32();
          continue;
        }
        case 56: {
          if (tag !== 448) {
            break;
          }

          message.scaleInitFillQty = reader.int32();
          continue;
        }
        case 57: {
          if (tag !== 456) {
            break;
          }

          message.scaleRandomPercent = reader.bool();
          continue;
        }
        case 58: {
          if (tag !== 466) {
            break;
          }

          message.scaleTable = reader.string();
          continue;
        }
        case 59: {
          if (tag !== 474) {
            break;
          }

          message.hedgeType = reader.string();
          continue;
        }
        case 60: {
          if (tag !== 482) {
            break;
          }

          message.hedgeParam = reader.string();
          continue;
        }
        case 61: {
          if (tag !== 490) {
            break;
          }

          message.algoStrategy = reader.string();
          continue;
        }
        case 62: {
          if (tag !== 498) {
            break;
          }

          const entry62 = Order_AlgoParamsEntry.decode(reader, reader.uint32());
          if (entry62.value !== undefined) {
            message.algoParams[entry62.key] = entry62.value;
          }
          continue;
        }
        case 63: {
          if (tag !== 506) {
            break;
          }

          message.algoId = reader.string();
          continue;
        }
        case 64: {
          if (tag !== 514) {
            break;
          }

          const entry64 = Order_SmartComboRoutingParamsEntry.decode(reader, reader.uint32());
          if (entry64.value !== undefined) {
            message.smartComboRoutingParams[entry64.key] = entry64.value;
          }
          continue;
        }
        case 65: {
          if (tag !== 520) {
            break;
          }

          message.whatIf = reader.bool();
          continue;
        }
        case 66: {
          if (tag !== 528) {
            break;
          }

          message.transmit = reader.bool();
          continue;
        }
        case 67: {
          if (tag !== 536) {
            break;
          }

          message.overridePercentageConstraints = reader.bool();
          continue;
        }
        case 68: {
          if (tag !== 546) {
            break;
          }

          message.openClose = reader.string();
          continue;
        }
        case 69: {
          if (tag !== 552) {
            break;
          }

          message.origin = reader.int32();
          continue;
        }
        case 70: {
          if (tag !== 560) {
            break;
          }

          message.shortSaleSlot = reader.int32();
          continue;
        }
        case 71: {
          if (tag !== 570) {
            break;
          }

          message.designatedLocation = reader.string();
          continue;
        }
        case 72: {
          if (tag !== 576) {
            break;
          }

          message.exemptCode = reader.int32();
          continue;
        }
        case 73: {
          if (tag !== 586) {
            break;
          }

          message.deltaNeutralSettlingFirm = reader.string();
          continue;
        }
        case 74: {
          if (tag !== 594) {
            break;
          }

          message.deltaNeutralClearingAccount = reader.string();
          continue;
        }
        case 75: {
          if (tag !== 602) {
            break;
          }

          message.deltaNeutralClearingIntent = reader.string();
          continue;
        }
        case 76: {
          if (tag !== 609) {
            break;
          }

          message.discretionaryAmt = reader.double();
          continue;
        }
        case 77: {
          if (tag !== 616) {
            break;
          }

          message.optOutSmartRouting = reader.bool();
          continue;
        }
        case 78: {
          if (tag !== 625) {
            break;
          }

          message.startingPrice = reader.double();
          continue;
        }
        case 79: {
          if (tag !== 633) {
            break;
          }

          message.stockRefPrice = reader.double();
          continue;
        }
        case 80: {
          if (tag !== 641) {
            break;
          }

          message.delta = reader.double();
          continue;
        }
        case 81: {
          if (tag !== 649) {
            break;
          }

          message.stockRangeLower = reader.double();
          continue;
        }
        case 82: {
          if (tag !== 657) {
            break;
          }

          message.stockRangeUpper = reader.double();
          continue;
        }
        case 83: {
          if (tag !== 664) {
            break;
          }

          message.notHeld = reader.bool();
          continue;
        }
        case 84: {
          if (tag !== 674) {
            break;
          }

          const entry84 = Order_OrderMiscOptionsEntry.decode(reader, reader.uint32());
          if (entry84.value !== undefined) {
            message.orderMiscOptions[entry84.key] = entry84.value;
          }
          continue;
        }
        case 85: {
          if (tag !== 680) {
            break;
          }

          message.solicited = reader.bool();
          continue;
        }
        case 86: {
          if (tag !== 688) {
            break;
          }

          message.randomizeSize = reader.bool();
          continue;
        }
        case 87: {
          if (tag !== 696) {
            break;
          }

          message.randomizePrice = reader.bool();
          continue;
        }
        case 88: {
          if (tag !== 704) {
            break;
          }

          message.referenceContractId = reader.int32();
          continue;
        }
        case 89: {
          if (tag !== 713) {
            break;
          }

          message.peggedChangeAmount = reader.double();
          continue;
        }
        case 90: {
          if (tag !== 720) {
            break;
          }

          message.isPeggedChangeAmountDecrease = reader.bool();
          continue;
        }
        case 91: {
          if (tag !== 729) {
            break;
          }

          message.referenceChangeAmount = reader.double();
          continue;
        }
        case 92: {
          if (tag !== 738) {
            break;
          }

          message.referenceExchangeId = reader.string();
          continue;
        }
        case 93: {
          if (tag !== 746) {
            break;
          }

          message.adjustedOrderType = reader.string();
          continue;
        }
        case 94: {
          if (tag !== 753) {
            break;
          }

          message.triggerPrice = reader.double();
          continue;
        }
        case 95: {
          if (tag !== 761) {
            break;
          }

          message.adjustedStopPrice = reader.double();
          continue;
        }
        case 96: {
          if (tag !== 769) {
            break;
          }

          message.adjustedStopLimitPrice = reader.double();
          continue;
        }
        case 97: {
          if (tag !== 777) {
            break;
          }

          message.adjustedTrailingAmount = reader.double();
          continue;
        }
        case 98: {
          if (tag !== 784) {
            break;
          }

          message.adjustableTrailingUnit = reader.int32();
          continue;
        }
        case 99: {
          if (tag !== 793) {
            break;
          }

          message.lmtPriceOffset = reader.double();
          continue;
        }
        case 100: {
          if (tag !== 802) {
            break;
          }

          message.conditions.push(OrderCondition.decode(reader, reader.uint32()));
          continue;
        }
        case 101: {
          if (tag !== 808) {
            break;
          }

          message.conditionsCancelOrder = reader.bool();
          continue;
        }
        case 102: {
          if (tag !== 816) {
            break;
          }

          message.conditionsIgnoreRth = reader.bool();
          continue;
        }
        case 103: {
          if (tag !== 826) {
            break;
          }

          message.modelCode = reader.string();
          continue;
        }
        case 104: {
          if (tag !== 834) {
            break;
          }

          message.extOperator = reader.string();
          continue;
        }
        case 105: {
          if (tag !== 842) {
            break;
          }

          message.softDollarTier = SoftDollarTier.decode(reader, reader.uint32());
          continue;
        }
        case 106: {
          if (tag !== 849) {
            break;
          }

          message.cashQty = reader.double();
          continue;
        }
        case 107: {
          if (tag !== 858) {
            break;
          }

          message.mifid2DecisionMaker = reader.string();
          continue;
        }
        case 108: {
          if (tag !== 866) {
            break;
          }

          message.mifid2DecisionAlgo = reader.string();
          continue;
        }
        case 109: {
          if (tag !== 874) {
            break;
          }

          message.mifid2ExecutionTrader = reader.string();
          continue;
        }
        case 110: {
          if (tag !== 882) {
            break;
          }

          message.mifid2ExecutionAlgo = reader.string();
          continue;
        }
        case 111: {
          if (tag !== 888) {
            break;
          }

          message.dontUseAutoPriceForHedge = reader.bool();
          continue;
        }
        case 112: {
          if (tag !== 896) {
            break;
          }

          message.isOmsContainer = reader.bool();
          continue;
        }
        case 113: {
          if (tag !== 904) {
            break;
          }

          message.discretionaryUpToLimitPrice = reader.bool();
          continue;
        }
        case 114: {
          if (tag !== 914) {
            break;
          }

          message.autoCancelDate = reader.string();
          continue;
        }
        case 115: {
          if (tag !== 922) {
            break;
          }

          message.filledQuantity = reader.string();
          continue;
        }
        case 116: {
          if (tag !== 928) {
            break;
          }

          message.refFuturesConId = reader.int32();
          continue;
        }
        case 117: {
          if (tag !== 936) {
            break;
          }

          message.autoCancelParent = reader.bool();
          continue;
        }
        case 118: {
          if (tag !== 946) {
            break;
          }

          message.shareholder = reader.string();
          continue;
        }
        case 119: {
          if (tag !== 952) {
            break;
          }

          message.imbalanceOnly = reader.bool();
          continue;
        }
        case 120: {
          if (tag !== 960) {
            break;
          }

          message.routeMarketableToBbo = reader.int32();
          continue;
        }
        case 121: {
          if (tag !== 968) {
            break;
          }

          message.parentPermId = longToNumber(reader.int64());
          continue;
        }
        case 122: {
          if (tag !== 976) {
            break;
          }

          message.usePriceMgmtAlgo = reader.int32();
          continue;
        }
        case 123: {
          if (tag !== 984) {
            break;
          }

          message.duration = reader.int32();
          continue;
        }
        case 124: {
          if (tag !== 992) {
            break;
          }

          message.postToAts = reader.int32();
          continue;
        }
        case 125: {
          if (tag !== 1002) {
            break;
          }

          message.advancedErrorOverride = reader.string();
          continue;
        }
        case 126: {
          if (tag !== 1010) {
            break;
          }

          message.manualOrderTime = reader.string();
          continue;
        }
        case 127: {
          if (tag !== 1016) {
            break;
          }

          message.minTradeQty = reader.int32();
          continue;
        }
        case 128: {
          if (tag !== 1024) {
            break;
          }

          message.minCompeteSize = reader.int32();
          continue;
        }
        case 129: {
          if (tag !== 1033) {
            break;
          }

          message.competeAgainstBestOffset = reader.double();
          continue;
        }
        case 130: {
          if (tag !== 1041) {
            break;
          }

          message.midOffsetAtWhole = reader.double();
          continue;
        }
        case 131: {
          if (tag !== 1049) {
            break;
          }

          message.midOffsetAtHalf = reader.double();
          continue;
        }
        case 132: {
          if (tag !== 1058) {
            break;
          }

          message.customerAccount = reader.string();
          continue;
        }
        case 133: {
          if (tag !== 1064) {
            break;
          }

          message.professionalCustomer = reader.bool();
          continue;
        }
        case 134: {
          if (tag !== 1074) {
            break;
          }

          message.bondAccruedInterest = reader.string();
          continue;
        }
        case 135: {
          if (tag !== 1080) {
            break;
          }

          message.includeOvernight = reader.bool();
          continue;
        }
        case 136: {
          if (tag !== 1088) {
            break;
          }

          message.manualOrderIndicator = reader.int32();
          continue;
        }
        case 137: {
          if (tag !== 1098) {
            break;
          }

          message.submitter = reader.string();
          continue;
        }
        case 138: {
          if (tag !== 1104) {
            break;
          }

          message.deactivate = reader.bool();
          continue;
        }
        case 139: {
          if (tag !== 1112) {
            break;
          }

          message.postOnly = reader.bool();
          continue;
        }
        case 140: {
          if (tag !== 1120) {
            break;
          }

          message.allowPreOpen = reader.bool();
          continue;
        }
        case 141: {
          if (tag !== 1128) {
            break;
          }

          message.ignoreOpenAuction = reader.bool();
          continue;
        }
        case 142: {
          if (tag !== 1136) {
            break;
          }

          message.seekPriceImprovement = reader.int32();
          continue;
        }
        case 143: {
          if (tag !== 1144) {
            break;
          }

          message.whatIfType = reader.int32();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): Order {
    return {
      clientId: isSet(object.clientId) ? globalThis.Number(object.clientId) : undefined,
      orderId: isSet(object.orderId) ? globalThis.Number(object.orderId) : undefined,
      permId: isSet(object.permId) ? globalThis.Number(object.permId) : undefined,
      parentId: isSet(object.parentId) ? globalThis.Number(object.parentId) : undefined,
      action: isSet(object.action) ? globalThis.String(object.action) : undefined,
      totalQuantity: isSet(object.totalQuantity) ? globalThis.String(object.totalQuantity) : undefined,
      displaySize: isSet(object.displaySize) ? globalThis.Number(object.displaySize) : undefined,
      orderType: isSet(object.orderType) ? globalThis.String(object.orderType) : undefined,
      lmtPrice: isSet(object.lmtPrice) ? globalThis.Number(object.lmtPrice) : undefined,
      auxPrice: isSet(object.auxPrice) ? globalThis.Number(object.auxPrice) : undefined,
      tif: isSet(object.tif) ? globalThis.String(object.tif) : undefined,
      account: isSet(object.account) ? globalThis.String(object.account) : undefined,
      settlingFirm: isSet(object.settlingFirm) ? globalThis.String(object.settlingFirm) : undefined,
      clearingAccount: isSet(object.clearingAccount) ? globalThis.String(object.clearingAccount) : undefined,
      clearingIntent: isSet(object.clearingIntent) ? globalThis.String(object.clearingIntent) : undefined,
      allOrNone: isSet(object.allOrNone) ? globalThis.Boolean(object.allOrNone) : undefined,
      blockOrder: isSet(object.blockOrder) ? globalThis.Boolean(object.blockOrder) : undefined,
      hidden: isSet(object.hidden) ? globalThis.Boolean(object.hidden) : undefined,
      outsideRth: isSet(object.outsideRth) ? globalThis.Boolean(object.outsideRth) : undefined,
      sweepToFill: isSet(object.sweepToFill) ? globalThis.Boolean(object.sweepToFill) : undefined,
      percentOffset: isSet(object.percentOffset) ? globalThis.Number(object.percentOffset) : undefined,
      trailingPercent: isSet(object.trailingPercent) ? globalThis.Number(object.trailingPercent) : undefined,
      trailStopPrice: isSet(object.trailStopPrice) ? globalThis.Number(object.trailStopPrice) : undefined,
      minQty: isSet(object.minQty) ? globalThis.Number(object.minQty) : undefined,
      goodAfterTime: isSet(object.goodAfterTime) ? globalThis.String(object.goodAfterTime) : undefined,
      goodTillDate: isSet(object.goodTillDate) ? globalThis.String(object.goodTillDate) : undefined,
      ocaGroup: isSet(object.ocaGroup) ? globalThis.String(object.ocaGroup) : undefined,
      orderRef: isSet(object.orderRef) ? globalThis.String(object.orderRef) : undefined,
      rule80A: isSet(object.rule80A) ? globalThis.String(object.rule80A) : undefined,
      ocaType: isSet(object.ocaType) ? globalThis.Number(object.ocaType) : undefined,
      triggerMethod: isSet(object.triggerMethod) ? globalThis.Number(object.triggerMethod) : undefined,
      activeStartTime: isSet(object.activeStartTime) ? globalThis.String(object.activeStartTime) : undefined,
      activeStopTime: isSet(object.activeStopTime) ? globalThis.String(object.activeStopTime) : undefined,
      faGroup: isSet(object.faGroup) ? globalThis.String(object.faGroup) : undefined,
      faMethod: isSet(object.faMethod) ? globalThis.String(object.faMethod) : undefined,
      faPercentage: isSet(object.faPercentage) ? globalThis.String(object.faPercentage) : undefined,
      volatility: isSet(object.volatility) ? globalThis.Number(object.volatility) : undefined,
      volatilityType: isSet(object.volatilityType) ? globalThis.Number(object.volatilityType) : undefined,
      continuousUpdate: isSet(object.continuousUpdate) ? globalThis.Boolean(object.continuousUpdate) : undefined,
      referencePriceType: isSet(object.referencePriceType) ? globalThis.Number(object.referencePriceType) : undefined,
      deltaNeutralOrderType: isSet(object.deltaNeutralOrderType)
        ? globalThis.String(object.deltaNeutralOrderType)
        : undefined,
      deltaNeutralAuxPrice: isSet(object.deltaNeutralAuxPrice)
        ? globalThis.Number(object.deltaNeutralAuxPrice)
        : undefined,
      deltaNeutralConId: isSet(object.deltaNeutralConId) ? globalThis.Number(object.deltaNeutralConId) : undefined,
      deltaNeutralOpenClose: isSet(object.deltaNeutralOpenClose)
        ? globalThis.String(object.deltaNeutralOpenClose)
        : undefined,
      deltaNeutralShortSale: isSet(object.deltaNeutralShortSale)
        ? globalThis.Boolean(object.deltaNeutralShortSale)
        : undefined,
      deltaNeutralShortSaleSlot: isSet(object.deltaNeutralShortSaleSlot)
        ? globalThis.Number(object.deltaNeutralShortSaleSlot)
        : undefined,
      deltaNeutralDesignatedLocation: isSet(object.deltaNeutralDesignatedLocation)
        ? globalThis.String(object.deltaNeutralDesignatedLocation)
        : undefined,
      scaleInitLevelSize: isSet(object.scaleInitLevelSize) ? globalThis.Number(object.scaleInitLevelSize) : undefined,
      scaleSubsLevelSize: isSet(object.scaleSubsLevelSize) ? globalThis.Number(object.scaleSubsLevelSize) : undefined,
      scalePriceIncrement: isSet(object.scalePriceIncrement)
        ? globalThis.Number(object.scalePriceIncrement)
        : undefined,
      scalePriceAdjustValue: isSet(object.scalePriceAdjustValue)
        ? globalThis.Number(object.scalePriceAdjustValue)
        : undefined,
      scalePriceAdjustInterval: isSet(object.scalePriceAdjustInterval)
        ? globalThis.Number(object.scalePriceAdjustInterval)
        : undefined,
      scaleProfitOffset: isSet(object.scaleProfitOffset) ? globalThis.Number(object.scaleProfitOffset) : undefined,
      scaleAutoReset: isSet(object.scaleAutoReset) ? globalThis.Boolean(object.scaleAutoReset) : undefined,
      scaleInitPosition: isSet(object.scaleInitPosition) ? globalThis.Number(object.scaleInitPosition) : undefined,
      scaleInitFillQty: isSet(object.scaleInitFillQty) ? globalThis.Number(object.scaleInitFillQty) : undefined,
      scaleRandomPercent: isSet(object.scaleRandomPercent) ? globalThis.Boolean(object.scaleRandomPercent) : undefined,
      scaleTable: isSet(object.scaleTable) ? globalThis.String(object.scaleTable) : undefined,
      hedgeType: isSet(object.hedgeType) ? globalThis.String(object.hedgeType) : undefined,
      hedgeParam: isSet(object.hedgeParam) ? globalThis.String(object.hedgeParam) : undefined,
      algoStrategy: isSet(object.algoStrategy) ? globalThis.String(object.algoStrategy) : undefined,
      algoParams: isObject(object.algoParams)
        ? (globalThis.Object.entries(object.algoParams) as [string, any][]).reduce(
          (acc: { [key: string]: string }, [key, value]: [string, any]) => {
            acc[key] = globalThis.String(value);
            return acc;
          },
          {},
        )
        : {},
      algoId: isSet(object.algoId) ? globalThis.String(object.algoId) : undefined,
      smartComboRoutingParams: isObject(object.smartComboRoutingParams)
        ? (globalThis.Object.entries(object.smartComboRoutingParams) as [string, any][]).reduce(
          (acc: { [key: string]: string }, [key, value]: [string, any]) => {
            acc[key] = globalThis.String(value);
            return acc;
          },
          {},
        )
        : {},
      whatIf: isSet(object.whatIf) ? globalThis.Boolean(object.whatIf) : undefined,
      transmit: isSet(object.transmit) ? globalThis.Boolean(object.transmit) : undefined,
      overridePercentageConstraints: isSet(object.overridePercentageConstraints)
        ? globalThis.Boolean(object.overridePercentageConstraints)
        : undefined,
      openClose: isSet(object.openClose) ? globalThis.String(object.openClose) : undefined,
      origin: isSet(object.origin) ? globalThis.Number(object.origin) : undefined,
      shortSaleSlot: isSet(object.shortSaleSlot) ? globalThis.Number(object.shortSaleSlot) : undefined,
      designatedLocation: isSet(object.designatedLocation) ? globalThis.String(object.designatedLocation) : undefined,
      exemptCode: isSet(object.exemptCode) ? globalThis.Number(object.exemptCode) : undefined,
      deltaNeutralSettlingFirm: isSet(object.deltaNeutralSettlingFirm)
        ? globalThis.String(object.deltaNeutralSettlingFirm)
        : undefined,
      deltaNeutralClearingAccount: isSet(object.deltaNeutralClearingAccount)
        ? globalThis.String(object.deltaNeutralClearingAccount)
        : undefined,
      deltaNeutralClearingIntent: isSet(object.deltaNeutralClearingIntent)
        ? globalThis.String(object.deltaNeutralClearingIntent)
        : undefined,
      discretionaryAmt: isSet(object.discretionaryAmt) ? globalThis.Number(object.discretionaryAmt) : undefined,
      optOutSmartRouting: isSet(object.optOutSmartRouting) ? globalThis.Boolean(object.optOutSmartRouting) : undefined,
      startingPrice: isSet(object.startingPrice) ? globalThis.Number(object.startingPrice) : undefined,
      stockRefPrice: isSet(object.stockRefPrice) ? globalThis.Number(object.stockRefPrice) : undefined,
      delta: isSet(object.delta) ? globalThis.Number(object.delta) : undefined,
      stockRangeLower: isSet(object.stockRangeLower) ? globalThis.Number(object.stockRangeLower) : undefined,
      stockRangeUpper: isSet(object.stockRangeUpper) ? globalThis.Number(object.stockRangeUpper) : undefined,
      notHeld: isSet(object.notHeld) ? globalThis.Boolean(object.notHeld) : undefined,
      orderMiscOptions: isObject(object.orderMiscOptions)
        ? (globalThis.Object.entries(object.orderMiscOptions) as [string, any][]).reduce(
          (acc: { [key: string]: string }, [key, value]: [string, any]) => {
            acc[key] = globalThis.String(value);
            return acc;
          },
          {},
        )
        : {},
      solicited: isSet(object.solicited) ? globalThis.Boolean(object.solicited) : undefined,
      randomizeSize: isSet(object.randomizeSize) ? globalThis.Boolean(object.randomizeSize) : undefined,
      randomizePrice: isSet(object.randomizePrice) ? globalThis.Boolean(object.randomizePrice) : undefined,
      referenceContractId: isSet(object.referenceContractId)
        ? globalThis.Number(object.referenceContractId)
        : undefined,
      peggedChangeAmount: isSet(object.peggedChangeAmount) ? globalThis.Number(object.peggedChangeAmount) : undefined,
      isPeggedChangeAmountDecrease: isSet(object.isPeggedChangeAmountDecrease)
        ? globalThis.Boolean(object.isPeggedChangeAmountDecrease)
        : undefined,
      referenceChangeAmount: isSet(object.referenceChangeAmount)
        ? globalThis.Number(object.referenceChangeAmount)
        : undefined,
      referenceExchangeId: isSet(object.referenceExchangeId)
        ? globalThis.String(object.referenceExchangeId)
        : undefined,
      adjustedOrderType: isSet(object.adjustedOrderType) ? globalThis.String(object.adjustedOrderType) : undefined,
      triggerPrice: isSet(object.triggerPrice) ? globalThis.Number(object.triggerPrice) : undefined,
      adjustedStopPrice: isSet(object.adjustedStopPrice) ? globalThis.Number(object.adjustedStopPrice) : undefined,
      adjustedStopLimitPrice: isSet(object.adjustedStopLimitPrice)
        ? globalThis.Number(object.adjustedStopLimitPrice)
        : undefined,
      adjustedTrailingAmount: isSet(object.adjustedTrailingAmount)
        ? globalThis.Number(object.adjustedTrailingAmount)
        : undefined,
      adjustableTrailingUnit: isSet(object.adjustableTrailingUnit)
        ? globalThis.Number(object.adjustableTrailingUnit)
        : undefined,
      lmtPriceOffset: isSet(object.lmtPriceOffset) ? globalThis.Number(object.lmtPriceOffset) : undefined,
      conditions: globalThis.Array.isArray(object?.conditions)
        ? object.conditions.map((e: any) => OrderCondition.fromJSON(e))
        : [],
      conditionsCancelOrder: isSet(object.conditionsCancelOrder)
        ? globalThis.Boolean(object.conditionsCancelOrder)
        : undefined,
      conditionsIgnoreRth: isSet(object.conditionsIgnoreRth)
        ? globalThis.Boolean(object.conditionsIgnoreRth)
        : undefined,
      modelCode: isSet(object.modelCode) ? globalThis.String(object.modelCode) : undefined,
      extOperator: isSet(object.extOperator) ? globalThis.String(object.extOperator) : undefined,
      softDollarTier: isSet(object.softDollarTier) ? SoftDollarTier.fromJSON(object.softDollarTier) : undefined,
      cashQty: isSet(object.cashQty) ? globalThis.Number(object.cashQty) : undefined,
      mifid2DecisionMaker: isSet(object.mifid2DecisionMaker)
        ? globalThis.String(object.mifid2DecisionMaker)
        : undefined,
      mifid2DecisionAlgo: isSet(object.mifid2DecisionAlgo) ? globalThis.String(object.mifid2DecisionAlgo) : undefined,
      mifid2ExecutionTrader: isSet(object.mifid2ExecutionTrader)
        ? globalThis.String(object.mifid2ExecutionTrader)
        : undefined,
      mifid2ExecutionAlgo: isSet(object.mifid2ExecutionAlgo)
        ? globalThis.String(object.mifid2ExecutionAlgo)
        : undefined,
      dontUseAutoPriceForHedge: isSet(object.dontUseAutoPriceForHedge)
        ? globalThis.Boolean(object.dontUseAutoPriceForHedge)
        : undefined,
      isOmsContainer: isSet(object.isOmsContainer) ? globalThis.Boolean(object.isOmsContainer) : undefined,
      discretionaryUpToLimitPrice: isSet(object.discretionaryUpToLimitPrice)
        ? globalThis.Boolean(object.discretionaryUpToLimitPrice)
        : undefined,
      autoCancelDate: isSet(object.autoCancelDate) ? globalThis.String(object.autoCancelDate) : undefined,
      filledQuantity: isSet(object.filledQuantity) ? globalThis.String(object.filledQuantity) : undefined,
      refFuturesConId: isSet(object.refFuturesConId) ? globalThis.Number(object.refFuturesConId) : undefined,
      autoCancelParent: isSet(object.autoCancelParent) ? globalThis.Boolean(object.autoCancelParent) : undefined,
      shareholder: isSet(object.shareholder) ? globalThis.String(object.shareholder) : undefined,
      imbalanceOnly: isSet(object.imbalanceOnly) ? globalThis.Boolean(object.imbalanceOnly) : undefined,
      routeMarketableToBbo: isSet(object.routeMarketableToBbo)
        ? globalThis.Number(object.routeMarketableToBbo)
        : undefined,
      parentPermId: isSet(object.parentPermId) ? globalThis.Number(object.parentPermId) : undefined,
      usePriceMgmtAlgo: isSet(object.usePriceMgmtAlgo) ? globalThis.Number(object.usePriceMgmtAlgo) : undefined,
      duration: isSet(object.duration) ? globalThis.Number(object.duration) : undefined,
      postToAts: isSet(object.postToAts) ? globalThis.Number(object.postToAts) : undefined,
      advancedErrorOverride: isSet(object.advancedErrorOverride)
        ? globalThis.String(object.advancedErrorOverride)
        : undefined,
      manualOrderTime: isSet(object.manualOrderTime) ? globalThis.String(object.manualOrderTime) : undefined,
      minTradeQty: isSet(object.minTradeQty) ? globalThis.Number(object.minTradeQty) : undefined,
      minCompeteSize: isSet(object.minCompeteSize) ? globalThis.Number(object.minCompeteSize) : undefined,
      competeAgainstBestOffset: isSet(object.competeAgainstBestOffset)
        ? globalThis.Number(object.competeAgainstBestOffset)
        : undefined,
      midOffsetAtWhole: isSet(object.midOffsetAtWhole) ? globalThis.Number(object.midOffsetAtWhole) : undefined,
      midOffsetAtHalf: isSet(object.midOffsetAtHalf) ? globalThis.Number(object.midOffsetAtHalf) : undefined,
      customerAccount: isSet(object.customerAccount) ? globalThis.String(object.customerAccount) : undefined,
      professionalCustomer: isSet(object.professionalCustomer)
        ? globalThis.Boolean(object.professionalCustomer)
        : undefined,
      bondAccruedInterest: isSet(object.bondAccruedInterest)
        ? globalThis.String(object.bondAccruedInterest)
        : undefined,
      includeOvernight: isSet(object.includeOvernight) ? globalThis.Boolean(object.includeOvernight) : undefined,
      manualOrderIndicator: isSet(object.manualOrderIndicator)
        ? globalThis.Number(object.manualOrderIndicator)
        : undefined,
      submitter: isSet(object.submitter) ? globalThis.String(object.submitter) : undefined,
      deactivate: isSet(object.deactivate) ? globalThis.Boolean(object.deactivate) : undefined,
      postOnly: isSet(object.postOnly) ? globalThis.Boolean(object.postOnly) : undefined,
      allowPreOpen: isSet(object.allowPreOpen) ? globalThis.Boolean(object.allowPreOpen) : undefined,
      ignoreOpenAuction: isSet(object.ignoreOpenAuction) ? globalThis.Boolean(object.ignoreOpenAuction) : undefined,
      seekPriceImprovement: isSet(object.seekPriceImprovement)
        ? globalThis.Number(object.seekPriceImprovement)
        : undefined,
      whatIfType: isSet(object.whatIfType) ? globalThis.Number(object.whatIfType) : undefined,
    };
  },

  toJSON(message: Order): unknown {
    const obj: any = {};
    if (message.clientId !== undefined) {
      obj.clientId = Math.round(message.clientId);
    }
    if (message.orderId !== undefined) {
      obj.orderId = Math.round(message.orderId);
    }
    if (message.permId !== undefined) {
      obj.permId = Math.round(message.permId);
    }
    if (message.parentId !== undefined) {
      obj.parentId = Math.round(message.parentId);
    }
    if (message.action !== undefined) {
      obj.action = message.action;
    }
    if (message.totalQuantity !== undefined) {
      obj.totalQuantity = message.totalQuantity;
    }
    if (message.displaySize !== undefined) {
      obj.displaySize = Math.round(message.displaySize);
    }
    if (message.orderType !== undefined) {
      obj.orderType = message.orderType;
    }
    if (message.lmtPrice !== undefined) {
      obj.lmtPrice = message.lmtPrice;
    }
    if (message.auxPrice !== undefined) {
      obj.auxPrice = message.auxPrice;
    }
    if (message.tif !== undefined) {
      obj.tif = message.tif;
    }
    if (message.account !== undefined) {
      obj.account = message.account;
    }
    if (message.settlingFirm !== undefined) {
      obj.settlingFirm = message.settlingFirm;
    }
    if (message.clearingAccount !== undefined) {
      obj.clearingAccount = message.clearingAccount;
    }
    if (message.clearingIntent !== undefined) {
      obj.clearingIntent = message.clearingIntent;
    }
    if (message.allOrNone !== undefined) {
      obj.allOrNone = message.allOrNone;
    }
    if (message.blockOrder !== undefined) {
      obj.blockOrder = message.blockOrder;
    }
    if (message.hidden !== undefined) {
      obj.hidden = message.hidden;
    }
    if (message.outsideRth !== undefined) {
      obj.outsideRth = message.outsideRth;
    }
    if (message.sweepToFill !== undefined) {
      obj.sweepToFill = message.sweepToFill;
    }
    if (message.percentOffset !== undefined) {
      obj.percentOffset = message.percentOffset;
    }
    if (message.trailingPercent !== undefined) {
      obj.trailingPercent = message.trailingPercent;
    }
    if (message.trailStopPrice !== undefined) {
      obj.trailStopPrice = message.trailStopPrice;
    }
    if (message.minQty !== undefined) {
      obj.minQty = Math.round(message.minQty);
    }
    if (message.goodAfterTime !== undefined) {
      obj.goodAfterTime = message.goodAfterTime;
    }
    if (message.goodTillDate !== undefined) {
      obj.goodTillDate = message.goodTillDate;
    }
    if (message.ocaGroup !== undefined) {
      obj.ocaGroup = message.ocaGroup;
    }
    if (message.orderRef !== undefined) {
      obj.orderRef = message.orderRef;
    }
    if (message.rule80A !== undefined) {
      obj.rule80A = message.rule80A;
    }
    if (message.ocaType !== undefined) {
      obj.ocaType = Math.round(message.ocaType);
    }
    if (message.triggerMethod !== undefined) {
      obj.triggerMethod = Math.round(message.triggerMethod);
    }
    if (message.activeStartTime !== undefined) {
      obj.activeStartTime = message.activeStartTime;
    }
    if (message.activeStopTime !== undefined) {
      obj.activeStopTime = message.activeStopTime;
    }
    if (message.faGroup !== undefined) {
      obj.faGroup = message.faGroup;
    }
    if (message.faMethod !== undefined) {
      obj.faMethod = message.faMethod;
    }
    if (message.faPercentage !== undefined) {
      obj.faPercentage = message.faPercentage;
    }
    if (message.volatility !== undefined) {
      obj.volatility = message.volatility;
    }
    if (message.volatilityType !== undefined) {
      obj.volatilityType = Math.round(message.volatilityType);
    }
    if (message.continuousUpdate !== undefined) {
      obj.continuousUpdate = message.continuousUpdate;
    }
    if (message.referencePriceType !== undefined) {
      obj.referencePriceType = Math.round(message.referencePriceType);
    }
    if (message.deltaNeutralOrderType !== undefined) {
      obj.deltaNeutralOrderType = message.deltaNeutralOrderType;
    }
    if (message.deltaNeutralAuxPrice !== undefined) {
      obj.deltaNeutralAuxPrice = message.deltaNeutralAuxPrice;
    }
    if (message.deltaNeutralConId !== undefined) {
      obj.deltaNeutralConId = Math.round(message.deltaNeutralConId);
    }
    if (message.deltaNeutralOpenClose !== undefined) {
      obj.deltaNeutralOpenClose = message.deltaNeutralOpenClose;
    }
    if (message.deltaNeutralShortSale !== undefined) {
      obj.deltaNeutralShortSale = message.deltaNeutralShortSale;
    }
    if (message.deltaNeutralShortSaleSlot !== undefined) {
      obj.deltaNeutralShortSaleSlot = Math.round(message.deltaNeutralShortSaleSlot);
    }
    if (message.deltaNeutralDesignatedLocation !== undefined) {
      obj.deltaNeutralDesignatedLocation = message.deltaNeutralDesignatedLocation;
    }
    if (message.scaleInitLevelSize !== undefined) {
      obj.scaleInitLevelSize = Math.round(message.scaleInitLevelSize);
    }
    if (message.scaleSubsLevelSize !== undefined) {
      obj.scaleSubsLevelSize = Math.round(message.scaleSubsLevelSize);
    }
    if (message.scalePriceIncrement !== undefined) {
      obj.scalePriceIncrement = message.scalePriceIncrement;
    }
    if (message.scalePriceAdjustValue !== undefined) {
      obj.scalePriceAdjustValue = message.scalePriceAdjustValue;
    }
    if (message.scalePriceAdjustInterval !== undefined) {
      obj.scalePriceAdjustInterval = Math.round(message.scalePriceAdjustInterval);
    }
    if (message.scaleProfitOffset !== undefined) {
      obj.scaleProfitOffset = message.scaleProfitOffset;
    }
    if (message.scaleAutoReset !== undefined) {
      obj.scaleAutoReset = message.scaleAutoReset;
    }
    if (message.scaleInitPosition !== undefined) {
      obj.scaleInitPosition = Math.round(message.scaleInitPosition);
    }
    if (message.scaleInitFillQty !== undefined) {
      obj.scaleInitFillQty = Math.round(message.scaleInitFillQty);
    }
    if (message.scaleRandomPercent !== undefined) {
      obj.scaleRandomPercent = message.scaleRandomPercent;
    }
    if (message.scaleTable !== undefined) {
      obj.scaleTable = message.scaleTable;
    }
    if (message.hedgeType !== undefined) {
      obj.hedgeType = message.hedgeType;
    }
    if (message.hedgeParam !== undefined) {
      obj.hedgeParam = message.hedgeParam;
    }
    if (message.algoStrategy !== undefined) {
      obj.algoStrategy = message.algoStrategy;
    }
    if (message.algoParams) {
      const entries = globalThis.Object.entries(message.algoParams) as [string, string][];
      if (entries.length > 0) {
        obj.algoParams = {};
        entries.forEach(([k, v]) => {
          obj.algoParams[k] = v;
        });
      }
    }
    if (message.algoId !== undefined) {
      obj.algoId = message.algoId;
    }
    if (message.smartComboRoutingParams) {
      const entries = globalThis.Object.entries(message.smartComboRoutingParams) as [string, string][];
      if (entries.length > 0) {
        obj.smartComboRoutingParams = {};
        entries.forEach(([k, v]) => {
          obj.smartComboRoutingParams[k] = v;
        });
      }
    }
    if (message.whatIf !== undefined) {
      obj.whatIf = message.whatIf;
    }
    if (message.transmit !== undefined) {
      obj.transmit = message.transmit;
    }
    if (message.overridePercentageConstraints !== undefined) {
      obj.overridePercentageConstraints = message.overridePercentageConstraints;
    }
    if (message.openClose !== undefined) {
      obj.openClose = message.openClose;
    }
    if (message.origin !== undefined) {
      obj.origin = Math.round(message.origin);
    }
    if (message.shortSaleSlot !== undefined) {
      obj.shortSaleSlot = Math.round(message.shortSaleSlot);
    }
    if (message.designatedLocation !== undefined) {
      obj.designatedLocation = message.designatedLocation;
    }
    if (message.exemptCode !== undefined) {
      obj.exemptCode = Math.round(message.exemptCode);
    }
    if (message.deltaNeutralSettlingFirm !== undefined) {
      obj.deltaNeutralSettlingFirm = message.deltaNeutralSettlingFirm;
    }
    if (message.deltaNeutralClearingAccount !== undefined) {
      obj.deltaNeutralClearingAccount = message.deltaNeutralClearingAccount;
    }
    if (message.deltaNeutralClearingIntent !== undefined) {
      obj.deltaNeutralClearingIntent = message.deltaNeutralClearingIntent;
    }
    if (message.discretionaryAmt !== undefined) {
      obj.discretionaryAmt = message.discretionaryAmt;
    }
    if (message.optOutSmartRouting !== undefined) {
      obj.optOutSmartRouting = message.optOutSmartRouting;
    }
    if (message.startingPrice !== undefined) {
      obj.startingPrice = message.startingPrice;
    }
    if (message.stockRefPrice !== undefined) {
      obj.stockRefPrice = message.stockRefPrice;
    }
    if (message.delta !== undefined) {
      obj.delta = message.delta;
    }
    if (message.stockRangeLower !== undefined) {
      obj.stockRangeLower = message.stockRangeLower;
    }
    if (message.stockRangeUpper !== undefined) {
      obj.stockRangeUpper = message.stockRangeUpper;
    }
    if (message.notHeld !== undefined) {
      obj.notHeld = message.notHeld;
    }
    if (message.orderMiscOptions) {
      const entries = globalThis.Object.entries(message.orderMiscOptions) as [string, string][];
      if (entries.length > 0) {
        obj.orderMiscOptions = {};
        entries.forEach(([k, v]) => {
          obj.orderMiscOptions[k] = v;
        });
      }
    }
    if (message.solicited !== undefined) {
      obj.solicited = message.solicited;
    }
    if (message.randomizeSize !== undefined) {
      obj.randomizeSize = message.randomizeSize;
    }
    if (message.randomizePrice !== undefined) {
      obj.randomizePrice = message.randomizePrice;
    }
    if (message.referenceContractId !== undefined) {
      obj.referenceContractId = Math.round(message.referenceContractId);
    }
    if (message.peggedChangeAmount !== undefined) {
      obj.peggedChangeAmount = message.peggedChangeAmount;
    }
    if (message.isPeggedChangeAmountDecrease !== undefined) {
      obj.isPeggedChangeAmountDecrease = message.isPeggedChangeAmountDecrease;
    }
    if (message.referenceChangeAmount !== undefined) {
      obj.referenceChangeAmount = message.referenceChangeAmount;
    }
    if (message.referenceExchangeId !== undefined) {
      obj.referenceExchangeId = message.referenceExchangeId;
    }
    if (message.adjustedOrderType !== undefined) {
      obj.adjustedOrderType = message.adjustedOrderType;
    }
    if (message.triggerPrice !== undefined) {
      obj.triggerPrice = message.triggerPrice;
    }
    if (message.adjustedStopPrice !== undefined) {
      obj.adjustedStopPrice = message.adjustedStopPrice;
    }
    if (message.adjustedStopLimitPrice !== undefined) {
      obj.adjustedStopLimitPrice = message.adjustedStopLimitPrice;
    }
    if (message.adjustedTrailingAmount !== undefined) {
      obj.adjustedTrailingAmount = message.adjustedTrailingAmount;
    }
    if (message.adjustableTrailingUnit !== undefined) {
      obj.adjustableTrailingUnit = Math.round(message.adjustableTrailingUnit);
    }
    if (message.lmtPriceOffset !== undefined) {
      obj.lmtPriceOffset = message.lmtPriceOffset;
    }
    if (message.conditions?.length) {
      obj.conditions = message.conditions.map((e) => OrderCondition.toJSON(e));
    }
    if (message.conditionsCancelOrder !== undefined) {
      obj.conditionsCancelOrder = message.conditionsCancelOrder;
    }
    if (message.conditionsIgnoreRth !== undefined) {
      obj.conditionsIgnoreRth = message.conditionsIgnoreRth;
    }
    if (message.modelCode !== undefined) {
      obj.modelCode = message.modelCode;
    }
    if (message.extOperator !== undefined) {
      obj.extOperator = message.extOperator;
    }
    if (message.softDollarTier !== undefined) {
      obj.softDollarTier = SoftDollarTier.toJSON(message.softDollarTier);
    }
    if (message.cashQty !== undefined) {
      obj.cashQty = message.cashQty;
    }
    if (message.mifid2DecisionMaker !== undefined) {
      obj.mifid2DecisionMaker = message.mifid2DecisionMaker;
    }
    if (message.mifid2DecisionAlgo !== undefined) {
      obj.mifid2DecisionAlgo = message.mifid2DecisionAlgo;
    }
    if (message.mifid2ExecutionTrader !== undefined) {
      obj.mifid2ExecutionTrader = message.mifid2ExecutionTrader;
    }
    if (message.mifid2ExecutionAlgo !== undefined) {
      obj.mifid2ExecutionAlgo = message.mifid2ExecutionAlgo;
    }
    if (message.dontUseAutoPriceForHedge !== undefined) {
      obj.dontUseAutoPriceForHedge = message.dontUseAutoPriceForHedge;
    }
    if (message.isOmsContainer !== undefined) {
      obj.isOmsContainer = message.isOmsContainer;
    }
    if (message.discretionaryUpToLimitPrice !== undefined) {
      obj.discretionaryUpToLimitPrice = message.discretionaryUpToLimitPrice;
    }
    if (message.autoCancelDate !== undefined) {
      obj.autoCancelDate = message.autoCancelDate;
    }
    if (message.filledQuantity !== undefined) {
      obj.filledQuantity = message.filledQuantity;
    }
    if (message.refFuturesConId !== undefined) {
      obj.refFuturesConId = Math.round(message.refFuturesConId);
    }
    if (message.autoCancelParent !== undefined) {
      obj.autoCancelParent = message.autoCancelParent;
    }
    if (message.shareholder !== undefined) {
      obj.shareholder = message.shareholder;
    }
    if (message.imbalanceOnly !== undefined) {
      obj.imbalanceOnly = message.imbalanceOnly;
    }
    if (message.routeMarketableToBbo !== undefined) {
      obj.routeMarketableToBbo = Math.round(message.routeMarketableToBbo);
    }
    if (message.parentPermId !== undefined) {
      obj.parentPermId = Math.round(message.parentPermId);
    }
    if (message.usePriceMgmtAlgo !== undefined) {
      obj.usePriceMgmtAlgo = Math.round(message.usePriceMgmtAlgo);
    }
    if (message.duration !== undefined) {
      obj.duration = Math.round(message.duration);
    }
    if (message.postToAts !== undefined) {
      obj.postToAts = Math.round(message.postToAts);
    }
    if (message.advancedErrorOverride !== undefined) {
      obj.advancedErrorOverride = message.advancedErrorOverride;
    }
    if (message.manualOrderTime !== undefined) {
      obj.manualOrderTime = message.manualOrderTime;
    }
    if (message.minTradeQty !== undefined) {
      obj.minTradeQty = Math.round(message.minTradeQty);
    }
    if (message.minCompeteSize !== undefined) {
      obj.minCompeteSize = Math.round(message.minCompeteSize);
    }
    if (message.competeAgainstBestOffset !== undefined) {
      obj.competeAgainstBestOffset = message.competeAgainstBestOffset;
    }
    if (message.midOffsetAtWhole !== undefined) {
      obj.midOffsetAtWhole = message.midOffsetAtWhole;
    }
    if (message.midOffsetAtHalf !== undefined) {
      obj.midOffsetAtHalf = message.midOffsetAtHalf;
    }
    if (message.customerAccount !== undefined) {
      obj.customerAccount = message.customerAccount;
    }
    if (message.professionalCustomer !== undefined) {
      obj.professionalCustomer = message.professionalCustomer;
    }
    if (message.bondAccruedInterest !== undefined) {
      obj.bondAccruedInterest = message.bondAccruedInterest;
    }
    if (message.includeOvernight !== undefined) {
      obj.includeOvernight = message.includeOvernight;
    }
    if (message.manualOrderIndicator !== undefined) {
      obj.manualOrderIndicator = Math.round(message.manualOrderIndicator);
    }
    if (message.submitter !== undefined) {
      obj.submitter = message.submitter;
    }
    if (message.deactivate !== undefined) {
      obj.deactivate = message.deactivate;
    }
    if (message.postOnly !== undefined) {
      obj.postOnly = message.postOnly;
    }
    if (message.allowPreOpen !== undefined) {
      obj.allowPreOpen = message.allowPreOpen;
    }
    if (message.ignoreOpenAuction !== undefined) {
      obj.ignoreOpenAuction = message.ignoreOpenAuction;
    }
    if (message.seekPriceImprovement !== undefined) {
      obj.seekPriceImprovement = Math.round(message.seekPriceImprovement);
    }
    if (message.whatIfType !== undefined) {
      obj.whatIfType = Math.round(message.whatIfType);
    }
    return obj;
  },

  create(base?: DeepPartial<Order>): Order {
    return Order.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<Order>): Order {
    const message = createBaseOrder();
    message.clientId = object.clientId ?? undefined;
    message.orderId = object.orderId ?? undefined;
    message.permId = object.permId ?? undefined;
    message.parentId = object.parentId ?? undefined;
    message.action = object.action ?? undefined;
    message.totalQuantity = object.totalQuantity ?? undefined;
    message.displaySize = object.displaySize ?? undefined;
    message.orderType = object.orderType ?? undefined;
    message.lmtPrice = object.lmtPrice ?? undefined;
    message.auxPrice = object.auxPrice ?? undefined;
    message.tif = object.tif ?? undefined;
    message.account = object.account ?? undefined;
    message.settlingFirm = object.settlingFirm ?? undefined;
    message.clearingAccount = object.clearingAccount ?? undefined;
    message.clearingIntent = object.clearingIntent ?? undefined;
    message.allOrNone = object.allOrNone ?? undefined;
    message.blockOrder = object.blockOrder ?? undefined;
    message.hidden = object.hidden ?? undefined;
    message.outsideRth = object.outsideRth ?? undefined;
    message.sweepToFill = object.sweepToFill ?? undefined;
    message.percentOffset = object.percentOffset ?? undefined;
    message.trailingPercent = object.trailingPercent ?? undefined;
    message.trailStopPrice = object.trailStopPrice ?? undefined;
    message.minQty = object.minQty ?? undefined;
    message.goodAfterTime = object.goodAfterTime ?? undefined;
    message.goodTillDate = object.goodTillDate ?? undefined;
    message.ocaGroup = object.ocaGroup ?? undefined;
    message.orderRef = object.orderRef ?? undefined;
    message.rule80A = object.rule80A ?? undefined;
    message.ocaType = object.ocaType ?? undefined;
    message.triggerMethod = object.triggerMethod ?? undefined;
    message.activeStartTime = object.activeStartTime ?? undefined;
    message.activeStopTime = object.activeStopTime ?? undefined;
    message.faGroup = object.faGroup ?? undefined;
    message.faMethod = object.faMethod ?? undefined;
    message.faPercentage = object.faPercentage ?? undefined;
    message.volatility = object.volatility ?? undefined;
    message.volatilityType = object.volatilityType ?? undefined;
    message.continuousUpdate = object.continuousUpdate ?? undefined;
    message.referencePriceType = object.referencePriceType ?? undefined;
    message.deltaNeutralOrderType = object.deltaNeutralOrderType ?? undefined;
    message.deltaNeutralAuxPrice = object.deltaNeutralAuxPrice ?? undefined;
    message.deltaNeutralConId = object.deltaNeutralConId ?? undefined;
    message.deltaNeutralOpenClose = object.deltaNeutralOpenClose ?? undefined;
    message.deltaNeutralShortSale = object.deltaNeutralShortSale ?? undefined;
    message.deltaNeutralShortSaleSlot = object.deltaNeutralShortSaleSlot ?? undefined;
    message.deltaNeutralDesignatedLocation = object.deltaNeutralDesignatedLocation ?? undefined;
    message.scaleInitLevelSize = object.scaleInitLevelSize ?? undefined;
    message.scaleSubsLevelSize = object.scaleSubsLevelSize ?? undefined;
    message.scalePriceIncrement = object.scalePriceIncrement ?? undefined;
    message.scalePriceAdjustValue = object.scalePriceAdjustValue ?? undefined;
    message.scalePriceAdjustInterval = object.scalePriceAdjustInterval ?? undefined;
    message.scaleProfitOffset = object.scaleProfitOffset ?? undefined;
    message.scaleAutoReset = object.scaleAutoReset ?? undefined;
    message.scaleInitPosition = object.scaleInitPosition ?? undefined;
    message.scaleInitFillQty = object.scaleInitFillQty ?? undefined;
    message.scaleRandomPercent = object.scaleRandomPercent ?? undefined;
    message.scaleTable = object.scaleTable ?? undefined;
    message.hedgeType = object.hedgeType ?? undefined;
    message.hedgeParam = object.hedgeParam ?? undefined;
    message.algoStrategy = object.algoStrategy ?? undefined;
    message.algoParams = (globalThis.Object.entries(object.algoParams ?? {}) as [string, string][]).reduce(
      (acc: { [key: string]: string }, [key, value]: [string, string]) => {
        if (value !== undefined) {
          acc[key] = globalThis.String(value);
        }
        return acc;
      },
      {},
    );
    message.algoId = object.algoId ?? undefined;
    message.smartComboRoutingParams =
      (globalThis.Object.entries(object.smartComboRoutingParams ?? {}) as [string, string][]).reduce(
        (acc: { [key: string]: string }, [key, value]: [string, string]) => {
          if (value !== undefined) {
            acc[key] = globalThis.String(value);
          }
          return acc;
        },
        {},
      );
    message.whatIf = object.whatIf ?? undefined;
    message.transmit = object.transmit ?? undefined;
    message.overridePercentageConstraints = object.overridePercentageConstraints ?? undefined;
    message.openClose = object.openClose ?? undefined;
    message.origin = object.origin ?? undefined;
    message.shortSaleSlot = object.shortSaleSlot ?? undefined;
    message.designatedLocation = object.designatedLocation ?? undefined;
    message.exemptCode = object.exemptCode ?? undefined;
    message.deltaNeutralSettlingFirm = object.deltaNeutralSettlingFirm ?? undefined;
    message.deltaNeutralClearingAccount = object.deltaNeutralClearingAccount ?? undefined;
    message.deltaNeutralClearingIntent = object.deltaNeutralClearingIntent ?? undefined;
    message.discretionaryAmt = object.discretionaryAmt ?? undefined;
    message.optOutSmartRouting = object.optOutSmartRouting ?? undefined;
    message.startingPrice = object.startingPrice ?? undefined;
    message.stockRefPrice = object.stockRefPrice ?? undefined;
    message.delta = object.delta ?? undefined;
    message.stockRangeLower = object.stockRangeLower ?? undefined;
    message.stockRangeUpper = object.stockRangeUpper ?? undefined;
    message.notHeld = object.notHeld ?? undefined;
    message.orderMiscOptions = (globalThis.Object.entries(object.orderMiscOptions ?? {}) as [string, string][]).reduce(
      (acc: { [key: string]: string }, [key, value]: [string, string]) => {
        if (value !== undefined) {
          acc[key] = globalThis.String(value);
        }
        return acc;
      },
      {},
    );
    message.solicited = object.solicited ?? undefined;
    message.randomizeSize = object.randomizeSize ?? undefined;
    message.randomizePrice = object.randomizePrice ?? undefined;
    message.referenceContractId = object.referenceContractId ?? undefined;
    message.peggedChangeAmount = object.peggedChangeAmount ?? undefined;
    message.isPeggedChangeAmountDecrease = object.isPeggedChangeAmountDecrease ?? undefined;
    message.referenceChangeAmount = object.referenceChangeAmount ?? undefined;
    message.referenceExchangeId = object.referenceExchangeId ?? undefined;
    message.adjustedOrderType = object.adjustedOrderType ?? undefined;
    message.triggerPrice = object.triggerPrice ?? undefined;
    message.adjustedStopPrice = object.adjustedStopPrice ?? undefined;
    message.adjustedStopLimitPrice = object.adjustedStopLimitPrice ?? undefined;
    message.adjustedTrailingAmount = object.adjustedTrailingAmount ?? undefined;
    message.adjustableTrailingUnit = object.adjustableTrailingUnit ?? undefined;
    message.lmtPriceOffset = object.lmtPriceOffset ?? undefined;
    message.conditions = object.conditions?.map((e) => OrderCondition.fromPartial(e)) || [];
    message.conditionsCancelOrder = object.conditionsCancelOrder ?? undefined;
    message.conditionsIgnoreRth = object.conditionsIgnoreRth ?? undefined;
    message.modelCode = object.modelCode ?? undefined;
    message.extOperator = object.extOperator ?? undefined;
    message.softDollarTier = (object.softDollarTier !== undefined && object.softDollarTier !== null)
      ? SoftDollarTier.fromPartial(object.softDollarTier)
      : undefined;
    message.cashQty = object.cashQty ?? undefined;
    message.mifid2DecisionMaker = object.mifid2DecisionMaker ?? undefined;
    message.mifid2DecisionAlgo = object.mifid2DecisionAlgo ?? undefined;
    message.mifid2ExecutionTrader = object.mifid2ExecutionTrader ?? undefined;
    message.mifid2ExecutionAlgo = object.mifid2ExecutionAlgo ?? undefined;
    message.dontUseAutoPriceForHedge = object.dontUseAutoPriceForHedge ?? undefined;
    message.isOmsContainer = object.isOmsContainer ?? undefined;
    message.discretionaryUpToLimitPrice = object.discretionaryUpToLimitPrice ?? undefined;
    message.autoCancelDate = object.autoCancelDate ?? undefined;
    message.filledQuantity = object.filledQuantity ?? undefined;
    message.refFuturesConId = object.refFuturesConId ?? undefined;
    message.autoCancelParent = object.autoCancelParent ?? undefined;
    message.shareholder = object.shareholder ?? undefined;
    message.imbalanceOnly = object.imbalanceOnly ?? undefined;
    message.routeMarketableToBbo = object.routeMarketableToBbo ?? undefined;
    message.parentPermId = object.parentPermId ?? undefined;
    message.usePriceMgmtAlgo = object.usePriceMgmtAlgo ?? undefined;
    message.duration = object.duration ?? undefined;
    message.postToAts = object.postToAts ?? undefined;
    message.advancedErrorOverride = object.advancedErrorOverride ?? undefined;
    message.manualOrderTime = object.manualOrderTime ?? undefined;
    message.minTradeQty = object.minTradeQty ?? undefined;
    message.minCompeteSize = object.minCompeteSize ?? undefined;
    message.competeAgainstBestOffset = object.competeAgainstBestOffset ?? undefined;
    message.midOffsetAtWhole = object.midOffsetAtWhole ?? undefined;
    message.midOffsetAtHalf = object.midOffsetAtHalf ?? undefined;
    message.customerAccount = object.customerAccount ?? undefined;
    message.professionalCustomer = object.professionalCustomer ?? undefined;
    message.bondAccruedInterest = object.bondAccruedInterest ?? undefined;
    message.includeOvernight = object.includeOvernight ?? undefined;
    message.manualOrderIndicator = object.manualOrderIndicator ?? undefined;
    message.submitter = object.submitter ?? undefined;
    message.deactivate = object.deactivate ?? undefined;
    message.postOnly = object.postOnly ?? undefined;
    message.allowPreOpen = object.allowPreOpen ?? undefined;
    message.ignoreOpenAuction = object.ignoreOpenAuction ?? undefined;
    message.seekPriceImprovement = object.seekPriceImprovement ?? undefined;
    message.whatIfType = object.whatIfType ?? undefined;
    return message;
  },
};

function createBaseOrder_AlgoParamsEntry(): Order_AlgoParamsEntry {
  return { key: "", value: "" };
}

export const Order_AlgoParamsEntry: MessageFns<Order_AlgoParamsEntry> = {
  encode(message: Order_AlgoParamsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.key !== "") {
      writer.uint32(10).string(message.key);
    }
    if (message.value !== "") {
      writer.uint32(18).string(message.value);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): Order_AlgoParamsEntry {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseOrder_AlgoParamsEntry();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.key = reader.string();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.value = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): Order_AlgoParamsEntry {
    return {
      key: isSet(object.key) ? globalThis.String(object.key) : "",
      value: isSet(object.value) ? globalThis.String(object.value) : "",
    };
  },

  toJSON(message: Order_AlgoParamsEntry): unknown {
    const obj: any = {};
    if (message.key !== "") {
      obj.key = message.key;
    }
    if (message.value !== "") {
      obj.value = message.value;
    }
    return obj;
  },

  create(base?: DeepPartial<Order_AlgoParamsEntry>): Order_AlgoParamsEntry {
    return Order_AlgoParamsEntry.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<Order_AlgoParamsEntry>): Order_AlgoParamsEntry {
    const message = createBaseOrder_AlgoParamsEntry();
    message.key = object.key ?? "";
    message.value = object.value ?? "";
    return message;
  },
};

function createBaseOrder_SmartComboRoutingParamsEntry(): Order_SmartComboRoutingParamsEntry {
  return { key: "", value: "" };
}

export const Order_SmartComboRoutingParamsEntry: MessageFns<Order_SmartComboRoutingParamsEntry> = {
  encode(message: Order_SmartComboRoutingParamsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.key !== "") {
      writer.uint32(10).string(message.key);
    }
    if (message.value !== "") {
      writer.uint32(18).string(message.value);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): Order_SmartComboRoutingParamsEntry {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseOrder_SmartComboRoutingParamsEntry();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.key = reader.string();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.value = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): Order_SmartComboRoutingParamsEntry {
    return {
      key: isSet(object.key) ? globalThis.String(object.key) : "",
      value: isSet(object.value) ? globalThis.String(object.value) : "",
    };
  },

  toJSON(message: Order_SmartComboRoutingParamsEntry): unknown {
    const obj: any = {};
    if (message.key !== "") {
      obj.key = message.key;
    }
    if (message.value !== "") {
      obj.value = message.value;
    }
    return obj;
  },

  create(base?: DeepPartial<Order_SmartComboRoutingParamsEntry>): Order_SmartComboRoutingParamsEntry {
    return Order_SmartComboRoutingParamsEntry.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<Order_SmartComboRoutingParamsEntry>): Order_SmartComboRoutingParamsEntry {
    const message = createBaseOrder_SmartComboRoutingParamsEntry();
    message.key = object.key ?? "";
    message.value = object.value ?? "";
    return message;
  },
};

function createBaseOrder_OrderMiscOptionsEntry(): Order_OrderMiscOptionsEntry {
  return { key: "", value: "" };
}

export const Order_OrderMiscOptionsEntry: MessageFns<Order_OrderMiscOptionsEntry> = {
  encode(message: Order_OrderMiscOptionsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.key !== "") {
      writer.uint32(10).string(message.key);
    }
    if (message.value !== "") {
      writer.uint32(18).string(message.value);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): Order_OrderMiscOptionsEntry {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseOrder_OrderMiscOptionsEntry();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.key = reader.string();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.value = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): Order_OrderMiscOptionsEntry {
    return {
      key: isSet(object.key) ? globalThis.String(object.key) : "",
      value: isSet(object.value) ? globalThis.String(object.value) : "",
    };
  },

  toJSON(message: Order_OrderMiscOptionsEntry): unknown {
    const obj: any = {};
    if (message.key !== "") {
      obj.key = message.key;
    }
    if (message.value !== "") {
      obj.value = message.value;
    }
    return obj;
  },

  create(base?: DeepPartial<Order_OrderMiscOptionsEntry>): Order_OrderMiscOptionsEntry {
    return Order_OrderMiscOptionsEntry.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<Order_OrderMiscOptionsEntry>): Order_OrderMiscOptionsEntry {
    const message = createBaseOrder_OrderMiscOptionsEntry();
    message.key = object.key ?? "";
    message.value = object.value ?? "";
    return message;
  },
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

function longToNumber(int64: { toString(): string }): number {
  const num = globalThis.Number(int64.toString());
  if (num > globalThis.Number.MAX_SAFE_INTEGER) {
    throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
  }
  if (num < globalThis.Number.MIN_SAFE_INTEGER) {
    throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
  }
  return num;
}

function isObject(value: any): boolean {
  return typeof value === "object" && value !== null;
}

function isSet(value: any): boolean {
  return value !== null && value !== undefined;
}

export interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  fromJSON(object: any): T;
  toJSON(message: T): unknown;
  create(base?: DeepPartial<T>): T;
  fromPartial(object: DeepPartial<T>): T;
}
