<commit_before>module Service
  module Benchmark
    extend self

    def calculate_spread_to_benchmark(corporate_bond, government_bond)
      raise "ERROR: Service::Benchmark#calculate_spread_to_benchmark MUST have a corporate bond as its first parameter!" if corporate_bond.type != BondMetric::CORPORATE
      raise "ERROR: Service::Benchmark#calculate_spread_to_benchmark MUST have a government bond as its second parameter!"  if government_bond.type != BondMetric::GOVERNMENT

      return corporate_bond.basis_points - government_bond.basis_points
    end 

    def calculate_spread_to_curve(corporate_bond, government_bond_less_term, government_bond_greater_term)
    end
  end
end<commit_msg>implement #calculate_spread_to_curve<commit_after>module Service
  module Benchmark
    extend self

    def calculate_spread_to_benchmark(corporate_bond, government_bond)
      raise "ERROR: Service::Benchmark#calculate_spread_to_benchmark MUST have a corporate bond as its first parameter!" if corporate_bond.type != BondMetric::CORPORATE
      raise "ERROR: Service::Benchmark#calculate_spread_to_benchmark MUST have a government bond as its second parameter!"  if government_bond.type != BondMetric::GOVERNMENT

      return corporate_bond.basis_points - government_bond.basis_points
    end 

    def calculate_spread_to_curve(corporate_bond, government_bond_lesser, government_bond_greater)
      x = corporate_bond.term_years
      x1 = government_bond_lesser.term_years
      x2 = government_bond_greater.term_years
      y1 = government_bond_lesser.basis_points
      y2 = government_bond_greater.basis_points
      
      y = (y1 + ((x - x1)*(y2 - y1))/(x2 - x1)).round

      return corporate_bond.basis_points - y
    end
  end
end
{'fraction_non_alphanumeric': 0.06027554535017222, 'fraction_numerical': 0.0057405281285878304, 'mean_word_length': 4.771523178807947, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2849559', 'n_tokens_mistral': 574, 'n_tokens_neox': 499, 'n_words': 119}