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

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

export const protobufPackage = "protobuf";

export interface ContractDetails {
  marketName?: string | undefined;
  minTick?: string | undefined;
  orderTypes?: string | undefined;
  validExchanges?: string | undefined;
  priceMagnifier?: number | undefined;
  underConId?: number | undefined;
  longName?: string | undefined;
  contractMonth?: string | undefined;
  industry?: string | undefined;
  category?: string | undefined;
  subcategory?: string | undefined;
  timeZoneId?: string | undefined;
  tradingHours?: string | undefined;
  liquidHours?: string | undefined;
  evRule?: string | undefined;
  evMultiplier?: number | undefined;
  secIdList: { [key: string]: string };
  aggGroup?: number | undefined;
  underSymbol?: string | undefined;
  underSecType?: string | undefined;
  marketRuleIds?: string | undefined;
  realExpirationDate?: string | undefined;
  stockType?: string | undefined;
  minSize?: string | undefined;
  sizeIncrement?: string | undefined;
  suggestedSizeIncrement?:
    | string
    | undefined;
  /** fund	fields */
  fundName?: string | undefined;
  fundFamily?: string | undefined;
  fundType?: string | undefined;
  fundFrontLoad?: string | undefined;
  fundBackLoad?: string | undefined;
  fundBackLoadTimeInterval?: string | undefined;
  fundManagementFee?: string | undefined;
  fundClosed?: boolean | undefined;
  fundClosedForNewInvestors?: boolean | undefined;
  fundClosedForNewMoney?: boolean | undefined;
  fundNotifyAmount?: string | undefined;
  fundMinimumInitialPurchase?: string | undefined;
  fundMinimumSubsequentPurchase?: string | undefined;
  fundBlueSkyStates?: string | undefined;
  fundBlueSkyTerritories?: string | undefined;
  fundDistributionPolicyIndicator?: string | undefined;
  fundAssetType?:
    | string
    | undefined;
  /** bond fields */
  cusip?: string | undefined;
  issueDate?: string | undefined;
  ratings?: string | undefined;
  bondType?: string | undefined;
  coupon?: number | undefined;
  couponType?: string | undefined;
  convertible?: boolean | undefined;
  callable?: boolean | undefined;
  puttable?: boolean | undefined;
  descAppend?: string | undefined;
  nextOptionDate?: string | undefined;
  nextOptionType?: string | undefined;
  nextOptionPartial?: boolean | undefined;
  bondNotes?: string | undefined;
  ineligibilityReasonList: IneligibilityReason[];
  /** event contract fields */
  eventContract1?: string | undefined;
  eventContractDescription1?: string | undefined;
  eventContractDescription2?: string | undefined;
  minAlgoSize?: string | undefined;
  lastPricePrecision?: string | undefined;
  lastSizePrecision?: string | undefined;
}

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

function createBaseContractDetails(): ContractDetails {
  return {
    marketName: undefined,
    minTick: undefined,
    orderTypes: undefined,
    validExchanges: undefined,
    priceMagnifier: undefined,
    underConId: undefined,
    longName: undefined,
    contractMonth: undefined,
    industry: undefined,
    category: undefined,
    subcategory: undefined,
    timeZoneId: undefined,
    tradingHours: undefined,
    liquidHours: undefined,
    evRule: undefined,
    evMultiplier: undefined,
    secIdList: {},
    aggGroup: undefined,
    underSymbol: undefined,
    underSecType: undefined,
    marketRuleIds: undefined,
    realExpirationDate: undefined,
    stockType: undefined,
    minSize: undefined,
    sizeIncrement: undefined,
    suggestedSizeIncrement: undefined,
    fundName: undefined,
    fundFamily: undefined,
    fundType: undefined,
    fundFrontLoad: undefined,
    fundBackLoad: undefined,
    fundBackLoadTimeInterval: undefined,
    fundManagementFee: undefined,
    fundClosed: undefined,
    fundClosedForNewInvestors: undefined,
    fundClosedForNewMoney: undefined,
    fundNotifyAmount: undefined,
    fundMinimumInitialPurchase: undefined,
    fundMinimumSubsequentPurchase: undefined,
    fundBlueSkyStates: undefined,
    fundBlueSkyTerritories: undefined,
    fundDistributionPolicyIndicator: undefined,
    fundAssetType: undefined,
    cusip: undefined,
    issueDate: undefined,
    ratings: undefined,
    bondType: undefined,
    coupon: undefined,
    couponType: undefined,
    convertible: undefined,
    callable: undefined,
    puttable: undefined,
    descAppend: undefined,
    nextOptionDate: undefined,
    nextOptionType: undefined,
    nextOptionPartial: undefined,
    bondNotes: undefined,
    ineligibilityReasonList: [],
    eventContract1: undefined,
    eventContractDescription1: undefined,
    eventContractDescription2: undefined,
    minAlgoSize: undefined,
    lastPricePrecision: undefined,
    lastSizePrecision: undefined,
  };
}

export const ContractDetails: MessageFns<ContractDetails> = {
  encode(message: ContractDetails, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.marketName !== undefined) {
      writer.uint32(10).string(message.marketName);
    }
    if (message.minTick !== undefined) {
      writer.uint32(18).string(message.minTick);
    }
    if (message.orderTypes !== undefined) {
      writer.uint32(26).string(message.orderTypes);
    }
    if (message.validExchanges !== undefined) {
      writer.uint32(34).string(message.validExchanges);
    }
    if (message.priceMagnifier !== undefined) {
      writer.uint32(40).int32(message.priceMagnifier);
    }
    if (message.underConId !== undefined) {
      writer.uint32(48).int32(message.underConId);
    }
    if (message.longName !== undefined) {
      writer.uint32(58).string(message.longName);
    }
    if (message.contractMonth !== undefined) {
      writer.uint32(66).string(message.contractMonth);
    }
    if (message.industry !== undefined) {
      writer.uint32(74).string(message.industry);
    }
    if (message.category !== undefined) {
      writer.uint32(82).string(message.category);
    }
    if (message.subcategory !== undefined) {
      writer.uint32(90).string(message.subcategory);
    }
    if (message.timeZoneId !== undefined) {
      writer.uint32(98).string(message.timeZoneId);
    }
    if (message.tradingHours !== undefined) {
      writer.uint32(106).string(message.tradingHours);
    }
    if (message.liquidHours !== undefined) {
      writer.uint32(114).string(message.liquidHours);
    }
    if (message.evRule !== undefined) {
      writer.uint32(122).string(message.evRule);
    }
    if (message.evMultiplier !== undefined) {
      writer.uint32(129).double(message.evMultiplier);
    }
    globalThis.Object.entries(message.secIdList).forEach(([key, value]: [string, string]) => {
      ContractDetails_SecIdListEntry.encode({ key: key as any, value }, writer.uint32(138).fork()).join();
    });
    if (message.aggGroup !== undefined) {
      writer.uint32(144).int32(message.aggGroup);
    }
    if (message.underSymbol !== undefined) {
      writer.uint32(154).string(message.underSymbol);
    }
    if (message.underSecType !== undefined) {
      writer.uint32(162).string(message.underSecType);
    }
    if (message.marketRuleIds !== undefined) {
      writer.uint32(170).string(message.marketRuleIds);
    }
    if (message.realExpirationDate !== undefined) {
      writer.uint32(178).string(message.realExpirationDate);
    }
    if (message.stockType !== undefined) {
      writer.uint32(186).string(message.stockType);
    }
    if (message.minSize !== undefined) {
      writer.uint32(194).string(message.minSize);
    }
    if (message.sizeIncrement !== undefined) {
      writer.uint32(202).string(message.sizeIncrement);
    }
    if (message.suggestedSizeIncrement !== undefined) {
      writer.uint32(210).string(message.suggestedSizeIncrement);
    }
    if (message.fundName !== undefined) {
      writer.uint32(218).string(message.fundName);
    }
    if (message.fundFamily !== undefined) {
      writer.uint32(226).string(message.fundFamily);
    }
    if (message.fundType !== undefined) {
      writer.uint32(234).string(message.fundType);
    }
    if (message.fundFrontLoad !== undefined) {
      writer.uint32(242).string(message.fundFrontLoad);
    }
    if (message.fundBackLoad !== undefined) {
      writer.uint32(250).string(message.fundBackLoad);
    }
    if (message.fundBackLoadTimeInterval !== undefined) {
      writer.uint32(258).string(message.fundBackLoadTimeInterval);
    }
    if (message.fundManagementFee !== undefined) {
      writer.uint32(266).string(message.fundManagementFee);
    }
    if (message.fundClosed !== undefined) {
      writer.uint32(272).bool(message.fundClosed);
    }
    if (message.fundClosedForNewInvestors !== undefined) {
      writer.uint32(280).bool(message.fundClosedForNewInvestors);
    }
    if (message.fundClosedForNewMoney !== undefined) {
      writer.uint32(288).bool(message.fundClosedForNewMoney);
    }
    if (message.fundNotifyAmount !== undefined) {
      writer.uint32(298).string(message.fundNotifyAmount);
    }
    if (message.fundMinimumInitialPurchase !== undefined) {
      writer.uint32(306).string(message.fundMinimumInitialPurchase);
    }
    if (message.fundMinimumSubsequentPurchase !== undefined) {
      writer.uint32(314).string(message.fundMinimumSubsequentPurchase);
    }
    if (message.fundBlueSkyStates !== undefined) {
      writer.uint32(322).string(message.fundBlueSkyStates);
    }
    if (message.fundBlueSkyTerritories !== undefined) {
      writer.uint32(330).string(message.fundBlueSkyTerritories);
    }
    if (message.fundDistributionPolicyIndicator !== undefined) {
      writer.uint32(338).string(message.fundDistributionPolicyIndicator);
    }
    if (message.fundAssetType !== undefined) {
      writer.uint32(346).string(message.fundAssetType);
    }
    if (message.cusip !== undefined) {
      writer.uint32(354).string(message.cusip);
    }
    if (message.issueDate !== undefined) {
      writer.uint32(362).string(message.issueDate);
    }
    if (message.ratings !== undefined) {
      writer.uint32(370).string(message.ratings);
    }
    if (message.bondType !== undefined) {
      writer.uint32(378).string(message.bondType);
    }
    if (message.coupon !== undefined) {
      writer.uint32(385).double(message.coupon);
    }
    if (message.couponType !== undefined) {
      writer.uint32(394).string(message.couponType);
    }
    if (message.convertible !== undefined) {
      writer.uint32(400).bool(message.convertible);
    }
    if (message.callable !== undefined) {
      writer.uint32(408).bool(message.callable);
    }
    if (message.puttable !== undefined) {
      writer.uint32(416).bool(message.puttable);
    }
    if (message.descAppend !== undefined) {
      writer.uint32(426).string(message.descAppend);
    }
    if (message.nextOptionDate !== undefined) {
      writer.uint32(434).string(message.nextOptionDate);
    }
    if (message.nextOptionType !== undefined) {
      writer.uint32(442).string(message.nextOptionType);
    }
    if (message.nextOptionPartial !== undefined) {
      writer.uint32(448).bool(message.nextOptionPartial);
    }
    if (message.bondNotes !== undefined) {
      writer.uint32(458).string(message.bondNotes);
    }
    for (const v of message.ineligibilityReasonList) {
      IneligibilityReason.encode(v!, writer.uint32(466).fork()).join();
    }
    if (message.eventContract1 !== undefined) {
      writer.uint32(474).string(message.eventContract1);
    }
    if (message.eventContractDescription1 !== undefined) {
      writer.uint32(482).string(message.eventContractDescription1);
    }
    if (message.eventContractDescription2 !== undefined) {
      writer.uint32(490).string(message.eventContractDescription2);
    }
    if (message.minAlgoSize !== undefined) {
      writer.uint32(498).string(message.minAlgoSize);
    }
    if (message.lastPricePrecision !== undefined) {
      writer.uint32(506).string(message.lastPricePrecision);
    }
    if (message.lastSizePrecision !== undefined) {
      writer.uint32(514).string(message.lastSizePrecision);
    }
    return writer;
  },

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

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

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

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

          message.validExchanges = reader.string();
          continue;
        }
        case 5: {
          if (tag !== 40) {
            break;
          }

          message.priceMagnifier = reader.int32();
          continue;
        }
        case 6: {
          if (tag !== 48) {
            break;
          }

          message.underConId = reader.int32();
          continue;
        }
        case 7: {
          if (tag !== 58) {
            break;
          }

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

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

          message.industry = reader.string();
          continue;
        }
        case 10: {
          if (tag !== 82) {
            break;
          }

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

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

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

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

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

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

          message.evMultiplier = reader.double();
          continue;
        }
        case 17: {
          if (tag !== 138) {
            break;
          }

          const entry17 = ContractDetails_SecIdListEntry.decode(reader, reader.uint32());
          if (entry17.value !== undefined) {
            message.secIdList[entry17.key] = entry17.value;
          }
          continue;
        }
        case 18: {
          if (tag !== 144) {
            break;
          }

          message.aggGroup = reader.int32();
          continue;
        }
        case 19: {
          if (tag !== 154) {
            break;
          }

          message.underSymbol = reader.string();
          continue;
        }
        case 20: {
          if (tag !== 162) {
            break;
          }

          message.underSecType = reader.string();
          continue;
        }
        case 21: {
          if (tag !== 170) {
            break;
          }

          message.marketRuleIds = reader.string();
          continue;
        }
        case 22: {
          if (tag !== 178) {
            break;
          }

          message.realExpirationDate = reader.string();
          continue;
        }
        case 23: {
          if (tag !== 186) {
            break;
          }

          message.stockType = reader.string();
          continue;
        }
        case 24: {
          if (tag !== 194) {
            break;
          }

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

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

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

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

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

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

          message.fundFrontLoad = reader.string();
          continue;
        }
        case 31: {
          if (tag !== 250) {
            break;
          }

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

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

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

          message.fundClosed = reader.bool();
          continue;
        }
        case 35: {
          if (tag !== 280) {
            break;
          }

          message.fundClosedForNewInvestors = reader.bool();
          continue;
        }
        case 36: {
          if (tag !== 288) {
            break;
          }

          message.fundClosedForNewMoney = reader.bool();
          continue;
        }
        case 37: {
          if (tag !== 298) {
            break;
          }

          message.fundNotifyAmount = reader.string();
          continue;
        }
        case 38: {
          if (tag !== 306) {
            break;
          }

          message.fundMinimumInitialPurchase = reader.string();
          continue;
        }
        case 39: {
          if (tag !== 314) {
            break;
          }

          message.fundMinimumSubsequentPurchase = reader.string();
          continue;
        }
        case 40: {
          if (tag !== 322) {
            break;
          }

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

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

          message.fundDistributionPolicyIndicator = reader.string();
          continue;
        }
        case 43: {
          if (tag !== 346) {
            break;
          }

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

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

          message.issueDate = reader.string();
          continue;
        }
        case 46: {
          if (tag !== 370) {
            break;
          }

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

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

          message.coupon = reader.double();
          continue;
        }
        case 49: {
          if (tag !== 394) {
            break;
          }

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

          message.convertible = reader.bool();
          continue;
        }
        case 51: {
          if (tag !== 408) {
            break;
          }

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

          message.puttable = reader.bool();
          continue;
        }
        case 53: {
          if (tag !== 426) {
            break;
          }

          message.descAppend = reader.string();
          continue;
        }
        case 54: {
          if (tag !== 434) {
            break;
          }

          message.nextOptionDate = reader.string();
          continue;
        }
        case 55: {
          if (tag !== 442) {
            break;
          }

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

          message.nextOptionPartial = reader.bool();
          continue;
        }
        case 57: {
          if (tag !== 458) {
            break;
          }

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

          message.ineligibilityReasonList.push(IneligibilityReason.decode(reader, reader.uint32()));
          continue;
        }
        case 59: {
          if (tag !== 474) {
            break;
          }

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

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

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

          message.minAlgoSize = reader.string();
          continue;
        }
        case 63: {
          if (tag !== 506) {
            break;
          }

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

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

  fromJSON(object: any): ContractDetails {
    return {
      marketName: isSet(object.marketName) ? globalThis.String(object.marketName) : undefined,
      minTick: isSet(object.minTick) ? globalThis.String(object.minTick) : undefined,
      orderTypes: isSet(object.orderTypes) ? globalThis.String(object.orderTypes) : undefined,
      validExchanges: isSet(object.validExchanges) ? globalThis.String(object.validExchanges) : undefined,
      priceMagnifier: isSet(object.priceMagnifier) ? globalThis.Number(object.priceMagnifier) : undefined,
      underConId: isSet(object.underConId) ? globalThis.Number(object.underConId) : undefined,
      longName: isSet(object.longName) ? globalThis.String(object.longName) : undefined,
      contractMonth: isSet(object.contractMonth) ? globalThis.String(object.contractMonth) : undefined,
      industry: isSet(object.industry) ? globalThis.String(object.industry) : undefined,
      category: isSet(object.category) ? globalThis.String(object.category) : undefined,
      subcategory: isSet(object.subcategory) ? globalThis.String(object.subcategory) : undefined,
      timeZoneId: isSet(object.timeZoneId) ? globalThis.String(object.timeZoneId) : undefined,
      tradingHours: isSet(object.tradingHours) ? globalThis.String(object.tradingHours) : undefined,
      liquidHours: isSet(object.liquidHours) ? globalThis.String(object.liquidHours) : undefined,
      evRule: isSet(object.evRule) ? globalThis.String(object.evRule) : undefined,
      evMultiplier: isSet(object.evMultiplier) ? globalThis.Number(object.evMultiplier) : undefined,
      secIdList: isObject(object.secIdList)
        ? (globalThis.Object.entries(object.secIdList) as [string, any][]).reduce(
          (acc: { [key: string]: string }, [key, value]: [string, any]) => {
            acc[key] = globalThis.String(value);
            return acc;
          },
          {},
        )
        : {},
      aggGroup: isSet(object.aggGroup) ? globalThis.Number(object.aggGroup) : undefined,
      underSymbol: isSet(object.underSymbol) ? globalThis.String(object.underSymbol) : undefined,
      underSecType: isSet(object.underSecType) ? globalThis.String(object.underSecType) : undefined,
      marketRuleIds: isSet(object.marketRuleIds) ? globalThis.String(object.marketRuleIds) : undefined,
      realExpirationDate: isSet(object.realExpirationDate) ? globalThis.String(object.realExpirationDate) : undefined,
      stockType: isSet(object.stockType) ? globalThis.String(object.stockType) : undefined,
      minSize: isSet(object.minSize) ? globalThis.String(object.minSize) : undefined,
      sizeIncrement: isSet(object.sizeIncrement) ? globalThis.String(object.sizeIncrement) : undefined,
      suggestedSizeIncrement: isSet(object.suggestedSizeIncrement)
        ? globalThis.String(object.suggestedSizeIncrement)
        : undefined,
      fundName: isSet(object.fundName) ? globalThis.String(object.fundName) : undefined,
      fundFamily: isSet(object.fundFamily) ? globalThis.String(object.fundFamily) : undefined,
      fundType: isSet(object.fundType) ? globalThis.String(object.fundType) : undefined,
      fundFrontLoad: isSet(object.fundFrontLoad) ? globalThis.String(object.fundFrontLoad) : undefined,
      fundBackLoad: isSet(object.fundBackLoad) ? globalThis.String(object.fundBackLoad) : undefined,
      fundBackLoadTimeInterval: isSet(object.fundBackLoadTimeInterval)
        ? globalThis.String(object.fundBackLoadTimeInterval)
        : undefined,
      fundManagementFee: isSet(object.fundManagementFee) ? globalThis.String(object.fundManagementFee) : undefined,
      fundClosed: isSet(object.fundClosed) ? globalThis.Boolean(object.fundClosed) : undefined,
      fundClosedForNewInvestors: isSet(object.fundClosedForNewInvestors)
        ? globalThis.Boolean(object.fundClosedForNewInvestors)
        : undefined,
      fundClosedForNewMoney: isSet(object.fundClosedForNewMoney)
        ? globalThis.Boolean(object.fundClosedForNewMoney)
        : undefined,
      fundNotifyAmount: isSet(object.fundNotifyAmount) ? globalThis.String(object.fundNotifyAmount) : undefined,
      fundMinimumInitialPurchase: isSet(object.fundMinimumInitialPurchase)
        ? globalThis.String(object.fundMinimumInitialPurchase)
        : undefined,
      fundMinimumSubsequentPurchase: isSet(object.fundMinimumSubsequentPurchase)
        ? globalThis.String(object.fundMinimumSubsequentPurchase)
        : undefined,
      fundBlueSkyStates: isSet(object.fundBlueSkyStates) ? globalThis.String(object.fundBlueSkyStates) : undefined,
      fundBlueSkyTerritories: isSet(object.fundBlueSkyTerritories)
        ? globalThis.String(object.fundBlueSkyTerritories)
        : undefined,
      fundDistributionPolicyIndicator: isSet(object.fundDistributionPolicyIndicator)
        ? globalThis.String(object.fundDistributionPolicyIndicator)
        : undefined,
      fundAssetType: isSet(object.fundAssetType) ? globalThis.String(object.fundAssetType) : undefined,
      cusip: isSet(object.cusip) ? globalThis.String(object.cusip) : undefined,
      issueDate: isSet(object.issueDate) ? globalThis.String(object.issueDate) : undefined,
      ratings: isSet(object.ratings) ? globalThis.String(object.ratings) : undefined,
      bondType: isSet(object.bondType) ? globalThis.String(object.bondType) : undefined,
      coupon: isSet(object.coupon) ? globalThis.Number(object.coupon) : undefined,
      couponType: isSet(object.couponType) ? globalThis.String(object.couponType) : undefined,
      convertible: isSet(object.convertible) ? globalThis.Boolean(object.convertible) : undefined,
      callable: isSet(object.callable) ? globalThis.Boolean(object.callable) : undefined,
      puttable: isSet(object.puttable) ? globalThis.Boolean(object.puttable) : undefined,
      descAppend: isSet(object.descAppend) ? globalThis.String(object.descAppend) : undefined,
      nextOptionDate: isSet(object.nextOptionDate) ? globalThis.String(object.nextOptionDate) : undefined,
      nextOptionType: isSet(object.nextOptionType) ? globalThis.String(object.nextOptionType) : undefined,
      nextOptionPartial: isSet(object.nextOptionPartial) ? globalThis.Boolean(object.nextOptionPartial) : undefined,
      bondNotes: isSet(object.bondNotes) ? globalThis.String(object.bondNotes) : undefined,
      ineligibilityReasonList: globalThis.Array.isArray(object?.ineligibilityReasonList)
        ? object.ineligibilityReasonList.map((e: any) => IneligibilityReason.fromJSON(e))
        : [],
      eventContract1: isSet(object.eventContract1) ? globalThis.String(object.eventContract1) : undefined,
      eventContractDescription1: isSet(object.eventContractDescription1)
        ? globalThis.String(object.eventContractDescription1)
        : undefined,
      eventContractDescription2: isSet(object.eventContractDescription2)
        ? globalThis.String(object.eventContractDescription2)
        : undefined,
      minAlgoSize: isSet(object.minAlgoSize) ? globalThis.String(object.minAlgoSize) : undefined,
      lastPricePrecision: isSet(object.lastPricePrecision) ? globalThis.String(object.lastPricePrecision) : undefined,
      lastSizePrecision: isSet(object.lastSizePrecision) ? globalThis.String(object.lastSizePrecision) : undefined,
    };
  },

  toJSON(message: ContractDetails): unknown {
    const obj: any = {};
    if (message.marketName !== undefined) {
      obj.marketName = message.marketName;
    }
    if (message.minTick !== undefined) {
      obj.minTick = message.minTick;
    }
    if (message.orderTypes !== undefined) {
      obj.orderTypes = message.orderTypes;
    }
    if (message.validExchanges !== undefined) {
      obj.validExchanges = message.validExchanges;
    }
    if (message.priceMagnifier !== undefined) {
      obj.priceMagnifier = Math.round(message.priceMagnifier);
    }
    if (message.underConId !== undefined) {
      obj.underConId = Math.round(message.underConId);
    }
    if (message.longName !== undefined) {
      obj.longName = message.longName;
    }
    if (message.contractMonth !== undefined) {
      obj.contractMonth = message.contractMonth;
    }
    if (message.industry !== undefined) {
      obj.industry = message.industry;
    }
    if (message.category !== undefined) {
      obj.category = message.category;
    }
    if (message.subcategory !== undefined) {
      obj.subcategory = message.subcategory;
    }
    if (message.timeZoneId !== undefined) {
      obj.timeZoneId = message.timeZoneId;
    }
    if (message.tradingHours !== undefined) {
      obj.tradingHours = message.tradingHours;
    }
    if (message.liquidHours !== undefined) {
      obj.liquidHours = message.liquidHours;
    }
    if (message.evRule !== undefined) {
      obj.evRule = message.evRule;
    }
    if (message.evMultiplier !== undefined) {
      obj.evMultiplier = message.evMultiplier;
    }
    if (message.secIdList) {
      const entries = globalThis.Object.entries(message.secIdList) as [string, string][];
      if (entries.length > 0) {
        obj.secIdList = {};
        entries.forEach(([k, v]) => {
          obj.secIdList[k] = v;
        });
      }
    }
    if (message.aggGroup !== undefined) {
      obj.aggGroup = Math.round(message.aggGroup);
    }
    if (message.underSymbol !== undefined) {
      obj.underSymbol = message.underSymbol;
    }
    if (message.underSecType !== undefined) {
      obj.underSecType = message.underSecType;
    }
    if (message.marketRuleIds !== undefined) {
      obj.marketRuleIds = message.marketRuleIds;
    }
    if (message.realExpirationDate !== undefined) {
      obj.realExpirationDate = message.realExpirationDate;
    }
    if (message.stockType !== undefined) {
      obj.stockType = message.stockType;
    }
    if (message.minSize !== undefined) {
      obj.minSize = message.minSize;
    }
    if (message.sizeIncrement !== undefined) {
      obj.sizeIncrement = message.sizeIncrement;
    }
    if (message.suggestedSizeIncrement !== undefined) {
      obj.suggestedSizeIncrement = message.suggestedSizeIncrement;
    }
    if (message.fundName !== undefined) {
      obj.fundName = message.fundName;
    }
    if (message.fundFamily !== undefined) {
      obj.fundFamily = message.fundFamily;
    }
    if (message.fundType !== undefined) {
      obj.fundType = message.fundType;
    }
    if (message.fundFrontLoad !== undefined) {
      obj.fundFrontLoad = message.fundFrontLoad;
    }
    if (message.fundBackLoad !== undefined) {
      obj.fundBackLoad = message.fundBackLoad;
    }
    if (message.fundBackLoadTimeInterval !== undefined) {
      obj.fundBackLoadTimeInterval = message.fundBackLoadTimeInterval;
    }
    if (message.fundManagementFee !== undefined) {
      obj.fundManagementFee = message.fundManagementFee;
    }
    if (message.fundClosed !== undefined) {
      obj.fundClosed = message.fundClosed;
    }
    if (message.fundClosedForNewInvestors !== undefined) {
      obj.fundClosedForNewInvestors = message.fundClosedForNewInvestors;
    }
    if (message.fundClosedForNewMoney !== undefined) {
      obj.fundClosedForNewMoney = message.fundClosedForNewMoney;
    }
    if (message.fundNotifyAmount !== undefined) {
      obj.fundNotifyAmount = message.fundNotifyAmount;
    }
    if (message.fundMinimumInitialPurchase !== undefined) {
      obj.fundMinimumInitialPurchase = message.fundMinimumInitialPurchase;
    }
    if (message.fundMinimumSubsequentPurchase !== undefined) {
      obj.fundMinimumSubsequentPurchase = message.fundMinimumSubsequentPurchase;
    }
    if (message.fundBlueSkyStates !== undefined) {
      obj.fundBlueSkyStates = message.fundBlueSkyStates;
    }
    if (message.fundBlueSkyTerritories !== undefined) {
      obj.fundBlueSkyTerritories = message.fundBlueSkyTerritories;
    }
    if (message.fundDistributionPolicyIndicator !== undefined) {
      obj.fundDistributionPolicyIndicator = message.fundDistributionPolicyIndicator;
    }
    if (message.fundAssetType !== undefined) {
      obj.fundAssetType = message.fundAssetType;
    }
    if (message.cusip !== undefined) {
      obj.cusip = message.cusip;
    }
    if (message.issueDate !== undefined) {
      obj.issueDate = message.issueDate;
    }
    if (message.ratings !== undefined) {
      obj.ratings = message.ratings;
    }
    if (message.bondType !== undefined) {
      obj.bondType = message.bondType;
    }
    if (message.coupon !== undefined) {
      obj.coupon = message.coupon;
    }
    if (message.couponType !== undefined) {
      obj.couponType = message.couponType;
    }
    if (message.convertible !== undefined) {
      obj.convertible = message.convertible;
    }
    if (message.callable !== undefined) {
      obj.callable = message.callable;
    }
    if (message.puttable !== undefined) {
      obj.puttable = message.puttable;
    }
    if (message.descAppend !== undefined) {
      obj.descAppend = message.descAppend;
    }
    if (message.nextOptionDate !== undefined) {
      obj.nextOptionDate = message.nextOptionDate;
    }
    if (message.nextOptionType !== undefined) {
      obj.nextOptionType = message.nextOptionType;
    }
    if (message.nextOptionPartial !== undefined) {
      obj.nextOptionPartial = message.nextOptionPartial;
    }
    if (message.bondNotes !== undefined) {
      obj.bondNotes = message.bondNotes;
    }
    if (message.ineligibilityReasonList?.length) {
      obj.ineligibilityReasonList = message.ineligibilityReasonList.map((e) => IneligibilityReason.toJSON(e));
    }
    if (message.eventContract1 !== undefined) {
      obj.eventContract1 = message.eventContract1;
    }
    if (message.eventContractDescription1 !== undefined) {
      obj.eventContractDescription1 = message.eventContractDescription1;
    }
    if (message.eventContractDescription2 !== undefined) {
      obj.eventContractDescription2 = message.eventContractDescription2;
    }
    if (message.minAlgoSize !== undefined) {
      obj.minAlgoSize = message.minAlgoSize;
    }
    if (message.lastPricePrecision !== undefined) {
      obj.lastPricePrecision = message.lastPricePrecision;
    }
    if (message.lastSizePrecision !== undefined) {
      obj.lastSizePrecision = message.lastSizePrecision;
    }
    return obj;
  },

  create(base?: DeepPartial<ContractDetails>): ContractDetails {
    return ContractDetails.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ContractDetails>): ContractDetails {
    const message = createBaseContractDetails();
    message.marketName = object.marketName ?? undefined;
    message.minTick = object.minTick ?? undefined;
    message.orderTypes = object.orderTypes ?? undefined;
    message.validExchanges = object.validExchanges ?? undefined;
    message.priceMagnifier = object.priceMagnifier ?? undefined;
    message.underConId = object.underConId ?? undefined;
    message.longName = object.longName ?? undefined;
    message.contractMonth = object.contractMonth ?? undefined;
    message.industry = object.industry ?? undefined;
    message.category = object.category ?? undefined;
    message.subcategory = object.subcategory ?? undefined;
    message.timeZoneId = object.timeZoneId ?? undefined;
    message.tradingHours = object.tradingHours ?? undefined;
    message.liquidHours = object.liquidHours ?? undefined;
    message.evRule = object.evRule ?? undefined;
    message.evMultiplier = object.evMultiplier ?? undefined;
    message.secIdList = (globalThis.Object.entries(object.secIdList ?? {}) as [string, string][]).reduce(
      (acc: { [key: string]: string }, [key, value]: [string, string]) => {
        if (value !== undefined) {
          acc[key] = globalThis.String(value);
        }
        return acc;
      },
      {},
    );
    message.aggGroup = object.aggGroup ?? undefined;
    message.underSymbol = object.underSymbol ?? undefined;
    message.underSecType = object.underSecType ?? undefined;
    message.marketRuleIds = object.marketRuleIds ?? undefined;
    message.realExpirationDate = object.realExpirationDate ?? undefined;
    message.stockType = object.stockType ?? undefined;
    message.minSize = object.minSize ?? undefined;
    message.sizeIncrement = object.sizeIncrement ?? undefined;
    message.suggestedSizeIncrement = object.suggestedSizeIncrement ?? undefined;
    message.fundName = object.fundName ?? undefined;
    message.fundFamily = object.fundFamily ?? undefined;
    message.fundType = object.fundType ?? undefined;
    message.fundFrontLoad = object.fundFrontLoad ?? undefined;
    message.fundBackLoad = object.fundBackLoad ?? undefined;
    message.fundBackLoadTimeInterval = object.fundBackLoadTimeInterval ?? undefined;
    message.fundManagementFee = object.fundManagementFee ?? undefined;
    message.fundClosed = object.fundClosed ?? undefined;
    message.fundClosedForNewInvestors = object.fundClosedForNewInvestors ?? undefined;
    message.fundClosedForNewMoney = object.fundClosedForNewMoney ?? undefined;
    message.fundNotifyAmount = object.fundNotifyAmount ?? undefined;
    message.fundMinimumInitialPurchase = object.fundMinimumInitialPurchase ?? undefined;
    message.fundMinimumSubsequentPurchase = object.fundMinimumSubsequentPurchase ?? undefined;
    message.fundBlueSkyStates = object.fundBlueSkyStates ?? undefined;
    message.fundBlueSkyTerritories = object.fundBlueSkyTerritories ?? undefined;
    message.fundDistributionPolicyIndicator = object.fundDistributionPolicyIndicator ?? undefined;
    message.fundAssetType = object.fundAssetType ?? undefined;
    message.cusip = object.cusip ?? undefined;
    message.issueDate = object.issueDate ?? undefined;
    message.ratings = object.ratings ?? undefined;
    message.bondType = object.bondType ?? undefined;
    message.coupon = object.coupon ?? undefined;
    message.couponType = object.couponType ?? undefined;
    message.convertible = object.convertible ?? undefined;
    message.callable = object.callable ?? undefined;
    message.puttable = object.puttable ?? undefined;
    message.descAppend = object.descAppend ?? undefined;
    message.nextOptionDate = object.nextOptionDate ?? undefined;
    message.nextOptionType = object.nextOptionType ?? undefined;
    message.nextOptionPartial = object.nextOptionPartial ?? undefined;
    message.bondNotes = object.bondNotes ?? undefined;
    message.ineligibilityReasonList = object.ineligibilityReasonList?.map((e) => IneligibilityReason.fromPartial(e)) ||
      [];
    message.eventContract1 = object.eventContract1 ?? undefined;
    message.eventContractDescription1 = object.eventContractDescription1 ?? undefined;
    message.eventContractDescription2 = object.eventContractDescription2 ?? undefined;
    message.minAlgoSize = object.minAlgoSize ?? undefined;
    message.lastPricePrecision = object.lastPricePrecision ?? undefined;
    message.lastSizePrecision = object.lastSizePrecision ?? undefined;
    return message;
  },
};

function createBaseContractDetails_SecIdListEntry(): ContractDetails_SecIdListEntry {
  return { key: "", value: "" };
}

export const ContractDetails_SecIdListEntry: MessageFns<ContractDetails_SecIdListEntry> = {
  encode(message: ContractDetails_SecIdListEntry, 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): ContractDetails_SecIdListEntry {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseContractDetails_SecIdListEntry();
    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): ContractDetails_SecIdListEntry {
    return {
      key: isSet(object.key) ? globalThis.String(object.key) : "",
      value: isSet(object.value) ? globalThis.String(object.value) : "",
    };
  },

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

  create(base?: DeepPartial<ContractDetails_SecIdListEntry>): ContractDetails_SecIdListEntry {
    return ContractDetails_SecIdListEntry.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ContractDetails_SecIdListEntry>): ContractDetails_SecIdListEntry {
    const message = createBaseContractDetails_SecIdListEntry();
    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 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;
}
