statement

package
v0.0.0-...-6b395dd Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package statement parses stock gain/loss statements as issued by MSSB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntryLess

func EntryLess(a, b *Entry) bool

EntryLess reports whether a should be ordered prior to b, based on time of acquisition with ties split by index.

func WriteCSV

func WriteCSV(entries []*Entry, w io.Writer) error

WriteCSV renders entries as CSV to w.

Types

type Entry

type Entry struct {
	Index      int            // batch index
	Acquired   time.Time      // when the shares were issued
	Plan       string         // under what plan
	Available  int            // how many shares are available
	Via        string         // how they were received
	IssuePrice currency.Value // price per share at issue
	Price      currency.Value // value per share currently (estimated)
	Gain       currency.Value // capital gain/loss per share (via estimated value)
}

An Entry represents a group of shares acquired at a particular time.

func ParseCSV

func ParseCSV(data []byte, opts *Options) ([]*Entry, error)

ParseCSV extracts the gain/loss entries from the statement in data, returning those matched by the options (or all if opts == nil).

The input data are expected to have a header row containing the standard fields of the MSSB gain/loss report:

Acquired Date:              date as mm/dd/yyyy
Plan Name:                  string
Acquired Price:             price as $ddd.cc
Acquired Via:               string
Shares Available for Sale:  integer
Current Market Value:       price as $ddd.cc
Unrealized Total Gain/Loss: price as $ddd.cc (possibly negative)

func ParseXLS

func ParseXLS(data []byte, opts *Options) ([]*Entry, error)

ParseXLS extracts the gain/loss entries from the statement in data, returning those matched by the options (or all if opts == nil).

func (*Entry) Format

func (e *Entry) Format(n int) string

Format returns a description of n shares of e. If n < 0, the total available share count is used.

type Options

type Options struct {
	// If not nil, select which entries to return.  If nil, all entries are
	// selected.
	Filter func(*Entry) bool

	// If set, override the current market value per share.
	MarketPrice currency.Value
}

Options control the behaviour of a parser.

Jump to

Keyboard shortcuts

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