https://github.com/jameslairdsmith/contractr
contractr is a grammar of financial contracts.
https://github.com/jameslairdsmith/contractr
Last synced: 4 months ago
JSON representation
contractr is a grammar of financial contracts.
- Host: GitHub
- URL: https://github.com/jameslairdsmith/contractr
- Owner: jameslairdsmith
- Created: 2018-10-01T11:28:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-11T15:24:54.000Z (almost 6 years ago)
- Last Synced: 2024-08-13T07:11:12.365Z (8 months ago)
- Language: R
- Size: 221 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - jameslairdsmith/contractr - contractr is a grammar of financial contracts. (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# contractrcontractr is a grammar of financial contracts implemented in R. It is currently in the early stages of development.
Financial analysis, on its most basic level, can be simplified into two components. The first is the contract or contracts which are made between different parties. The second are the events which result from these contracts.
contractr provides a core set of functions which, when combined together, allow users to compose almost any type of financial contract. These contracts can then be be used to generate financial events, which are the the building blocks of all financial analysis.
## Adding terms to a contract
Financial contracts occur between different parties and obligate them to take certain actions. These are called terms. In contractr terms are added to a contract iteratively, building up until the contract is fully specified.
While the terms to a contract can be of many types, they are almost always exchanges of money. If person A borrows $100 from person B and agrees to repay it in one year's time, that is a financial contract with two terms. When sheduled, that contract will have two events.
## The `contract` object
The contract object is an S3 object in R. Once all the terms have been added to it, it encodes the information necessary to produce financial events.
The contract object doesn't schedule the events automatically, rather it delays this creation until it is fed into the `schedule()` function. In everyday language `schedule` is a verb which loosely means to "create events". When the `schedule()` function is applied to a `contract` object, it returns the events correspoding to the terms of the contract.