PRICE3.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // Result, Settlement, Maturity, Rate, Yield, Redemption, Frequency, Basis
  3. // On the result line, the value is ODS's calculation.
  4. // This agrees with Gnumeric, PhpSpreadsheet, and the published algorithm at:
  5. //https://support.office.com/en-us/article/price-function-3ea9deac-8dfa-436f-a7c8-17ea02c21b0a.
  6. // The commented-out value on the next line is Excel's result.
  7. // I do not know how best to reconcile the different results.
  8. // The problem seems restricted to basis codes 2 and 3.
  9. return [
  10. [
  11. 94.60241717687768,
  12. // 94.636564030025099,
  13. '15-Feb-2008',
  14. '15-Nov-2017',
  15. 0.0575,
  16. 0.065,
  17. 100,
  18. 2,
  19. 2,
  20. ],
  21. [
  22. 94.643594548258,
  23. // 94.635174796784497,
  24. '15-Feb-2008',
  25. '15-Nov-2017',
  26. 0.0575,
  27. 0.065,
  28. 100,
  29. 2,
  30. 3,
  31. ],
  32. [
  33. 110.74436592216529,
  34. // 110.83448359321601,
  35. '01-Apr-2012',
  36. '31-Mar-2020',
  37. 0.12,
  38. 0.10,
  39. 100,
  40. 2,
  41. 2,
  42. ],
  43. [
  44. 110.81970970927745,
  45. // 110.83452855143901,
  46. '01-Apr-2012',
  47. '31-Mar-2020',
  48. 0.12,
  49. 0.10,
  50. 100,
  51. 2,
  52. 3,
  53. ],
  54. [
  55. 110.8912556,
  56. // 110.9216934,
  57. '01-Apr-2012',
  58. '31-Mar-2020',
  59. 0.12,
  60. 0.10,
  61. 100,
  62. 4,
  63. 2,
  64. ],
  65. [
  66. 110.9292394066714,
  67. // 110.921732963198,
  68. '01-Apr-2012',
  69. '31-Mar-2020',
  70. 0.12,
  71. 0.10,
  72. 100,
  73. 4,
  74. 3,
  75. ],
  76. ];