Financial.php 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Calculation;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Financial\Amortization;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Financial\Coupons;
  5. use PhpOffice\PhpSpreadsheet\Calculation\Financial\Depreciation;
  6. use PhpOffice\PhpSpreadsheet\Calculation\Financial\Dollar;
  7. use PhpOffice\PhpSpreadsheet\Calculation\Financial\InterestRate;
  8. use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities;
  9. use PhpOffice\PhpSpreadsheet\Calculation\Financial\TreasuryBill;
  10. /**
  11. * @deprecated 1.18.0
  12. */
  13. class Financial
  14. {
  15. const FINANCIAL_MAX_ITERATIONS = 128;
  16. const FINANCIAL_PRECISION = 1.0e-08;
  17. /**
  18. * ACCRINT.
  19. *
  20. * Returns the accrued interest for a security that pays periodic interest.
  21. *
  22. * Excel Function:
  23. * ACCRINT(issue,firstinterest,settlement,rate,par,frequency[,basis][,calc_method])
  24. *
  25. * @deprecated 1.18.0
  26. * Use the periodic() method in the Financial\Securities\AccruedInterest class instead
  27. * @see Securities\AccruedInterest::periodic()
  28. *
  29. * @param mixed $issue the security's issue date
  30. * @param mixed $firstInterest the security's first interest date
  31. * @param mixed $settlement The security's settlement date.
  32. * The security settlement date is the date after the issue date
  33. * when the security is traded to the buyer.
  34. * @param mixed $rate the security's annual coupon rate
  35. * @param mixed $parValue The security's par value.
  36. * If you omit par, ACCRINT uses $1,000.
  37. * @param mixed $frequency The number of coupon payments per year.
  38. * Valid frequency values are:
  39. * 1 Annual
  40. * 2 Semi-Annual
  41. * 4 Quarterly
  42. * @param mixed $basis The type of day count to use.
  43. * 0 or omitted US (NASD) 30/360
  44. * 1 Actual/actual
  45. * 2 Actual/360
  46. * 3 Actual/365
  47. * 4 European 30/360
  48. * @param mixed $calcMethod
  49. * If true, use Issue to Settlement
  50. * If false, use FirstInterest to Settlement
  51. *
  52. * @return float|string Result, or a string containing an error
  53. */
  54. public static function ACCRINT(
  55. $issue,
  56. $firstInterest,
  57. $settlement,
  58. $rate,
  59. $parValue = 1000,
  60. $frequency = 1,
  61. $basis = 0,
  62. $calcMethod = true
  63. ) {
  64. return Securities\AccruedInterest::periodic(
  65. $issue,
  66. $firstInterest,
  67. $settlement,
  68. $rate,
  69. $parValue,
  70. $frequency,
  71. $basis,
  72. $calcMethod
  73. );
  74. }
  75. /**
  76. * ACCRINTM.
  77. *
  78. * Returns the accrued interest for a security that pays interest at maturity.
  79. *
  80. * Excel Function:
  81. * ACCRINTM(issue,settlement,rate[,par[,basis]])
  82. *
  83. * @deprecated 1.18.0
  84. * Use the atMaturity() method in the Financial\Securities\AccruedInterest class instead
  85. * @see Financial\Securities\AccruedInterest::atMaturity()
  86. *
  87. * @param mixed $issue The security's issue date
  88. * @param mixed $settlement The security's settlement (or maturity) date
  89. * @param mixed $rate The security's annual coupon rate
  90. * @param mixed $parValue The security's par value.
  91. * If you omit par, ACCRINT uses $1,000.
  92. * @param mixed $basis The type of day count to use.
  93. * 0 or omitted US (NASD) 30/360
  94. * 1 Actual/actual
  95. * 2 Actual/360
  96. * 3 Actual/365
  97. * 4 European 30/360
  98. *
  99. * @return float|string Result, or a string containing an error
  100. */
  101. public static function ACCRINTM($issue, $settlement, $rate, $parValue = 1000, $basis = 0)
  102. {
  103. return Securities\AccruedInterest::atMaturity($issue, $settlement, $rate, $parValue, $basis);
  104. }
  105. /**
  106. * AMORDEGRC.
  107. *
  108. * Returns the depreciation for each accounting period.
  109. * This function is provided for the French accounting system. If an asset is purchased in
  110. * the middle of the accounting period, the prorated depreciation is taken into account.
  111. * The function is similar to AMORLINC, except that a depreciation coefficient is applied in
  112. * the calculation depending on the life of the assets.
  113. * This function will return the depreciation until the last period of the life of the assets
  114. * or until the cumulated value of depreciation is greater than the cost of the assets minus
  115. * the salvage value.
  116. *
  117. * Excel Function:
  118. * AMORDEGRC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
  119. *
  120. * @deprecated 1.18.0
  121. * Use the AMORDEGRC() method in the Financial\Amortization class instead
  122. * @see Financial\Amortization::AMORDEGRC()
  123. *
  124. * @param float $cost The cost of the asset
  125. * @param mixed $purchased Date of the purchase of the asset
  126. * @param mixed $firstPeriod Date of the end of the first period
  127. * @param mixed $salvage The salvage value at the end of the life of the asset
  128. * @param float $period The period
  129. * @param float $rate Rate of depreciation
  130. * @param int $basis The type of day count to use.
  131. * 0 or omitted US (NASD) 30/360
  132. * 1 Actual/actual
  133. * 2 Actual/360
  134. * 3 Actual/365
  135. * 4 European 30/360
  136. *
  137. * @return float|string (string containing the error type if there is an error)
  138. */
  139. public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0)
  140. {
  141. return Amortization::AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis);
  142. }
  143. /**
  144. * AMORLINC.
  145. *
  146. * Returns the depreciation for each accounting period.
  147. * This function is provided for the French accounting system. If an asset is purchased in
  148. * the middle of the accounting period, the prorated depreciation is taken into account.
  149. *
  150. * Excel Function:
  151. * AMORLINC(cost,purchased,firstPeriod,salvage,period,rate[,basis])
  152. *
  153. * @deprecated 1.18.0
  154. * Use the AMORLINC() method in the Financial\Amortization class instead
  155. * @see Financial\Amortization::AMORLINC()
  156. *
  157. * @param float $cost The cost of the asset
  158. * @param mixed $purchased Date of the purchase of the asset
  159. * @param mixed $firstPeriod Date of the end of the first period
  160. * @param mixed $salvage The salvage value at the end of the life of the asset
  161. * @param float $period The period
  162. * @param float $rate Rate of depreciation
  163. * @param int $basis The type of day count to use.
  164. * 0 or omitted US (NASD) 30/360
  165. * 1 Actual/actual
  166. * 2 Actual/360
  167. * 3 Actual/365
  168. * 4 European 30/360
  169. *
  170. * @return float|string (string containing the error type if there is an error)
  171. */
  172. public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0)
  173. {
  174. return Amortization::AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis);
  175. }
  176. /**
  177. * COUPDAYBS.
  178. *
  179. * Returns the number of days from the beginning of the coupon period to the settlement date.
  180. *
  181. * Excel Function:
  182. * COUPDAYBS(settlement,maturity,frequency[,basis])
  183. *
  184. * @deprecated 1.18.0
  185. * Use the COUPDAYBS() method in the Financial\Coupons class instead
  186. * @see Financial\Coupons::COUPDAYBS()
  187. *
  188. * @param mixed $settlement The security's settlement date.
  189. * The security settlement date is the date after the issue
  190. * date when the security is traded to the buyer.
  191. * @param mixed $maturity The security's maturity date.
  192. * The maturity date is the date when the security expires.
  193. * @param int $frequency the number of coupon payments per year.
  194. * Valid frequency values are:
  195. * 1 Annual
  196. * 2 Semi-Annual
  197. * 4 Quarterly
  198. * @param int $basis The type of day count to use.
  199. * 0 or omitted US (NASD) 30/360
  200. * 1 Actual/actual
  201. * 2 Actual/360
  202. * 3 Actual/365
  203. * 4 European 30/360
  204. *
  205. * @return float|string
  206. */
  207. public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = 0)
  208. {
  209. return Coupons::COUPDAYBS($settlement, $maturity, $frequency, $basis);
  210. }
  211. /**
  212. * COUPDAYS.
  213. *
  214. * Returns the number of days in the coupon period that contains the settlement date.
  215. *
  216. * Excel Function:
  217. * COUPDAYS(settlement,maturity,frequency[,basis])
  218. *
  219. * @deprecated 1.18.0
  220. * Use the COUPDAYS() method in the Financial\Coupons class instead
  221. * @see Financial\Coupons::COUPDAYS()
  222. *
  223. * @param mixed $settlement The security's settlement date.
  224. * The security settlement date is the date after the issue
  225. * date when the security is traded to the buyer.
  226. * @param mixed $maturity The security's maturity date.
  227. * The maturity date is the date when the security expires.
  228. * @param mixed $frequency the number of coupon payments per year.
  229. * Valid frequency values are:
  230. * 1 Annual
  231. * 2 Semi-Annual
  232. * 4 Quarterly
  233. * @param int $basis The type of day count to use.
  234. * 0 or omitted US (NASD) 30/360
  235. * 1 Actual/actual
  236. * 2 Actual/360
  237. * 3 Actual/365
  238. * 4 European 30/360
  239. *
  240. * @return float|string
  241. */
  242. public static function COUPDAYS($settlement, $maturity, $frequency, $basis = 0)
  243. {
  244. return Coupons::COUPDAYS($settlement, $maturity, $frequency, $basis);
  245. }
  246. /**
  247. * COUPDAYSNC.
  248. *
  249. * Returns the number of days from the settlement date to the next coupon date.
  250. *
  251. * Excel Function:
  252. * COUPDAYSNC(settlement,maturity,frequency[,basis])
  253. *
  254. * @deprecated 1.18.0
  255. * Use the COUPDAYSNC() method in the Financial\Coupons class instead
  256. * @see Financial\Coupons::COUPDAYSNC()
  257. *
  258. * @param mixed $settlement The security's settlement date.
  259. * The security settlement date is the date after the issue
  260. * date when the security is traded to the buyer.
  261. * @param mixed $maturity The security's maturity date.
  262. * The maturity date is the date when the security expires.
  263. * @param mixed $frequency the number of coupon payments per year.
  264. * Valid frequency values are:
  265. * 1 Annual
  266. * 2 Semi-Annual
  267. * 4 Quarterly
  268. * @param int $basis The type of day count to use.
  269. * 0 or omitted US (NASD) 30/360
  270. * 1 Actual/actual
  271. * 2 Actual/360
  272. * 3 Actual/365
  273. * 4 European 30/360
  274. *
  275. * @return float|string
  276. */
  277. public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = 0)
  278. {
  279. return Coupons::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
  280. }
  281. /**
  282. * COUPNCD.
  283. *
  284. * Returns the next coupon date after the settlement date.
  285. *
  286. * Excel Function:
  287. * COUPNCD(settlement,maturity,frequency[,basis])
  288. *
  289. * @deprecated 1.18.0
  290. * Use the COUPNCD() method in the Financial\Coupons class instead
  291. * @see Financial\Coupons::COUPNCD()
  292. *
  293. * @param mixed $settlement The security's settlement date.
  294. * The security settlement date is the date after the issue
  295. * date when the security is traded to the buyer.
  296. * @param mixed $maturity The security's maturity date.
  297. * The maturity date is the date when the security expires.
  298. * @param mixed $frequency the number of coupon payments per year.
  299. * Valid frequency values are:
  300. * 1 Annual
  301. * 2 Semi-Annual
  302. * 4 Quarterly
  303. * @param int $basis The type of day count to use.
  304. * 0 or omitted US (NASD) 30/360
  305. * 1 Actual/actual
  306. * 2 Actual/360
  307. * 3 Actual/365
  308. * 4 European 30/360
  309. *
  310. * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
  311. * depending on the value of the ReturnDateType flag
  312. */
  313. public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0)
  314. {
  315. return Coupons::COUPNCD($settlement, $maturity, $frequency, $basis);
  316. }
  317. /**
  318. * COUPNUM.
  319. *
  320. * Returns the number of coupons payable between the settlement date and maturity date,
  321. * rounded up to the nearest whole coupon.
  322. *
  323. * Excel Function:
  324. * COUPNUM(settlement,maturity,frequency[,basis])
  325. *
  326. * @deprecated 1.18.0
  327. * Use the COUPNUM() method in the Financial\Coupons class instead
  328. * @see Financial\Coupons::COUPNUM()
  329. *
  330. * @param mixed $settlement The security's settlement date.
  331. * The security settlement date is the date after the issue
  332. * date when the security is traded to the buyer.
  333. * @param mixed $maturity The security's maturity date.
  334. * The maturity date is the date when the security expires.
  335. * @param mixed $frequency the number of coupon payments per year.
  336. * Valid frequency values are:
  337. * 1 Annual
  338. * 2 Semi-Annual
  339. * 4 Quarterly
  340. * @param int $basis The type of day count to use.
  341. * 0 or omitted US (NASD) 30/360
  342. * 1 Actual/actual
  343. * 2 Actual/360
  344. * 3 Actual/365
  345. * 4 European 30/360
  346. *
  347. * @return int|string
  348. */
  349. public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0)
  350. {
  351. return Coupons::COUPNUM($settlement, $maturity, $frequency, $basis);
  352. }
  353. /**
  354. * COUPPCD.
  355. *
  356. * Returns the previous coupon date before the settlement date.
  357. *
  358. * Excel Function:
  359. * COUPPCD(settlement,maturity,frequency[,basis])
  360. *
  361. * @deprecated 1.18.0
  362. * Use the COUPPCD() method in the Financial\Coupons class instead
  363. * @see Financial\Coupons::COUPPCD()
  364. *
  365. * @param mixed $settlement The security's settlement date.
  366. * The security settlement date is the date after the issue
  367. * date when the security is traded to the buyer.
  368. * @param mixed $maturity The security's maturity date.
  369. * The maturity date is the date when the security expires.
  370. * @param mixed $frequency the number of coupon payments per year.
  371. * Valid frequency values are:
  372. * 1 Annual
  373. * 2 Semi-Annual
  374. * 4 Quarterly
  375. * @param int $basis The type of day count to use.
  376. * 0 or omitted US (NASD) 30/360
  377. * 1 Actual/actual
  378. * 2 Actual/360
  379. * 3 Actual/365
  380. * 4 European 30/360
  381. *
  382. * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
  383. * depending on the value of the ReturnDateType flag
  384. */
  385. public static function COUPPCD($settlement, $maturity, $frequency, $basis = 0)
  386. {
  387. return Coupons::COUPPCD($settlement, $maturity, $frequency, $basis);
  388. }
  389. /**
  390. * CUMIPMT.
  391. *
  392. * Returns the cumulative interest paid on a loan between the start and end periods.
  393. *
  394. * Excel Function:
  395. * CUMIPMT(rate,nper,pv,start,end[,type])
  396. *
  397. * @deprecated 1.18.0
  398. * Use the interest() method in the Financial\CashFlow\Constant\Periodic\Cumulative class instead
  399. * @see Financial\CashFlow\Constant\Periodic\Cumulative::interest()
  400. *
  401. * @param float $rate The Interest rate
  402. * @param int $nper The total number of payment periods
  403. * @param float $pv Present Value
  404. * @param int $start The first period in the calculation.
  405. * Payment periods are numbered beginning with 1.
  406. * @param int $end the last period in the calculation
  407. * @param int $type A number 0 or 1 and indicates when payments are due:
  408. * 0 or omitted At the end of the period.
  409. * 1 At the beginning of the period.
  410. *
  411. * @return float|string
  412. */
  413. public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0)
  414. {
  415. return Financial\CashFlow\Constant\Periodic\Cumulative::interest($rate, $nper, $pv, $start, $end, $type);
  416. }
  417. /**
  418. * CUMPRINC.
  419. *
  420. * Returns the cumulative principal paid on a loan between the start and end periods.
  421. *
  422. * Excel Function:
  423. * CUMPRINC(rate,nper,pv,start,end[,type])
  424. *
  425. * @deprecated 1.18.0
  426. * Use the principal() method in the Financial\CashFlow\Constant\Periodic\Cumulative class instead
  427. * @see Financial\CashFlow\Constant\Periodic\Cumulative::principal()
  428. *
  429. * @param float $rate The Interest rate
  430. * @param int $nper The total number of payment periods
  431. * @param float $pv Present Value
  432. * @param int $start The first period in the calculation.
  433. * Payment periods are numbered beginning with 1.
  434. * @param int $end the last period in the calculation
  435. * @param int $type A number 0 or 1 and indicates when payments are due:
  436. * 0 or omitted At the end of the period.
  437. * 1 At the beginning of the period.
  438. *
  439. * @return float|string
  440. */
  441. public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0)
  442. {
  443. return Financial\CashFlow\Constant\Periodic\Cumulative::principal($rate, $nper, $pv, $start, $end, $type);
  444. }
  445. /**
  446. * DB.
  447. *
  448. * Returns the depreciation of an asset for a specified period using the
  449. * fixed-declining balance method.
  450. * This form of depreciation is used if you want to get a higher depreciation value
  451. * at the beginning of the depreciation (as opposed to linear depreciation). The
  452. * depreciation value is reduced with every depreciation period by the depreciation
  453. * already deducted from the initial cost.
  454. *
  455. * Excel Function:
  456. * DB(cost,salvage,life,period[,month])
  457. *
  458. * @deprecated 1.18.0
  459. * Use the DB() method in the Financial\Depreciation class instead
  460. * @see Financial\Depreciation::DB()
  461. *
  462. * @param float $cost Initial cost of the asset
  463. * @param float $salvage Value at the end of the depreciation.
  464. * (Sometimes called the salvage value of the asset)
  465. * @param int $life Number of periods over which the asset is depreciated.
  466. * (Sometimes called the useful life of the asset)
  467. * @param int $period The period for which you want to calculate the
  468. * depreciation. Period must use the same units as life.
  469. * @param int $month Number of months in the first year. If month is omitted,
  470. * it defaults to 12.
  471. *
  472. * @return float|string
  473. */
  474. public static function DB($cost, $salvage, $life, $period, $month = 12)
  475. {
  476. return Depreciation::DB($cost, $salvage, $life, $period, $month);
  477. }
  478. /**
  479. * DDB.
  480. *
  481. * Returns the depreciation of an asset for a specified period using the
  482. * double-declining balance method or some other method you specify.
  483. *
  484. * Excel Function:
  485. * DDB(cost,salvage,life,period[,factor])
  486. *
  487. * @deprecated 1.18.0
  488. * Use the DDB() method in the Financial\Depreciation class instead
  489. * @see Financial\Depreciation::DDB()
  490. *
  491. * @param float $cost Initial cost of the asset
  492. * @param float $salvage Value at the end of the depreciation.
  493. * (Sometimes called the salvage value of the asset)
  494. * @param int $life Number of periods over which the asset is depreciated.
  495. * (Sometimes called the useful life of the asset)
  496. * @param int $period The period for which you want to calculate the
  497. * depreciation. Period must use the same units as life.
  498. * @param float $factor The rate at which the balance declines.
  499. * If factor is omitted, it is assumed to be 2 (the
  500. * double-declining balance method).
  501. *
  502. * @return float|string
  503. */
  504. public static function DDB($cost, $salvage, $life, $period, $factor = 2.0)
  505. {
  506. return Depreciation::DDB($cost, $salvage, $life, $period, $factor);
  507. }
  508. /**
  509. * DISC.
  510. *
  511. * Returns the discount rate for a security.
  512. *
  513. * Excel Function:
  514. * DISC(settlement,maturity,price,redemption[,basis])
  515. *
  516. * @deprecated 1.18.0
  517. * Use the discount() method in the Financial\Securities\Rates class instead
  518. * @see Financial\Securities\Rates::discount()
  519. *
  520. * @param mixed $settlement The security's settlement date.
  521. * The security settlement date is the date after the issue
  522. * date when the security is traded to the buyer.
  523. * @param mixed $maturity The security's maturity date.
  524. * The maturity date is the date when the security expires.
  525. * @param mixed $price The security's price per $100 face value
  526. * @param int $redemption The security's redemption value per $100 face value
  527. * @param int $basis The type of day count to use.
  528. * 0 or omitted US (NASD) 30/360
  529. * 1 Actual/actual
  530. * 2 Actual/360
  531. * 3 Actual/365
  532. * 4 European 30/360
  533. *
  534. * @return float|string
  535. */
  536. public static function DISC($settlement, $maturity, $price, $redemption, $basis = 0)
  537. {
  538. return Financial\Securities\Rates::discount($settlement, $maturity, $price, $redemption, $basis);
  539. }
  540. /**
  541. * DOLLARDE.
  542. *
  543. * Converts a dollar price expressed as an integer part and a fraction
  544. * part into a dollar price expressed as a decimal number.
  545. * Fractional dollar numbers are sometimes used for security prices.
  546. *
  547. * Excel Function:
  548. * DOLLARDE(fractional_dollar,fraction)
  549. *
  550. * @deprecated 1.18.0
  551. * Use the decimal() method in the Financial\Dollar class instead
  552. * @see Financial\Dollar::decimal()
  553. *
  554. * @param array|float $fractional_dollar Fractional Dollar
  555. * @param array|int $fraction Fraction
  556. *
  557. * @return array|float|string
  558. */
  559. public static function DOLLARDE($fractional_dollar = null, $fraction = 0)
  560. {
  561. return Dollar::decimal($fractional_dollar, $fraction);
  562. }
  563. /**
  564. * DOLLARFR.
  565. *
  566. * Converts a dollar price expressed as a decimal number into a dollar price
  567. * expressed as a fraction.
  568. * Fractional dollar numbers are sometimes used for security prices.
  569. *
  570. * Excel Function:
  571. * DOLLARFR(decimal_dollar,fraction)
  572. *
  573. * @deprecated 1.18.0
  574. * Use the fractional() method in the Financial\Dollar class instead
  575. * @see Financial\Dollar::fractional()
  576. *
  577. * @param array|float $decimal_dollar Decimal Dollar
  578. * @param array|int $fraction Fraction
  579. *
  580. * @return array|float|string
  581. */
  582. public static function DOLLARFR($decimal_dollar = null, $fraction = 0)
  583. {
  584. return Dollar::fractional($decimal_dollar, $fraction);
  585. }
  586. /**
  587. * EFFECT.
  588. *
  589. * Returns the effective interest rate given the nominal rate and the number of
  590. * compounding payments per year.
  591. *
  592. * Excel Function:
  593. * EFFECT(nominal_rate,npery)
  594. *
  595. * @deprecated 1.18.0
  596. * Use the effective() method in the Financial\InterestRate class instead
  597. * @see Financial\InterestRate::effective()
  598. *
  599. * @param float $nominalRate Nominal interest rate
  600. * @param int $periodsPerYear Number of compounding payments per year
  601. *
  602. * @return float|string
  603. */
  604. public static function EFFECT($nominalRate = 0, $periodsPerYear = 0)
  605. {
  606. return Financial\InterestRate::effective($nominalRate, $periodsPerYear);
  607. }
  608. /**
  609. * FV.
  610. *
  611. * Returns the Future Value of a cash flow with constant payments and interest rate (annuities).
  612. *
  613. * Excel Function:
  614. * FV(rate,nper,pmt[,pv[,type]])
  615. *
  616. * @deprecated 1.18.0
  617. * Use the futureValue() method in the Financial\CashFlow\Constant\Periodic class instead
  618. * @see Financial\CashFlow\Constant\Periodic::futureValue()
  619. *
  620. * @param float $rate The interest rate per period
  621. * @param int $nper Total number of payment periods in an annuity
  622. * @param float $pmt The payment made each period: it cannot change over the
  623. * life of the annuity. Typically, pmt contains principal
  624. * and interest but no other fees or taxes.
  625. * @param float $pv present Value, or the lump-sum amount that a series of
  626. * future payments is worth right now
  627. * @param int $type A number 0 or 1 and indicates when payments are due:
  628. * 0 or omitted At the end of the period.
  629. * 1 At the beginning of the period.
  630. *
  631. * @return float|string
  632. */
  633. public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0)
  634. {
  635. return Financial\CashFlow\Constant\Periodic::futureValue($rate, $nper, $pmt, $pv, $type);
  636. }
  637. /**
  638. * FVSCHEDULE.
  639. *
  640. * Returns the future value of an initial principal after applying a series of compound interest rates.
  641. * Use FVSCHEDULE to calculate the future value of an investment with a variable or adjustable rate.
  642. *
  643. * Excel Function:
  644. * FVSCHEDULE(principal,schedule)
  645. *
  646. * @deprecated 1.18.0
  647. * Use the futureValue() method in the Financial\CashFlow\Single class instead
  648. * @see Financial\CashFlow\Single::futureValue()
  649. *
  650. * @param float $principal the present value
  651. * @param float[] $schedule an array of interest rates to apply
  652. *
  653. * @return float|string
  654. */
  655. public static function FVSCHEDULE($principal, $schedule)
  656. {
  657. return Financial\CashFlow\Single::futureValue($principal, $schedule);
  658. }
  659. /**
  660. * INTRATE.
  661. *
  662. * Returns the interest rate for a fully invested security.
  663. *
  664. * Excel Function:
  665. * INTRATE(settlement,maturity,investment,redemption[,basis])
  666. *
  667. * @deprecated 1.18.0
  668. * Use the interest() method in the Financial\Securities\Rates class instead
  669. * @see Financial\Securities\Rates::interest()
  670. *
  671. * @param mixed $settlement The security's settlement date.
  672. * The security settlement date is the date after the issue date when the security
  673. * is traded to the buyer.
  674. * @param mixed $maturity The security's maturity date.
  675. * The maturity date is the date when the security expires.
  676. * @param int $investment the amount invested in the security
  677. * @param int $redemption the amount to be received at maturity
  678. * @param int $basis The type of day count to use.
  679. * 0 or omitted US (NASD) 30/360
  680. * 1 Actual/actual
  681. * 2 Actual/360
  682. * 3 Actual/365
  683. * 4 European 30/360
  684. *
  685. * @return float|string
  686. */
  687. public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis = 0)
  688. {
  689. return Financial\Securities\Rates::interest($settlement, $maturity, $investment, $redemption, $basis);
  690. }
  691. /**
  692. * IPMT.
  693. *
  694. * Returns the interest payment for a given period for an investment based on periodic, constant payments
  695. * and a constant interest rate.
  696. *
  697. * Excel Function:
  698. * IPMT(rate,per,nper,pv[,fv][,type])
  699. *
  700. * @deprecated 1.18.0
  701. * Use the payment() method in the Financial\CashFlow\Constant\Periodic\Interest class instead
  702. * @see Financial\CashFlow\Constant\Periodic\Interest::payment()
  703. *
  704. * @param float $rate Interest rate per period
  705. * @param int $per Period for which we want to find the interest
  706. * @param int $nper Number of periods
  707. * @param float $pv Present Value
  708. * @param float $fv Future Value
  709. * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
  710. *
  711. * @return float|string
  712. */
  713. public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0)
  714. {
  715. return Financial\CashFlow\Constant\Periodic\Interest::payment($rate, $per, $nper, $pv, $fv, $type);
  716. }
  717. /**
  718. * IRR.
  719. *
  720. * Returns the internal rate of return for a series of cash flows represented by the numbers in values.
  721. * These cash flows do not have to be even, as they would be for an annuity. However, the cash flows must occur
  722. * at regular intervals, such as monthly or annually. The internal rate of return is the interest rate received
  723. * for an investment consisting of payments (negative values) and income (positive values) that occur at regular
  724. * periods.
  725. *
  726. * Excel Function:
  727. * IRR(values[,guess])
  728. *
  729. * @deprecated 1.18.0
  730. * Use the rate() method in the Financial\CashFlow\Variable\Periodic class instead
  731. * @see Financial\CashFlow\Variable\Periodic::rate()
  732. *
  733. * @param mixed $values An array or a reference to cells that contain numbers for which you want
  734. * to calculate the internal rate of return.
  735. * Values must contain at least one positive value and one negative value to
  736. * calculate the internal rate of return.
  737. * @param mixed $guess A number that you guess is close to the result of IRR
  738. *
  739. * @return float|string
  740. */
  741. public static function IRR($values, $guess = 0.1)
  742. {
  743. return Financial\CashFlow\Variable\Periodic::rate($values, $guess);
  744. }
  745. /**
  746. * ISPMT.
  747. *
  748. * Returns the interest payment for an investment based on an interest rate and a constant payment schedule.
  749. *
  750. * Excel Function:
  751. * =ISPMT(interest_rate, period, number_payments, pv)
  752. *
  753. * @deprecated 1.18.0
  754. * Use the schedulePayment() method in the Financial\CashFlow\Constant\Periodic\Interest class instead
  755. * @see Financial\CashFlow\Constant\Periodic\Interest::schedulePayment()
  756. *
  757. * interest_rate is the interest rate for the investment
  758. *
  759. * period is the period to calculate the interest rate. It must be betweeen 1 and number_payments.
  760. *
  761. * number_payments is the number of payments for the annuity
  762. *
  763. * pv is the loan amount or present value of the payments
  764. *
  765. * @param array $args
  766. *
  767. * @return float|string
  768. */
  769. public static function ISPMT(...$args)
  770. {
  771. return Financial\CashFlow\Constant\Periodic\Interest::schedulePayment(...$args);
  772. }
  773. /**
  774. * MIRR.
  775. *
  776. * Returns the modified internal rate of return for a series of periodic cash flows. MIRR considers both
  777. * the cost of the investment and the interest received on reinvestment of cash.
  778. *
  779. * Excel Function:
  780. * MIRR(values,finance_rate, reinvestment_rate)
  781. *
  782. * @deprecated 1.18.0
  783. * Use the modifiedRate() method in the Financial\CashFlow\Variable\Periodic class instead
  784. * @see Financial\CashFlow\Variable\Periodic::modifiedRate()
  785. *
  786. * @param mixed $values An array or a reference to cells that contain a series of payments and
  787. * income occurring at regular intervals.
  788. * Payments are negative value, income is positive values.
  789. * @param mixed $finance_rate The interest rate you pay on the money used in the cash flows
  790. * @param mixed $reinvestment_rate The interest rate you receive on the cash flows as you reinvest them
  791. *
  792. * @return float|string Result, or a string containing an error
  793. */
  794. public static function MIRR($values, $finance_rate, $reinvestment_rate)
  795. {
  796. return Financial\CashFlow\Variable\Periodic::modifiedRate($values, $finance_rate, $reinvestment_rate);
  797. }
  798. /**
  799. * NOMINAL.
  800. *
  801. * Returns the nominal interest rate given the effective rate and the number of compounding payments per year.
  802. *
  803. * Excel Function:
  804. * NOMINAL(effect_rate, npery)
  805. *
  806. * @deprecated 1.18.0
  807. * Use the nominal() method in the Financial\InterestRate class instead
  808. * @see Financial\InterestRate::nominal()
  809. *
  810. * @param float $effectiveRate Effective interest rate
  811. * @param int $periodsPerYear Number of compounding payments per year
  812. *
  813. * @return float|string Result, or a string containing an error
  814. */
  815. public static function NOMINAL($effectiveRate = 0, $periodsPerYear = 0)
  816. {
  817. return InterestRate::nominal($effectiveRate, $periodsPerYear);
  818. }
  819. /**
  820. * NPER.
  821. *
  822. * Returns the number of periods for a cash flow with constant periodic payments (annuities), and interest rate.
  823. *
  824. * @deprecated 1.18.0
  825. * Use the periods() method in the Financial\CashFlow\Constant\Periodic class instead
  826. * @see Financial\CashFlow\Constant\Periodic::periods()
  827. *
  828. * @param float $rate Interest rate per period
  829. * @param int $pmt Periodic payment (annuity)
  830. * @param float $pv Present Value
  831. * @param float $fv Future Value
  832. * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
  833. *
  834. * @return float|string Result, or a string containing an error
  835. */
  836. public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0)
  837. {
  838. return Financial\CashFlow\Constant\Periodic::periods($rate, $pmt, $pv, $fv, $type);
  839. }
  840. /**
  841. * NPV.
  842. *
  843. * Returns the Net Present Value of a cash flow series given a discount rate.
  844. *
  845. * @deprecated 1.18.0
  846. * Use the presentValue() method in the Financial\CashFlow\Variable\Periodic class instead
  847. * @see Financial\CashFlow\Variable\Periodic::presentValue()
  848. *
  849. * @param array $args
  850. *
  851. * @return float
  852. */
  853. public static function NPV(...$args)
  854. {
  855. return Financial\CashFlow\Variable\Periodic::presentValue(...$args);
  856. }
  857. /**
  858. * PDURATION.
  859. *
  860. * Calculates the number of periods required for an investment to reach a specified value.
  861. *
  862. * @deprecated 1.18.0
  863. * Use the periods() method in the Financial\CashFlow\Single class instead
  864. * @see Financial\CashFlow\Single::periods()
  865. *
  866. * @param float $rate Interest rate per period
  867. * @param float $pv Present Value
  868. * @param float $fv Future Value
  869. *
  870. * @return float|string Result, or a string containing an error
  871. */
  872. public static function PDURATION($rate = 0, $pv = 0, $fv = 0)
  873. {
  874. return Financial\CashFlow\Single::periods($rate, $pv, $fv);
  875. }
  876. /**
  877. * PMT.
  878. *
  879. * Returns the constant payment (annuity) for a cash flow with a constant interest rate.
  880. *
  881. * @deprecated 1.18.0
  882. * Use the annuity() method in the Financial\CashFlow\Constant\Periodic\Payments class instead
  883. * @see Financial\CashFlow\Constant\Periodic\Payments::annuity()
  884. *
  885. * @param float $rate Interest rate per period
  886. * @param int $nper Number of periods
  887. * @param float $pv Present Value
  888. * @param float $fv Future Value
  889. * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
  890. *
  891. * @return float|string Result, or a string containing an error
  892. */
  893. public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0)
  894. {
  895. return Financial\CashFlow\Constant\Periodic\Payments::annuity($rate, $nper, $pv, $fv, $type);
  896. }
  897. /**
  898. * PPMT.
  899. *
  900. * Returns the interest payment for a given period for an investment based on periodic, constant payments
  901. * and a constant interest rate.
  902. *
  903. * @deprecated 1.18.0
  904. * Use the interestPayment() method in the Financial\CashFlow\Constant\Periodic\Payments class instead
  905. * @see Financial\CashFlow\Constant\Periodic\Payments::interestPayment()
  906. *
  907. * @param float $rate Interest rate per period
  908. * @param int $per Period for which we want to find the interest
  909. * @param int $nper Number of periods
  910. * @param float $pv Present Value
  911. * @param float $fv Future Value
  912. * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
  913. *
  914. * @return float|string Result, or a string containing an error
  915. */
  916. public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0)
  917. {
  918. return Financial\CashFlow\Constant\Periodic\Payments::interestPayment($rate, $per, $nper, $pv, $fv, $type);
  919. }
  920. /**
  921. * PRICE.
  922. *
  923. * Returns the price per $100 face value of a security that pays periodic interest.
  924. *
  925. * @deprecated 1.18.0
  926. * Use the price() method in the Financial\Securities\Price class instead
  927. * @see Financial\Securities\Price::price()
  928. *
  929. * @param mixed $settlement The security's settlement date.
  930. * The security settlement date is the date after the issue date when the security
  931. * is traded to the buyer.
  932. * @param mixed $maturity The security's maturity date.
  933. * The maturity date is the date when the security expires.
  934. * @param float $rate the security's annual coupon rate
  935. * @param float $yield the security's annual yield
  936. * @param float $redemption The number of coupon payments per year.
  937. * For annual payments, frequency = 1;
  938. * for semiannual, frequency = 2;
  939. * for quarterly, frequency = 4.
  940. * @param int $frequency
  941. * @param int $basis The type of day count to use.
  942. * 0 or omitted US (NASD) 30/360
  943. * 1 Actual/actual
  944. * 2 Actual/360
  945. * 3 Actual/365
  946. * 4 European 30/360
  947. *
  948. * @return float|string Result, or a string containing an error
  949. */
  950. public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0)
  951. {
  952. return Securities\Price::price($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis);
  953. }
  954. /**
  955. * PRICEDISC.
  956. *
  957. * Returns the price per $100 face value of a discounted security.
  958. *
  959. * @deprecated 1.18.0
  960. * Use the priceDiscounted() method in the Financial\Securities\Price class instead
  961. * @see Financial\Securities\Price::priceDiscounted()
  962. *
  963. * @param mixed $settlement The security's settlement date.
  964. * The security settlement date is the date after the issue date when the security
  965. * is traded to the buyer.
  966. * @param mixed $maturity The security's maturity date.
  967. * The maturity date is the date when the security expires.
  968. * @param mixed $discount The security's discount rate
  969. * @param int $redemption The security's redemption value per $100 face value
  970. * @param int $basis The type of day count to use.
  971. * 0 or omitted US (NASD) 30/360
  972. * 1 Actual/actual
  973. * 2 Actual/360
  974. * 3 Actual/365
  975. * 4 European 30/360
  976. *
  977. * @return float|string Result, or a string containing an error
  978. */
  979. public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis = 0)
  980. {
  981. return Securities\Price::priceDiscounted($settlement, $maturity, $discount, $redemption, $basis);
  982. }
  983. /**
  984. * PRICEMAT.
  985. *
  986. * Returns the price per $100 face value of a security that pays interest at maturity.
  987. *
  988. * @deprecated 1.18.0
  989. * Use the priceAtMaturity() method in the Financial\Securities\Price class instead
  990. * @see Financial\Securities\Price::priceAtMaturity()
  991. *
  992. * @param mixed $settlement The security's settlement date.
  993. * The security's settlement date is the date after the issue date when the security
  994. * is traded to the buyer.
  995. * @param mixed $maturity The security's maturity date.
  996. * The maturity date is the date when the security expires.
  997. * @param mixed $issue The security's issue date
  998. * @param mixed $rate The security's interest rate at date of issue
  999. * @param mixed $yield The security's annual yield
  1000. * @param int $basis The type of day count to use.
  1001. * 0 or omitted US (NASD) 30/360
  1002. * 1 Actual/actual
  1003. * 2 Actual/360
  1004. * 3 Actual/365
  1005. * 4 European 30/360
  1006. *
  1007. * @return float|string Result, or a string containing an error
  1008. */
  1009. public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis = 0)
  1010. {
  1011. return Securities\Price::priceAtMaturity($settlement, $maturity, $issue, $rate, $yield, $basis);
  1012. }
  1013. /**
  1014. * PV.
  1015. *
  1016. * Returns the Present Value of a cash flow with constant payments and interest rate (annuities).
  1017. *
  1018. * @deprecated 1.18.0
  1019. * Use the presentValue() method in the Financial\CashFlow\Constant\Periodic class instead
  1020. * @see Financial\CashFlow\Constant\Periodic::presentValue()
  1021. *
  1022. * @param float $rate Interest rate per period
  1023. * @param int $nper Number of periods
  1024. * @param float $pmt Periodic payment (annuity)
  1025. * @param float $fv Future Value
  1026. * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
  1027. *
  1028. * @return float|string Result, or a string containing an error
  1029. */
  1030. public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0)
  1031. {
  1032. return Financial\CashFlow\Constant\Periodic::presentValue($rate, $nper, $pmt, $fv, $type);
  1033. }
  1034. /**
  1035. * RATE.
  1036. *
  1037. * Returns the interest rate per period of an annuity.
  1038. * RATE is calculated by iteration and can have zero or more solutions.
  1039. * If the successive results of RATE do not converge to within 0.0000001 after 20 iterations,
  1040. * RATE returns the #NUM! error value.
  1041. *
  1042. * Excel Function:
  1043. * RATE(nper,pmt,pv[,fv[,type[,guess]]])
  1044. *
  1045. * @deprecated 1.18.0
  1046. * Use the rate() method in the Financial\CashFlow\Constant\Periodic\Interest class instead
  1047. * @see Financial\CashFlow\Constant\Periodic\Interest::rate()
  1048. *
  1049. * @param mixed $nper The total number of payment periods in an annuity
  1050. * @param mixed $pmt The payment made each period and cannot change over the life
  1051. * of the annuity.
  1052. * Typically, pmt includes principal and interest but no other
  1053. * fees or taxes.
  1054. * @param mixed $pv The present value - the total amount that a series of future
  1055. * payments is worth now
  1056. * @param mixed $fv The future value, or a cash balance you want to attain after
  1057. * the last payment is made. If fv is omitted, it is assumed
  1058. * to be 0 (the future value of a loan, for example, is 0).
  1059. * @param mixed $type A number 0 or 1 and indicates when payments are due:
  1060. * 0 or omitted At the end of the period.
  1061. * 1 At the beginning of the period.
  1062. * @param mixed $guess Your guess for what the rate will be.
  1063. * If you omit guess, it is assumed to be 10 percent.
  1064. *
  1065. * @return float|string
  1066. */
  1067. public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1)
  1068. {
  1069. return Financial\CashFlow\Constant\Periodic\Interest::rate($nper, $pmt, $pv, $fv, $type, $guess);
  1070. }
  1071. /**
  1072. * RECEIVED.
  1073. *
  1074. * Returns the amount received at maturity for a fully invested Security.
  1075. *
  1076. * @deprecated 1.18.0
  1077. * Use the received() method in the Financial\Securities\Price class instead
  1078. * @see Financial\Securities\Price::received()
  1079. *
  1080. * @param mixed $settlement The security's settlement date.
  1081. * The security settlement date is the date after the issue date when the security
  1082. * is traded to the buyer.
  1083. * @param mixed $maturity The security's maturity date.
  1084. * The maturity date is the date when the security expires.
  1085. * @param mixed $investment The amount invested in the security
  1086. * @param mixed $discount The security's discount rate
  1087. * @param mixed $basis The type of day count to use.
  1088. * 0 or omitted US (NASD) 30/360
  1089. * 1 Actual/actual
  1090. * 2 Actual/360
  1091. * 3 Actual/365
  1092. * 4 European 30/360
  1093. *
  1094. * @return float|string Result, or a string containing an error
  1095. */
  1096. public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis = 0)
  1097. {
  1098. return Financial\Securities\Price::received($settlement, $maturity, $investment, $discount, $basis);
  1099. }
  1100. /**
  1101. * RRI.
  1102. *
  1103. * Calculates the interest rate required for an investment to grow to a specified future value .
  1104. *
  1105. * @deprecated 1.18.0
  1106. * Use the interestRate() method in the Financial\CashFlow\Single class instead
  1107. * @see Financial\CashFlow\Single::interestRate()
  1108. *
  1109. * @param float $nper The number of periods over which the investment is made
  1110. * @param float $pv Present Value
  1111. * @param float $fv Future Value
  1112. *
  1113. * @return float|string Result, or a string containing an error
  1114. */
  1115. public static function RRI($nper = 0, $pv = 0, $fv = 0)
  1116. {
  1117. return Financial\CashFlow\Single::interestRate($nper, $pv, $fv);
  1118. }
  1119. /**
  1120. * SLN.
  1121. *
  1122. * Returns the straight-line depreciation of an asset for one period
  1123. *
  1124. * @deprecated 1.18.0
  1125. * Use the SLN() method in the Financial\Depreciation class instead
  1126. * @see Financial\Depreciation::SLN()
  1127. *
  1128. * @param mixed $cost Initial cost of the asset
  1129. * @param mixed $salvage Value at the end of the depreciation
  1130. * @param mixed $life Number of periods over which the asset is depreciated
  1131. *
  1132. * @return float|string Result, or a string containing an error
  1133. */
  1134. public static function SLN($cost, $salvage, $life)
  1135. {
  1136. return Depreciation::SLN($cost, $salvage, $life);
  1137. }
  1138. /**
  1139. * SYD.
  1140. *
  1141. * Returns the sum-of-years' digits depreciation of an asset for a specified period.
  1142. *
  1143. * @deprecated 1.18.0
  1144. * Use the SYD() method in the Financial\Depreciation class instead
  1145. * @see Financial\Depreciation::SYD()
  1146. *
  1147. * @param mixed $cost Initial cost of the asset
  1148. * @param mixed $salvage Value at the end of the depreciation
  1149. * @param mixed $life Number of periods over which the asset is depreciated
  1150. * @param mixed $period Period
  1151. *
  1152. * @return float|string Result, or a string containing an error
  1153. */
  1154. public static function SYD($cost, $salvage, $life, $period)
  1155. {
  1156. return Depreciation::SYD($cost, $salvage, $life, $period);
  1157. }
  1158. /**
  1159. * TBILLEQ.
  1160. *
  1161. * Returns the bond-equivalent yield for a Treasury bill.
  1162. *
  1163. * @deprecated 1.18.0
  1164. * Use the bondEquivalentYield() method in the Financial\TreasuryBill class instead
  1165. * @see Financial\TreasuryBill::bondEquivalentYield()
  1166. *
  1167. * @param mixed $settlement The Treasury bill's settlement date.
  1168. * The Treasury bill's settlement date is the date after the issue date when the
  1169. * Treasury bill is traded to the buyer.
  1170. * @param mixed $maturity The Treasury bill's maturity date.
  1171. * The maturity date is the date when the Treasury bill expires.
  1172. * @param mixed $discount The Treasury bill's discount rate
  1173. *
  1174. * @return float|string Result, or a string containing an error
  1175. */
  1176. public static function TBILLEQ($settlement, $maturity, $discount)
  1177. {
  1178. return TreasuryBill::bondEquivalentYield($settlement, $maturity, $discount);
  1179. }
  1180. /**
  1181. * TBILLPRICE.
  1182. *
  1183. * Returns the price per $100 face value for a Treasury bill.
  1184. *
  1185. * @deprecated 1.18.0
  1186. * Use the price() method in the Financial\TreasuryBill class instead
  1187. * @see Financial\TreasuryBill::price()
  1188. *
  1189. * @param mixed $settlement The Treasury bill's settlement date.
  1190. * The Treasury bill's settlement date is the date after the issue date
  1191. * when the Treasury bill is traded to the buyer.
  1192. * @param mixed $maturity The Treasury bill's maturity date.
  1193. * The maturity date is the date when the Treasury bill expires.
  1194. * @param mixed $discount The Treasury bill's discount rate
  1195. *
  1196. * @return float|string Result, or a string containing an error
  1197. */
  1198. public static function TBILLPRICE($settlement, $maturity, $discount)
  1199. {
  1200. return TreasuryBill::price($settlement, $maturity, $discount);
  1201. }
  1202. /**
  1203. * TBILLYIELD.
  1204. *
  1205. * Returns the yield for a Treasury bill.
  1206. *
  1207. * @deprecated 1.18.0
  1208. * Use the yield() method in the Financial\TreasuryBill class instead
  1209. * @see Financial\TreasuryBill::yield()
  1210. *
  1211. * @param mixed $settlement The Treasury bill's settlement date.
  1212. * The Treasury bill's settlement date is the date after the issue date
  1213. * when the Treasury bill is traded to the buyer.
  1214. * @param mixed $maturity The Treasury bill's maturity date.
  1215. * The maturity date is the date when the Treasury bill expires.
  1216. * @param mixed $price The Treasury bill's price per $100 face value
  1217. *
  1218. * @return float|mixed|string
  1219. */
  1220. public static function TBILLYIELD($settlement, $maturity, $price)
  1221. {
  1222. return TreasuryBill::yield($settlement, $maturity, $price);
  1223. }
  1224. /**
  1225. * XIRR.
  1226. *
  1227. * Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic.
  1228. *
  1229. * Excel Function:
  1230. * =XIRR(values,dates,guess)
  1231. *
  1232. * @deprecated 1.18.0
  1233. * Use the rate() method in the Financial\CashFlow\Variable\NonPeriodic class instead
  1234. * @see Financial\CashFlow\Variable\NonPeriodic::rate()
  1235. *
  1236. * @param float[] $values A series of cash flow payments
  1237. * The series of values must contain at least one positive value & one negative value
  1238. * @param mixed[] $dates A series of payment dates
  1239. * The first payment date indicates the beginning of the schedule of payments
  1240. * All other dates must be later than this date, but they may occur in any order
  1241. * @param float $guess An optional guess at the expected answer
  1242. *
  1243. * @return float|mixed|string
  1244. */
  1245. public static function XIRR($values, $dates, $guess = 0.1)
  1246. {
  1247. return Financial\CashFlow\Variable\NonPeriodic::rate($values, $dates, $guess);
  1248. }
  1249. /**
  1250. * XNPV.
  1251. *
  1252. * Returns the net present value for a schedule of cash flows that is not necessarily periodic.
  1253. * To calculate the net present value for a series of cash flows that is periodic, use the NPV function.
  1254. *
  1255. * Excel Function:
  1256. * =XNPV(rate,values,dates)
  1257. *
  1258. * @deprecated 1.18.0
  1259. * Use the presentValue() method in the Financial\CashFlow\Variable\NonPeriodic class instead
  1260. * @see Financial\CashFlow\Variable\NonPeriodic::presentValue()
  1261. *
  1262. * @param float $rate the discount rate to apply to the cash flows
  1263. * @param float[] $values A series of cash flows that corresponds to a schedule of payments in dates.
  1264. * The first payment is optional and corresponds to a cost or payment that occurs
  1265. * at the beginning of the investment.
  1266. * If the first value is a cost or payment, it must be a negative value.
  1267. * All succeeding payments are discounted based on a 365-day year.
  1268. * The series of values must contain at least one positive value and one negative value.
  1269. * @param mixed[] $dates A schedule of payment dates that corresponds to the cash flow payments.
  1270. * The first payment date indicates the beginning of the schedule of payments.
  1271. * All other dates must be later than this date, but they may occur in any order.
  1272. *
  1273. * @return float|mixed|string
  1274. */
  1275. public static function XNPV($rate, $values, $dates)
  1276. {
  1277. return Financial\CashFlow\Variable\NonPeriodic::presentValue($rate, $values, $dates);
  1278. }
  1279. /**
  1280. * YIELDDISC.
  1281. *
  1282. * Returns the annual yield of a security that pays interest at maturity.
  1283. *
  1284. * @deprecated 1.18.0
  1285. * Use the yieldDiscounted() method in the Financial\Securities\Yields class instead
  1286. * @see Financial\Securities\Yields::yieldDiscounted()
  1287. *
  1288. * @param mixed $settlement The security's settlement date.
  1289. * The security's settlement date is the date after the issue date when the security
  1290. * is traded to the buyer.
  1291. * @param mixed $maturity The security's maturity date.
  1292. * The maturity date is the date when the security expires.
  1293. * @param mixed $price The security's price per $100 face value
  1294. * @param int $redemption The security's redemption value per $100 face value
  1295. * @param int $basis The type of day count to use.
  1296. * 0 or omitted US (NASD) 30/360
  1297. * 1 Actual/actual
  1298. * 2 Actual/360
  1299. * 3 Actual/365
  1300. * 4 European 30/360
  1301. *
  1302. * @return float|string Result, or a string containing an error
  1303. */
  1304. public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis = 0)
  1305. {
  1306. return Securities\Yields::yieldDiscounted($settlement, $maturity, $price, $redemption, $basis);
  1307. }
  1308. /**
  1309. * YIELDMAT.
  1310. *
  1311. * Returns the annual yield of a security that pays interest at maturity.
  1312. *
  1313. * @deprecated 1.18.0
  1314. * Use the yieldAtMaturity() method in the Financial\Securities\Yields class instead
  1315. * @see Financial\Securities\Yields::yieldAtMaturity()
  1316. *
  1317. * @param mixed $settlement The security's settlement date.
  1318. * The security's settlement date is the date after the issue date when the security
  1319. * is traded to the buyer.
  1320. * @param mixed $maturity The security's maturity date.
  1321. * The maturity date is the date when the security expires.
  1322. * @param mixed $issue The security's issue date
  1323. * @param mixed $rate The security's interest rate at date of issue
  1324. * @param mixed $price The security's price per $100 face value
  1325. * @param int $basis The type of day count to use.
  1326. * 0 or omitted US (NASD) 30/360
  1327. * 1 Actual/actual
  1328. * 2 Actual/360
  1329. * 3 Actual/365
  1330. * 4 European 30/360
  1331. *
  1332. * @return float|string Result, or a string containing an error
  1333. */
  1334. public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis = 0)
  1335. {
  1336. return Securities\Yields::yieldAtMaturity($settlement, $maturity, $issue, $rate, $price, $basis);
  1337. }
  1338. }