forked from SciSharp/Numpy.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumPy.financial.gen.cs
More file actions
518 lines (505 loc) · 18.3 KB
/
NumPy.financial.gen.cs
File metadata and controls
518 lines (505 loc) · 18.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
// Copyright (c) 2019 by the SciSharp Team
// Code generated by CodeMinion: https://github.com/SciSharp/CodeMinion
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Python.Runtime;
using Numpy.Models;
using Python.Included;
namespace Numpy
{
public partial class NumPy
{
/// <summary>
/// Compute the future value.<br></br>
///
/// Notes
///
/// The future value is computed by solving the equation:
///
/// or, when rate == 0:
///
/// References
/// </summary>
/// <param name="rate">
/// Rate of interest as decimal (not per cent) per period
/// </param>
/// <param name="nper">
/// Number of compounding periods
/// </param>
/// <param name="pmt">
/// Payment
/// </param>
/// <param name="pv">
/// Present value
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0)).<br></br>
///
/// Defaults to {‘end’, 0}.
/// </param>
/// <returns>
/// Future values.<br></br>
/// If all input is scalar, returns a scalar float.<br></br>
/// If
/// any input is array_like, returns future values for each input element.<br></br>
///
/// If multiple inputs are array_like, they all must have the same shape.
/// </returns>
public NDarray fv(NDarray rate, NDarray nper, NDarray pmt, NDarray pv, string @when = "end")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
nper,
pmt,
pv,
});
var kwargs=new PyDict();
if (@when!="end") kwargs["when"]=ToPython(@when);
dynamic py = __self__.InvokeMethod("fv", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Compute the present value.<br></br>
///
/// Notes
///
/// The present value is computed by solving the equation:
///
/// or, when rate = 0:
///
/// for pv, which is then returned.<br></br>
///
/// References
/// </summary>
/// <param name="rate">
/// Rate of interest (per period)
/// </param>
/// <param name="nper">
/// Number of compounding periods
/// </param>
/// <param name="pmt">
/// Payment
/// </param>
/// <param name="fv">
/// Future value
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0))
/// </param>
/// <returns>
/// Present value of a series of payments or investments.
/// </returns>
public NDarray pv(NDarray rate, NDarray nper, NDarray pmt, NDarray fv = null, string @when = "end")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
nper,
pmt,
});
var kwargs=new PyDict();
if (fv!=null) kwargs["fv"]=ToPython(fv);
if (@when!="end") kwargs["when"]=ToPython(@when);
dynamic py = __self__.InvokeMethod("pv", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Returns the NPV (Net Present Value) of a cash flow series.<br></br>
///
/// Notes
///
/// Returns the result of: [G]
///
/// References
/// </summary>
/// <param name="rate">
/// The discount rate.
/// </param>
/// <param name="values">
/// The values of the time series of cash flows.<br></br>
/// The (fixed) time
/// interval between cash flow “events” must be the same as that for
/// which rate is given (i.e., if rate is per year, then precisely
/// a year is understood to elapse between each cash flow event).<br></br>
/// By
/// convention, investments or “deposits” are negative, income or
/// “withdrawals” are positive; values must begin with the initial
/// investment, thus values[0] will typically be negative.
/// </param>
/// <returns>
/// The NPV of the input cash flow series values at the discount
/// rate.
/// </returns>
public float npv(ValueType rate, NDarray values)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
values,
});
var kwargs=new PyDict();
dynamic py = __self__.InvokeMethod("npv", pyargs, kwargs);
return ToCsharp<float>(py);
}
/// <summary>
/// Compute the payment against loan principal plus interest.<br></br>
///
/// Notes
///
/// The payment is computed by solving the equation:
///
/// or, when rate == 0:
///
/// for pmt.<br></br>
///
/// Note that computing a monthly mortgage payment is only
/// one use for this function.<br></br>
/// For example, pmt returns the
/// periodic deposit one must make to achieve a specified
/// future balance given an initial deposit, a fixed,
/// periodically compounded interest rate, and the total
/// number of periods.<br></br>
///
/// References
/// </summary>
/// <param name="rate">
/// Rate of interest (per period)
/// </param>
/// <param name="nper">
/// Number of compounding periods
/// </param>
/// <param name="pv">
/// Present value
/// </param>
/// <param name="fv">
/// Future value (default = 0)
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0))
/// </param>
/// <returns>
/// Payment against loan plus interest.<br></br>
/// If all input is scalar, returns a
/// scalar float.<br></br>
/// If any input is array_like, returns payment for each
/// input element.<br></br>
/// If multiple inputs are array_like, they all must have
/// the same shape.
/// </returns>
public NDarray pmt(NDarray rate, NDarray nper, NDarray pv, NDarray fv = null, string @when = "end")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
nper,
pv,
});
var kwargs=new PyDict();
if (fv!=null) kwargs["fv"]=ToPython(fv);
if (@when!="end") kwargs["when"]=ToPython(@when);
dynamic py = __self__.InvokeMethod("pmt", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Compute the payment against loan principal.
/// </summary>
/// <param name="rate">
/// Rate of interest (per period)
/// </param>
/// <param name="per">
/// Amount paid against the loan changes.<br></br>
/// The per is the period of
/// interest.
/// </param>
/// <param name="nper">
/// Number of compounding periods
/// </param>
/// <param name="pv">
/// Present value
/// </param>
/// <param name="fv">
/// Future value
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0))
/// </param>
public void ppmt(NDarray rate, NDarray per, NDarray nper, NDarray pv, NDarray fv = null, string @when = "end")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
per,
nper,
pv,
});
var kwargs=new PyDict();
if (fv!=null) kwargs["fv"]=ToPython(fv);
if (@when!="end") kwargs["when"]=ToPython(@when);
dynamic py = __self__.InvokeMethod("ppmt", pyargs, kwargs);
}
/// <summary>
/// Compute the interest portion of a payment.<br></br>
///
/// Notes
///
/// The total payment is made up of payment against principal plus interest.<br></br>
///
/// pmt = ppmt + ipmt
/// </summary>
/// <param name="rate">
/// Rate of interest as decimal (not per cent) per period
/// </param>
/// <param name="per">
/// Interest paid against the loan changes during the life or the loan.<br></br>
///
/// The per is the payment period to calculate the interest amount.
/// </param>
/// <param name="nper">
/// Number of compounding periods
/// </param>
/// <param name="pv">
/// Present value
/// </param>
/// <param name="fv">
/// Future value
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0)).<br></br>
///
/// Defaults to {‘end’, 0}.
/// </param>
/// <returns>
/// Interest portion of payment.<br></br>
/// If all input is scalar, returns a scalar
/// float.<br></br>
/// If any input is array_like, returns interest payment for each
/// input element.<br></br>
/// If multiple inputs are array_like, they all must have
/// the same shape.
/// </returns>
public NDarray ipmt(NDarray rate, NDarray per, NDarray nper, NDarray pv, NDarray fv = null, string @when = "end")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
per,
nper,
pv,
});
var kwargs=new PyDict();
if (fv!=null) kwargs["fv"]=ToPython(fv);
if (@when!="end") kwargs["when"]=ToPython(@when);
dynamic py = __self__.InvokeMethod("ipmt", pyargs, kwargs);
return ToCsharp<NDarray>(py);
}
/// <summary>
/// Return the Internal Rate of Return (IRR).<br></br>
///
/// This is the “average” periodically compounded rate of return
/// that gives a net present value of 0.0; for a more complete explanation,
/// see Notes below.<br></br>
///
/// decimal.Decimal type is not supported.<br></br>
///
/// Notes
///
/// The IRR is perhaps best understood through an example (illustrated
/// using np.irr in the Examples section below).<br></br>
/// Suppose one invests 100
/// units and then makes the following withdrawals at regular (fixed)
/// intervals: 39, 59, 55, 20. Assuming the ending value is 0, one’s 100
/// unit investment yields 173 units; however, due to the combination of
/// compounding and the periodic withdrawals, the “average” rate of return
/// is neither simply 0.73/4 nor (1.73)^0.25-1. Rather, it is the solution
/// (for ) of the equation:
///
/// In general, for values ,
/// irr is the solution of the equation: [G]
///
/// References
/// </summary>
/// <param name="values">
/// Input cash flows per time period.<br></br>
/// By convention, net “deposits”
/// are negative and net “withdrawals” are positive.<br></br>
/// Thus, for
/// example, at least the first element of values, which represents
/// the initial investment, will typically be negative.
/// </param>
/// <returns>
/// Internal Rate of Return for periodic input values.
/// </returns>
public float irr(NDarray values)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
values,
});
var kwargs=new PyDict();
dynamic py = __self__.InvokeMethod("irr", pyargs, kwargs);
return ToCsharp<float>(py);
}
/// <summary>
/// Modified internal rate of return.
/// </summary>
/// <param name="values">
/// Cash flows (must contain at least one positive and one negative
/// value) or nan is returned.<br></br>
/// The first value is considered a sunk
/// cost at time zero.
/// </param>
/// <param name="finance_rate">
/// Interest rate paid on the cash flows
/// </param>
/// <param name="reinvest_rate">
/// Interest rate received on the cash flows upon reinvestment
/// </param>
/// <returns>
/// Modified internal rate of return
/// </returns>
public float mirr(NDarray values, ValueType finance_rate, ValueType reinvest_rate)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
values,
finance_rate,
reinvest_rate,
});
var kwargs=new PyDict();
dynamic py = __self__.InvokeMethod("mirr", pyargs, kwargs);
return ToCsharp<float>(py);
}
/// <summary>
/// Compute the number of periodic payments.<br></br>
///
/// decimal.Decimal type is not supported.<br></br>
///
/// Notes
///
/// The number of periods nper is computed by solving the equation:
///
/// but if rate = 0 then:
/// </summary>
/// <param name="rate">
/// Rate of interest (per period)
/// </param>
/// <param name="pmt">
/// Payment
/// </param>
/// <param name="pv">
/// Present value
/// </param>
/// <param name="fv">
/// Future value
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0))
/// </param>
public void nper(NDarray rate, NDarray pmt, NDarray pv, NDarray fv = null, string @when = "end")
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
rate,
pmt,
pv,
});
var kwargs=new PyDict();
if (fv!=null) kwargs["fv"]=ToPython(fv);
if (@when!="end") kwargs["when"]=ToPython(@when);
dynamic py = __self__.InvokeMethod("nper", pyargs, kwargs);
}
/// <summary>
/// Compute the rate of interest per period.<br></br>
///
/// Notes
///
/// The rate of interest is computed by iteratively solving the
/// (non-linear) equation:
///
/// for rate.<br></br>
///
/// References
///
/// Wheeler, D.<br></br>
/// A., E.<br></br>
/// Rathke, and R.<br></br>
/// Weir (Eds.) (2009, May).<br></br>
/// Open Document
/// Format for Office Applications (OpenDocument)v1.2, Part 2: Recalculated
/// Formula (OpenFormula) Format - Annotated Version, Pre-Draft 12.
/// Organization for the Advancement of Structured Information Standards
/// (OASIS).<br></br>
/// Billerica, MA, USA.<br></br>
/// [ODT Document].<br></br>
/// Available:
/// http://www.oasis-open.org/committees/documents.php?wg_abbrev=office-formula
/// OpenDocument-formula-20090508.odt
/// </summary>
/// <param name="nper">
/// Number of compounding periods
/// </param>
/// <param name="pmt">
/// Payment
/// </param>
/// <param name="pv">
/// Present value
/// </param>
/// <param name="fv">
/// Future value
/// </param>
/// <param name="when">
/// When payments are due (‘begin’ (1) or ‘end’ (0))
/// </param>
/// <param name="guess">
/// Starting guess for solving the rate of interest, default 0.1
/// </param>
/// <param name="tol">
/// Required tolerance for the solution, default 1e-6
/// </param>
/// <param name="maxiter">
/// Maximum iterations in finding the solution
/// </param>
public void rate(NDarray nper, NDarray pmt, NDarray pv, NDarray fv, string @when = "end", double? guess = null, double? tol = null, int? maxiter = 100)
{
//auto-generated code, do not change
var __self__=self;
var pyargs=ToTuple(new object[]
{
nper,
pmt,
pv,
fv,
});
var kwargs=new PyDict();
if (@when!="end") kwargs["when"]=ToPython(@when);
if (guess!=null) kwargs["guess"]=ToPython(guess);
if (tol!=null) kwargs["tol"]=ToPython(tol);
if (maxiter!=100) kwargs["maxiter"]=ToPython(maxiter);
dynamic py = __self__.InvokeMethod("rate", pyargs, kwargs);
}
}
}