Latest 1.0.1 https://github.com/superwatermelon/SwiftAnnuity MIT ios 9.2 SwiftDecimalNumber Stuart Wakefield

## Introduction

A Swift library used to calculate annuities.

• iOS 9.3
• Xcode 8.0
• Swift 3.0

## Installation

To install to use within your project use Cocoapods and add the following to

``pod 'SwiftAnnuity', '1.0.0-alpha'``

## Usage

``````var annuity = SwiftAnnuity(
principal: NSDecimalNumber(string: "250000"),
rate: NSDecimalNumber(string: "0.035"),
term: 15,
frequency: 12
)
annuity.total
annuity.payment``````

It is possible to find the principal and the total amount from the payment
amount by using the payment initializer:

``````var annuity = SwiftAnnuity(
payment: NSDecimalNumber(string: "1200"),
rate: NSDecimalNumber(string: "0.035"),
term: 15,
frequency: 12
)
annuity.principal
annuity.total``````

It is also possible to find the principal and the payment amount from the total
amount paid for the annuity by using the total initializer:

``````var annuity = SwiftAnnuity(
total: NSDecimalNumber(string: "400000"),
rate: NSDecimalNumber(string: "0.035"),
term: 15,
frequency: 12
)
annuity.principal
annuity.payment``````

## API

### `SwiftAnnuity(principal: NSDecimalNumber, rate: NSDecimalNumber, term: Int, frequency: Int = 1)`

Creates a new `SwiftAnnuity` object from the principal. Typically used to discover
the total and payment for the given interest rate over the term.

### `SwiftAnnuity(total: NSDecimalNumber, rate: NSDecimalNumber, term: Int, frequency: Int = 1)`

Creates a new `SwiftAnnuity` object from the total including interest over the term.
Can be used to discover the principal by reversing the calculation.

### `SwiftAnnuity(payment: NSDecimalNumber, rate: NSDecimalNumber, term: Int, frequency: Int = 1)`

Creates a new `SwiftAnnuity` object from the fixed payment. Can be used to discover
the principal by reversing the calculation.

### `annuity.rate: NSDecimalNumber`

Returns the rate for the `SwiftAnnuity` instance.

### `annuity.term: Int`

Returns the term for the `SwiftAnnuity` instance.

### `annuity.frequency`

Returns the frequency for the `SwiftAnnuity` instance.

### `annuity.principal`

Returns the principal for the `SwiftAnnuity` instance.

### `annuity.total`

Returns the total including interest for the `SwiftAnnuity` instance.

### `annuity.payment`

Returns the payment amount for the `SwiftAnnuity` instance.

### Latest podspec

```{
"name": "SwiftAnnuity",
"version": "1.0.1",
"summary": "Swift library used to calculate annuity rates.",
"description": "It provides an object wrapper to be able to calculatenannuity rates for example for a fixed rate over timensuch as mortgage repayments.",
"homepage": "https://github.com/superwatermelon/SwiftAnnuity",
"authors": {
"Stuart Wakefield": "[email protected]"
},
"platforms": {
"ios": "9.2"
},
"source": {
"git": "https://github.com/superwatermelon/SwiftAnnuity.git",
"tag": "1.0.1"
},
"source_files": "Sources/**/*.swift",
"dependencies": {
"SwiftDecimalNumber": [
"~> 1.0.3"
]
}
}```