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

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

export const protobufPackage = "protobuf";

export interface HistoricalDataBar {
  date?: string | undefined;
  open?: number | undefined;
  high?: number | undefined;
  low?: number | undefined;
  close?: number | undefined;
  volume?: string | undefined;
  WAP?: string | undefined;
  barCount?: number | undefined;
}

function createBaseHistoricalDataBar(): HistoricalDataBar {
  return {
    date: undefined,
    open: undefined,
    high: undefined,
    low: undefined,
    close: undefined,
    volume: undefined,
    WAP: undefined,
    barCount: undefined,
  };
}

export const HistoricalDataBar: MessageFns<HistoricalDataBar> = {
  encode(message: HistoricalDataBar, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.date !== undefined) {
      writer.uint32(10).string(message.date);
    }
    if (message.open !== undefined) {
      writer.uint32(17).double(message.open);
    }
    if (message.high !== undefined) {
      writer.uint32(25).double(message.high);
    }
    if (message.low !== undefined) {
      writer.uint32(33).double(message.low);
    }
    if (message.close !== undefined) {
      writer.uint32(41).double(message.close);
    }
    if (message.volume !== undefined) {
      writer.uint32(50).string(message.volume);
    }
    if (message.WAP !== undefined) {
      writer.uint32(58).string(message.WAP);
    }
    if (message.barCount !== undefined) {
      writer.uint32(64).int32(message.barCount);
    }
    return writer;
  },

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

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

          message.open = reader.double();
          continue;
        }
        case 3: {
          if (tag !== 25) {
            break;
          }

          message.high = reader.double();
          continue;
        }
        case 4: {
          if (tag !== 33) {
            break;
          }

          message.low = reader.double();
          continue;
        }
        case 5: {
          if (tag !== 41) {
            break;
          }

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

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

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

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

  fromJSON(object: any): HistoricalDataBar {
    return {
      date: isSet(object.date) ? globalThis.String(object.date) : undefined,
      open: isSet(object.open) ? globalThis.Number(object.open) : undefined,
      high: isSet(object.high) ? globalThis.Number(object.high) : undefined,
      low: isSet(object.low) ? globalThis.Number(object.low) : undefined,
      close: isSet(object.close) ? globalThis.Number(object.close) : undefined,
      volume: isSet(object.volume) ? globalThis.String(object.volume) : undefined,
      WAP: isSet(object.WAP) ? globalThis.String(object.WAP) : undefined,
      barCount: isSet(object.barCount) ? globalThis.Number(object.barCount) : undefined,
    };
  },

  toJSON(message: HistoricalDataBar): unknown {
    const obj: any = {};
    if (message.date !== undefined) {
      obj.date = message.date;
    }
    if (message.open !== undefined) {
      obj.open = message.open;
    }
    if (message.high !== undefined) {
      obj.high = message.high;
    }
    if (message.low !== undefined) {
      obj.low = message.low;
    }
    if (message.close !== undefined) {
      obj.close = message.close;
    }
    if (message.volume !== undefined) {
      obj.volume = message.volume;
    }
    if (message.WAP !== undefined) {
      obj.WAP = message.WAP;
    }
    if (message.barCount !== undefined) {
      obj.barCount = Math.round(message.barCount);
    }
    return obj;
  },

  create(base?: DeepPartial<HistoricalDataBar>): HistoricalDataBar {
    return HistoricalDataBar.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<HistoricalDataBar>): HistoricalDataBar {
    const message = createBaseHistoricalDataBar();
    message.date = object.date ?? undefined;
    message.open = object.open ?? undefined;
    message.high = object.high ?? undefined;
    message.low = object.low ?? undefined;
    message.close = object.close ?? undefined;
    message.volume = object.volume ?? undefined;
    message.WAP = object.WAP ?? undefined;
    message.barCount = object.barCount ?? undefined;
    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 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;
}
