Documentation
¶
Index ¶
- Variables
- func NewLinearGrowthIP(bd financial.Date, bi, curve decimal.Decimal) (i indexGrowthLinear)
- type CalculationType
- type CashFlowCreator
- type Flow
- type FlowTab
- func (ft FlowTab) Irr() (decimal.Decimal, error)
- func (ft FlowTab) IrrIndexed() (decimal.Decimal, error)
- func (ft FlowTab) Len() int
- func (ft FlowTab) Less(i, j int) bool
- func (ft FlowTab) OrderByDate() (r FlowTab)
- func (ft FlowTab) Rearrange() (result FlowTab)
- func (ft FlowTab) String() string
- func (ft FlowTab) Swap(i, j int)
- func (ft FlowTab) ToCashFlowTab() (cft financial.CashFlowTab)
- func (ft FlowTab) ToCashFlowTabIndexed() (cft financial.CashFlowTab)
- type IndexPrediction
- type ShpitzerCashflow
Constants ¶
This section is empty.
Variables ¶
var ( ErrParametersMissing = errors.New("invalid data, calculation failed due to missing parameters") ErrCalculationFailed = errors.New("calculation failed") )
Common errors.
Functions ¶
Types ¶
type CalculationType ¶
type CalculationType int
const ( Shpitzer CalculationType = iota + 1 ConstFromPrincipal )
type CashFlowCreator ¶
type Flow ¶
type Flow struct { Index int64 Date financial.Date Principal decimal.Decimal Interest decimal.Decimal Payment decimal.Decimal PrincipalLeft decimal.Decimal KnownIndex decimal.Decimal PaymentFactored decimal.Decimal }
Flow is full cashflow of mortgage
func (Flow) ToCashFlow ¶
func (Flow) ToCashFlowIndexed ¶
type FlowTab ¶
type FlowTab []Flow
FlowTab is table of flows, represent full cash flow
func CreateFlowTable ¶
func CreateFlowTable(t CalculationType, a, r decimal.Decimal, m int64, ad, pd financial.Date, ip IndexPrediction, kf financial.CashFlowTab) (ft FlowTab, e error)
CreateShpitzerFlowTable calculate and create cashflow. a = amount r = monthly rate (note: not yearly rate, divide by 12 if needed) m = number of months ad = receiving the loan -> date pd = start paying -> date ed = end paying -> date bi = Base index kf = Known flows (down payment, fees and so on...)
func (FlowTab) OrderByDate ¶
func (FlowTab) ToCashFlowTab ¶
func (ft FlowTab) ToCashFlowTab() (cft financial.CashFlowTab)
func (FlowTab) ToCashFlowTabIndexed ¶
func (ft FlowTab) ToCashFlowTabIndexed() (cft financial.CashFlowTab)
type IndexPrediction ¶
type IndexPrediction interface { GetIndex(date financial.Date) decimal.Decimal GetBaseIndex() (financial.Date, decimal.Decimal) }
IndexPrediction allow prediction of future index
type ShpitzerCashflow ¶
type ShpitzerCashflow struct { Amount decimal.Decimal Months int64 MonthlyRate decimal.Decimal CashRecieveDate financial.Date StartPayingDate financial.Date IndexPredict IndexPrediction KnownCashFlows financial.CashFlowTab }
func GetShpitzerCashflowInstance ¶
func GetShpitzerCashflowInstance(a, r decimal.Decimal, m int64, cashDate, fromDate financial.Date, ip IndexPrediction, kf financial.CashFlowTab) (result *ShpitzerCashflow)
GetShpitzerCashflowInstance Creates instance. Parameters are: a : Amount of money r : Rate (monthly rate, not yearly) m : How many months cashDate : Date the money is taken from the bank fromDate : The first payment (to the bank) date ip : instance of index prediction. can be null if not relevant. kf : Known cash flows. Optional: additional known flows, like: down payment, taxes and so on.
func (ShpitzerCashflow) NewCashFlowTable ¶
func (s ShpitzerCashflow) NewCashFlowTable() (ft FlowTab, e error)