<commit_before>require 'bindata'
require 'date'

module Tdx
  module Parsers
    class EoD
      def self.parse(file)
        quotes = []

        (file.size / 32).times do |line|
          file.pos = line * 32
          quotes << Quote.read(file)
        end

        return quotes
      end

      class Quote < BinData::Record
        endian  :little

        uint32  :date       # Date, as yyyymmdd
        uint32  :open       # Opening price, in cents
        uint32  :high       # Highiest price, in cents
        uint32  :low        # Lowest price, in cents
        uint32  :close      # Closing price, in cents
        float   :turnover   # Turnover
        uint32  :volume     # Volume
        skip    length: 4   # Reserved

        def read(data)
          super(data)

          return {
            date:     Date.parse(date.to_s),
            open:     open / 100.00,
            high:     high / 100.00,
            low:      low / 100.00,
            close:    close / 100.00,
            turnover: turnover.to_i,
            volume:   volume
          }
        end
      end
    end
  end
end<commit_msg>Fix the bug that returns unparsed quotes<commit_after>require 'bindata'
require 'date'

module Tdx
  module Parsers
    class EoD
      def self.parse(file)
        quotes = []

        (file.size / 32).times do |line|
          file.pos = line * 32
          quotes << Quote.new.read(file)
        end

        return quotes
      end

      class Quote < BinData::Record
        endian  :little

        uint32  :date       # Date, as yyyymmdd
        uint32  :open       # Opening price, in cents
        uint32  :high       # Highiest price, in cents
        uint32  :low        # Lowest price, in cents
        uint32  :close      # Closing price, in cents
        float   :turnover   # Turnover
        uint32  :volume     # Volume
        skip    length: 4   # Reserved

        def read(data)
          super

          return {
            date:     Date.parse(date.to_s),
            open:     open / 100.00,
            high:     high / 100.00,
            low:      low / 100.00,
            close:    close / 100.00,
            turnover: turnover.to_i,
            volume:   volume
          }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0744821507271926, 'fraction_numerical': 0.03261348611723226, 'mean_word_length': 1.2386587771203157, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4474764', 'n_tokens_mistral': 731, 'n_tokens_neox': 663, 'n_words': 199}