MyNixOS website logo
Description

A Financial Calculator.

A financial calculator that provides very fast implementations of common financial indicators using 'Rust' code. It includes functions for bond-related indicators, such as yield to maturity ('YTM'), modified duration, and Macaulay duration, as well as functions for calculating time-weighted and money-weighted rates of return (using 'Modified Dietz' method) for multiple portfolios, given their market values and profit and loss ('PnL') data. 'fcl' is designed to be efficient and accurate for financial analysis and computation. The methods used in this package are based on the following references: <https://en.wikipedia.org/wiki/Modified_Dietz_method>, <https://en.wikipedia.org/wiki/Time-weighted_return>.

fcl

R-CMD-check CRANstatus CoverageStatus

A financial calculator written in Rust. It provides simple calculations for bond YTM, Duration, etc.

Installation

You’ll need the rust toolchain to compile this package from the source.

Example

library(fcl)
## basic example code
bond <- fixed_bond(
  value_date = 210101,
  mty_date = c(250101, 300201),
  redem_value = 100,
  cpn_rate = c(0.05, 0.03),
  cpn_freq = c(0, 1)
)
bond$ytm_dur(
  ref_date = c(220101, 220201),
  clean_price = 100
)
#>          YTM     MACD     MODD
#> 1 0.04552728 3.000000 2.869366
#> 2 0.02999755 7.212793 7.002728
bond$cf(
  ref_date = c(220101, 220131)
)
#>    ID       DATE     COUPON REDEM
#> 1   1 2025-01-01 20.0000000   100
#> 2   2 2023-01-01  3.0000000     0
#> 3   2 2024-01-01  3.0000000     0
#> 4   2 2025-01-01  3.0000000     0
#> 5   2 2026-01-01  3.0000000     0
#> 6   2 2027-01-01  3.0000000     0
#> 7   2 2028-01-01  3.0000000     0
#> 8   2 2029-01-01  3.0000000     0
#> 9   2 2030-01-01  3.0000000     0
#> 10  2 2030-02-01  0.2547945   100

rtn <- make_rtn(date = c(210101, 210105, 210110), mv = c(100, 123, 140), pl = c(0, 3, 7))
rtn$twrr_cr(210102, 210110)
#>               TWRR_CR
#> 2021-01-02 0.00000000
#> 2021-01-03 0.00000000
#> 2021-01-04 0.00000000
#> 2021-01-05 0.02500000
#> 2021-01-06 0.02500000
#> 2021-01-07 0.02500000
#> 2021-01-08 0.02500000
#> 2021-01-09 0.02500000
#> 2021-01-10 0.07894737
rtn$twrr_dr(210102, 210110)
#>               TWRR_DR
#> 2021-01-02 0.00000000
#> 2021-01-03 0.00000000
#> 2021-01-04 0.00000000
#> 2021-01-05 0.02500000
#> 2021-01-06 0.00000000
#> 2021-01-07 0.00000000
#> 2021-01-08 0.00000000
#> 2021-01-09 0.00000000
#> 2021-01-10 0.05263158
rtn$dietz(210102, 210110)
#>                 DIETZ
#> 2021-01-02 0.00000000
#> 2021-01-03 0.00000000
#> 2021-01-04 0.00000000
#> 2021-01-05 0.02857143
#> 2021-01-06 0.02777778
#> 2021-01-07 0.02727273
#> 2021-01-08 0.02692308
#> 2021-01-09 0.02666667
#> 2021-01-10 0.08737864
rtn$dietz_avc(210102, 210110)
#>            DIETZ_AVC
#> 2021-01-02  100.0000
#> 2021-01-03  100.0000
#> 2021-01-04  100.0000
#> 2021-01-05  105.0000
#> 2021-01-06  108.0000
#> 2021-01-07  110.0000
#> 2021-01-08  111.4286
#> 2021-01-09  112.5000
#> 2021-01-10  114.4444
Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows