fast_xirr 1.1.0 → 1.1.1
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/ext/fast_xirr/brent.c +14 -9
- data/lib/fast_xirr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f240b5f7c4ffe72a091fea47502e7bf16a206502eb7b498131f68489698353a4
|
4
|
+
data.tar.gz: 541df15f67a6e62dc1d8c2a07db6673bd8b806b98a22dc7832a743824add6078
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15e8c80e533662528318fa0bd4a488c27c1fe30532d6b483acaf05e7407a67a17d899cad206d455d4d13a7ddcec929f7a265ba926222fe07881c9034f6718c89
|
7
|
+
data.tar.gz: deb52dffd457cab0bf5a730d75b26ed61cd0e87c6dc27708f2a515b61fd08edaeece7e09d365b3e08748cfab53f9bff87a404e7d8aa92ff091ed328769316336
|
data/ext/fast_xirr/brent.c
CHANGED
@@ -127,14 +127,19 @@ double brent_method(CashFlow *cashflows, long long count, double tol,
|
|
127
127
|
VALUE calculate_xirr_with_brent(VALUE self, VALUE rb_cashflows, VALUE rb_tol,
|
128
128
|
VALUE rb_max_iter, VALUE rb_brackets) {
|
129
129
|
// Get the number of cash flows
|
130
|
-
long long
|
131
|
-
CashFlow cashflows[
|
130
|
+
long long total_count = (long long)RARRAY_LEN(rb_cashflows);
|
131
|
+
CashFlow cashflows[total_count];
|
132
|
+
long long filtered_count = 0;
|
132
133
|
|
133
|
-
// Convert Ruby cash flows array to C array
|
134
|
-
for (long long i = 0; i <
|
134
|
+
// Convert Ruby cash flows array to C array, filtering out zero amounts
|
135
|
+
for (long long i = 0; i < total_count; i++) {
|
135
136
|
VALUE rb_cashflow = rb_ary_entry(rb_cashflows, i);
|
136
|
-
|
137
|
-
|
137
|
+
double amount = NUM2DBL(rb_ary_entry(rb_cashflow, 0));
|
138
|
+
if (amount != 0.0) {
|
139
|
+
cashflows[filtered_count].amount = amount;
|
140
|
+
cashflows[filtered_count].date = (int64_t)NUM2LL(rb_ary_entry(rb_cashflow, 1));
|
141
|
+
filtered_count++;
|
142
|
+
}
|
138
143
|
}
|
139
144
|
|
140
145
|
// Convert tolerance and max iterations to C types
|
@@ -154,7 +159,7 @@ VALUE calculate_xirr_with_brent(VALUE self, VALUE rb_cashflows, VALUE rb_tol,
|
|
154
159
|
high = NUM2DBL(rb_ary_entry(rb_brackets, 1));
|
155
160
|
}
|
156
161
|
|
157
|
-
result = brent_method(cashflows,
|
162
|
+
result = brent_method(cashflows, filtered_count, tol, max_iter, low, high);
|
158
163
|
if (!isnan(result)) {
|
159
164
|
return rb_float_new(result);
|
160
165
|
}
|
@@ -162,8 +167,8 @@ VALUE calculate_xirr_with_brent(VALUE self, VALUE rb_cashflows, VALUE rb_tol,
|
|
162
167
|
// If the standard interval fails, try to find a better bracketing interval
|
163
168
|
low = -0.9999999;
|
164
169
|
high = 100.0;
|
165
|
-
if (find_bracketing_interval(cashflows,
|
166
|
-
result = brent_method(cashflows,
|
170
|
+
if (find_bracketing_interval(cashflows, filtered_count, &low, &high)) {
|
171
|
+
result = brent_method(cashflows, filtered_count, tol, max_iter, low, high);
|
167
172
|
return rb_float_new(result);
|
168
173
|
}
|
169
174
|
|
data/lib/fast_xirr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_xirr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Martini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem to calculate the XIRR using a C extension for performance.
|
14
14
|
email:
|