munn

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 12 Imported by: 0

README

munn

Build

CLI tool to project financial portfolio value.

Output is formatted with tabs to easily paste into Excel:

λ munn example.munn | tail
2022-11-24      Investment      4000.00
2022-11-24      Retirement      8600.00
2022-12-01      Bank    12735.98
2022-12-01      Savings 10200.00
2022-12-01      Investment      4000.00
2022-12-01      Retirement      8600.00
2022-12-02      Bank    10800.78
2022-12-02      Savings 10200.00
2022-12-02      Investment      4000.00
2022-12-02      Retirement      8600.00

You can also generate a graph image:

λ munn --image example.munn

Use the --debug flag to debug account changes:

λ munn --debug --image example.munn | tail
2022-12-02, Account Savings gained interest
2022-12-02, Account Investment gained interest
2022-12-02, Account Retirement gained interest
2022-12-02, Applied transaction Phone
2022-12-02, Applied transaction Rent
2022-12-02, Applied transaction Spotify
2022-12-02, Applied transaction Credit Card
2022-12-02, Applied transaction Internet
2022-12-02, Applied transaction Electric
2022-12-02, Applied transaction Auto/Renters Insurance

Supply a retirement plan with the --retire flag to see a projected retirement date:

λ munn example.munn --years 100 --retire 2080-01-01:25000 | tail
2119-11-30      Retirement      124900.00
2119-12-02      Bank    322148.31
2119-12-02      Savings 242800.00
2119-12-02      Investment      4000.00
2119-12-02      Retirement      124900.00
2119-12-07      Bank    322698.31
2119-12-07      Savings 242800.00
2119-12-07      Investment      4000.00
2119-12-07      Retirement      124900.00
Retirement date: 2068-01-02

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterScheduleParser

func RegisterScheduleParser(name string, parser ScheduleParser)

RegisterScheduleParser registers a schedule parser

Types

type Account

type Account struct {
	Name               string
	Portfolio          *Portfolio
	Balance            float32
	AnnualInterestRate float32
	// contains filtered or unexported fields
}

Account is a named account with a balance. An account may also have an annual interest rate which is applied monthly.

func (*Account) GainInterest

func (a *Account) GainInterest(now time.Time) bool

GainInterest adds interest to the account.

type ManualAdjustment

type ManualAdjustment struct {
	Portfolio *Portfolio
	Account   *Account
	Time      time.Time
	Balance   float32
	// contains filtered or unexported fields
}

ManualAdjustment is a single manual adjustment made on an account.

func (*ManualAdjustment) Apply

func (a *ManualAdjustment) Apply(now time.Time) bool

Apply the manual adjustment.

type Portfolio

type Portfolio struct {
	Accounts          []*Account
	Transactions      []*Transaction
	ManualAdjustments []*ManualAdjustment
	RetirementPlan    *RetirementPlan
	Debug             bool
}

Portfolio represents a person's financial portfolio.

func Parse

func Parse(r io.Reader) (*Portfolio, error)

Parse will read a portfolio from an io.Reader.

func (Portfolio) Chart

func (p Portfolio) Chart(recs []ProjectionRecord) chart.Chart

Chart generates a chart for the projection.

func (*Portfolio) NewAccount

func (p *Portfolio) NewAccount(name string) *Account

NewAccount adds a new account to the portfolio.

func (*Portfolio) NewManualAdjustment

func (p *Portfolio) NewManualAdjustment(acc *Account, t time.Time, balance float32)

NewManualAdjustment adds a new manual adjustment to the portfolio. It should be used to set the initial balance for an account or to log significant intended changes in the value of an account.

func (*Portfolio) NewTransaction

func (p *Portfolio) NewTransaction(from, to *Account, desc string, s Schedule, start, stop *time.Time, amt float32) *Transaction

NewTransaction adds a new transaction to the portfolio.

func (*Portfolio) Project

func (p *Portfolio) Project(years int) []ProjectionRecord

Project a portfolio's balances for a period of time.

func (*Portfolio) Stats

func (p *Portfolio) Stats() PortfolioStats

Stats gets stats for a portfolio.

func (*Portfolio) TotalBalance

func (p *Portfolio) TotalBalance() float32

TotalBalance gets the current total balance for all accounts.

type PortfolioStats

type PortfolioStats struct {
	AverageMonthlyExpenses float32
	AverageMonthlyIncome   float32
	AverageMonthlyGrowth   float32
}

PortfolioStats is a collection of stats about the portfolio.

func (PortfolioStats) String

func (s PortfolioStats) String() string

type ProjectionRecord

type ProjectionRecord struct {
	Time        time.Time
	AccountName string
	Balance     float32
}

ProjectionRecord is a record in a projection.

type RetirementPlan

type RetirementPlan struct {
	DeathDate      time.Time
	YearlyExpenses float32
	// contains filtered or unexported fields
}

RetirementPlan is a plan to retire.

func (*RetirementPlan) BalanceNeeded

func (p *RetirementPlan) BalanceNeeded(t time.Time) float32

BalanceNeeded is the balance needed to retire at a given date.

func (*RetirementPlan) RetireDate

func (p *RetirementPlan) RetireDate() (time.Time, bool)

RetireDate gets the found retirement date.

type Schedule

type Schedule interface {
	ShouldApply(time.Time) bool
	YearlyFactor() float32
}

Schedule determines the next time for a transaction to be applied, based on the last time it was applied. YearlyFactor should return the average number of times the schedule will be applied in a year (eg. a weekly schedule is applied 52 times in a year)

func Biweekly

func Biweekly(day time.Weekday) Schedule

Biweekly schedule will run biweekly on the given weekday.

func Monthly

func Monthly(day int) Schedule

Monthly schedule will run monthly on the given day of the month.

func Once

func Once(t time.Time) Schedule

Once schedule will run once at the given time.

func Weekly

func Weekly(day time.Weekday) Schedule

Weekly schedule will run weekly on the given weekday.

type ScheduleParser

type ScheduleParser interface {
	ParseSchedule(args []string) (Schedule, error)
}

ScheduleParser parses a schedule

func GetScheduleParser

func GetScheduleParser(name string) (ScheduleParser, bool)

GetScheduleParser gets a schedule parser

type Transaction

type Transaction struct {
	Description string
	Portfolio   *Portfolio
	Schedule    Schedule
	FromAccount *Account
	ToAccount   *Account
	Amount      float32
	Start       *time.Time
	Stop        *time.Time
}

Transaction is a transaction from one account to another. It may have a schedule to repeat the transaction on some interval. If FromAccount or ToAccount is nil, this transaction represents money in/out of the portfolio (payments, income, etc.). Otherwise it is a transfer between two accounts in the portfolio.

func (*Transaction) Apply

func (t *Transaction) Apply(now time.Time) bool

Apply the transaction.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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