bond_calculator

Bond Calculator is a ruby gem that helps calculate spread-to-benchmark and spread-to-curve

Installation

bond_calculator's installation is pretty standard:

$ gem install bond_calculator

Compatibility

bond_calculator supports the following Ruby versions:

  • 2.3
  • 2.4

Test

$ git clone https://github.com/lucassantanna/bond_calculator
$ cd bond_calculator
$ rake

Quickstart

$ cd ~/Desktop
$ git clone https://github.com/lucassantanna/bond_calculator
$ mkdir bond_example

$ cd bond_example
$ wget https://raw.githubusercontent.com/lucassantanna/bond_calculator/master/test/fixtures/c1.csv
$ wget https://raw.githubusercontent.com/lucassantanna/bond_calculator/master/test/fixtures/c2.csv

$ cd ~/Desktop/bond_calculator
$ /bin/console
# to calculate spread to benchmark
> BondCalculator::SpreadToBenchmark.new('PATH_TO_DESKTOP/bond_example/c1.csv').calculate

# OUTPUT: 
# bond, benchmark, spread_to_benchmark
# C1, G1, 1.6
# => [{:bond_name=>"C1", :benchmark_name=>"G1", :spread_to_benchmark=>1.6}]

# to calculate spread to curve
> BondCalculator::SpreadToCurve.new('PATH_TO_DESKTOP/bond_example/c2.csv').calculate

# OUTPUT: 
# bond, spread to curve
# C1, 1.43
# C2, 1.63
# C3, 2.47
# C4, 2.27
# C5, 1.9
# C6, 1.57
# C7, 2.83
# => [{:bond_name=>"C1", :spread_to_curve=>1.43}, {:bond_name=>"C2", :spread_to_curve=>1.63}, {:bond_name=>"C3", # :spread_to_curve=>2.47},{:bond_name=>"C4", :spread_to_curve=>2.27}, {:bond_name=>"C5", :spread_to_curve=>1.9}, # {:bond_name=>"C6", :spread_to_curve=>1.57}, {:bond
# _name=>"C7", :spread_to_curve=>2.83}]

Technical spec

  • Ruby 2.4.0
  • bundler ( Manage the gems that the application depends on)
  • mini-test ( I' ve decided to use mini-test because I have some experience with rspec but no experience with mini-test )
  • rake ( Created a task to run the tests )
  • pry ( debugging )
  • rubocop ( guarantee that the code is following the best practices)
  • YARD (Generate beautiful documentation.)

License

The gem is available under the terms of the MIT License.