fintracts

package module
v0.0.0-...-88bd814 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 6 Imported by: 0

README

Fintracts CLI Tool

Build Go Report Card Documentation

Fintracts CLI tool parses English contracts and validates any JSON contract according to the specification.

Features

Install With Go

If you have Go installed, you can simply run:

go install github.com/hacdias/fintracts/fintracts/cmd/fintracts

Run Directly

First, install the necessary dependencies:

go mod download

Then, build the executable:

make build

An executable can be found on ./fintracts.

Run With Docker

To build:

docker build . -t fintracts

You can now run the parser inside the docker image:

docker run -i fintracts [commands and arguments]

Usage

Run fintracts --help for more information.

License

MIT © Henrique Dias

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(c *Contract, fix bool) error

Validate validates a contract. Optionally, it can fix easy to fix errors, such as:

  • Convert currency names to upper case. E.g. 'eur' to 'EUR'.
  • Fill the implied exchange rate in currency swap agreements.

Types

type Agreement

type Agreement struct {
	BondPurchase     *BondPurchase     `json:"bondPurchase,omitempty"`
	InterestRateSwap *InterestRateSwap `json:"interestRateSwap,omitempty"`
	CurrencySwap     *CurrencySwap     `json:"currencySwap,omitempty"`
}

type BondPurchase

type BondPurchase struct {
	Issuer       string   `json:"issuer"`
	Underwriter  string   `json:"underwriter"`
	FaceValue    Money    `json:"faceValue"`
	IssuePrice   Money    `json:"issuePrice"`
	MaturityDate Date     `json:"maturityDate"`
	Coupons      *Coupons `json:"coupons,omitempty"`
}

type Contract

type Contract struct {
	Parties    []Party     `json:"parties"`
	Agreements []Agreement `json:"agreements"`
	Signatures []Signature `json:"signatures"`
	// contains filtered or unexported fields
}

Contract represents a financial contract with its parties, agreements and signatures.

func FromJSON

func FromJSON(data []byte) (*Contract, error)

FromJSON converts a JSON byte array into a contract.

func (*Contract) String

func (c *Contract) String() (string, error)

String returns an indented JSON-string representation of a contract.

type Coupons

type Coupons struct {
	Rate  float64 `json:"rate"`
	Dates []Date  `json:"dates"`
}

type Currency

type Currency string

type CurrencySwap

type CurrencySwap struct {
	PayerA              string            `json:"payerA"`
	PayerB              string            `json:"payerB"`
	PrincipalA          Money             `json:"principalA"`
	PrincipalB          Money             `json:"principalB"`
	ImpliedExchangeRate ExchangeRate      `json:"impliedExchangeRate"`
	EndExchangeRate     *ExchangeRate     `json:"endExchangeRate,omitempty"`
	EffectiveDate       Date              `json:"effectiveDate"`
	MaturityDate        Date              `json:"maturityDate"`
	Interest            []InterestPayment `json:"interest,omitempty"`
}

type Date

type Date time.Time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) (err error)

type ExchangeRate

type ExchangeRate struct {
	BaseCurrency    Currency `json:"baseCurrency"`
	CounterCurrency Currency `json:"counterCurrency"`
	Rate            float64  `json:"rate"`
}

type InterestPayment

type InterestPayment struct {
	Payer string `json:"payer"`
	Dates []Date `json:"dates"`

	// Fixed-rate only properties:
	FixedRate   float64 `json:"fixedRate,omitempty"`
	InitialRate float64 `json:"initialRate,omitempty"`

	// Floating-rate only properties:
	RateOption string `json:"rateOption,omitempty"`
}

type InterestRateSwap

type InterestRateSwap struct {
	NotationalAmount Money             `json:"notationalAmount"`
	EffectiveDate    Date              `json:"effectiveDate"`
	MaturityDate     Date              `json:"maturityDate"`
	Interest         []InterestPayment `json:"interest"`
}

type Money

type Money struct {
	Currency Currency `json:"currency"`
	Amount   float64  `json:"amount"`
}

type Party

type Party struct {
	Name       string `json:"name"`
	Identifier string `json:"identifier"`
}

type Signature

type Signature struct {
	Parties []string `json:"parties"`
	Date    Date     `json:"date"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL