mortgagerb 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/mortgagerb/freddie_mac.rb +27 -0
- data/lib/mortgagerb/version.rb +1 -1
- data/lib/mortgagerb.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e3fcee7b69255bf0df020d2a1e38600bf355b9c3dc3478df00caec5cbc64aa
|
4
|
+
data.tar.gz: ee31b2bbb990b25daec56f30a043d0b62211d72da1480570a67d85b457e5cd4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c7e1926a18c4dabbd13c1a5b114cf2c440a517204dfcccb13ab2fa20593f4f7bb8db467d1f896fa7f54cef9498bb76901548a78cd1e9e27f29de89a0bf6fab8
|
7
|
+
data.tar.gz: 413800dccf465e107ed86dbcc2fa494c3c29fb4d3017f19b1af53d5cb64b9cf284f3de57824a3ec7ec080fa4926c824f876236a966e347466c804eef48dbe2d0
|
data/README.md
CHANGED
@@ -30,6 +30,21 @@ scenario = Mortgagerb::Scenario.new(principal, rate, type)
|
|
30
30
|
amortization_payment = scenario.calculate # 5677.89
|
31
31
|
```
|
32
32
|
|
33
|
+
### Get the 30-Yr FRM and 15-Yr FRM from Freddie Mac
|
34
|
+
|
35
|
+
The gem will scrape Freddie Mac's website in order to get the rates.
|
36
|
+
Use this responsibly. Do not over-scrape the website. Cache the value locally.
|
37
|
+
Check for new data seldomly.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'mortgagerb'
|
41
|
+
|
42
|
+
rates_now = Mortgagerb::FreddieMac.now
|
43
|
+
frm30 = rates_now[:fmr30] # 7.77
|
44
|
+
frm15 = rates_now[:frm15] # 6.66
|
45
|
+
```
|
46
|
+
|
47
|
+
|
33
48
|
## Development
|
34
49
|
|
35
50
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "nokogiri"
|
3
|
+
|
4
|
+
module Mortgagerb
|
5
|
+
class FreddieMac
|
6
|
+
def self.now
|
7
|
+
parsed_data = fetch
|
8
|
+
locate_assign(parsed_data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.fetch
|
12
|
+
response = Faraday.get("https://www.freddiemac.com/pmms/pmmsthick.html")
|
13
|
+
html = response.body
|
14
|
+
parsed_data = Nokogiri::HTML.parse(html)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.locate_assign(parsed_data)
|
18
|
+
fmr30 = parsed_data.xpath("//div[@class='pmmsContainer']/table[@class='table1']/tr/td[1]")
|
19
|
+
fmr15 = parsed_data.xpath("//div[@class='pmmsContainer']/table[@class='table1']/tr/td[2]")
|
20
|
+
|
21
|
+
{
|
22
|
+
fmr30: fmr30.text.strip.to_f,
|
23
|
+
fmr15: fmr15.text.strip.to_f
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mortgagerb/version.rb
CHANGED
data/lib/mortgagerb.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortgagerb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Calculate periodic payment given principal, rate and mortgage type
|
14
14
|
email:
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- Rakefile
|
25
25
|
- lib/mortgagerb.rb
|
26
26
|
- lib/mortgagerb/calculator.rb
|
27
|
+
- lib/mortgagerb/freddie_mac.rb
|
27
28
|
- lib/mortgagerb/scenario.rb
|
28
29
|
- lib/mortgagerb/version.rb
|
29
30
|
- sig/mortgagerb.rbs
|