Documentation
¶
Overview ¶
Package returns implements data structures and convenience methods for interacting with a list of returns or sets of date-aligned returns.
Please remember, investing carries inherent risks including but not limited to the potential loss of principal. Past performance is no guarantee of future results. The data, equations, and calculations in these docs and code are for informational purposes only and should not be considered financial advice. It is important to carefully consider your own financial situation before making any investment decisions. You should seek the advice of a licensed financial professional before making any investment decisions. You should seek code review of an experienced software developer before consulting this library (or any library that imports it) to make investment decisions.
Index ¶
- Constants
- type ColumnGroup
- type ErrorNoReturns
- type List
- func (list List) AnnualizedArithmeticReturn() float64
- func (list List) AnnualizedRisk() float64
- func (list List) AnnualizedTimeWeightedReturn() float64
- func (list List) Between(t1, t0 time.Time) List
- func (list List) EndAndStartDate() (end, start time.Time, _ error)
- func (list List) Excess(other List) List
- func (list List) First() Return
- func (list List) FirstTime() time.Time
- func (list List) Insert(newReturn Return) List
- func (list List) Last() Return
- func (list List) LastTime() time.Time
- func (list List) Len() int
- func (list List) Less(i, j int) bool
- func (list List) Returns() List
- func (list List) Reverse()
- func (list List) Risk() float64
- func (list List) Sort()
- func (list List) Swap(i, j int)
- func (list List) TimeWeightedReturn() float64
- func (list List) Times() []time.Time
- func (list List) Value(t time.Time) (float64, bool)
- func (list List) Values() []float64
- type Return
- type Table
- func (table Table) AddColumn(list List) Table
- func (table Table) AddColumnGroup(lists []List) (ColumnGroup, Table)
- func (table Table) AddColumns(lists []List) Table
- func (table Table) AnnualizedArithmeticReturns() []float64
- func (table Table) AnnualizedRisks() []float64
- func (table Table) Between(last, first time.Time) Table
- func (table Table) ColumnGroupAsTable(group ColumnGroup) Table
- func (table Table) ColumnGroupColumnIndex(group ColumnGroup, groupIndex int) (columnIndex int)
- func (table Table) ColumnGroupLists(group ColumnGroup) []List
- func (table Table) ColumnGroupValues(group ColumnGroup) [][]float64
- func (table Table) ColumnValues() [][]float64
- func (table Table) CorrelationMatrix() *mat.Dense
- func (table Table) CorrelationMatrixValues() [][]float64
- func (table Table) EndAndStartDates() (end, start time.Time, _ error)
- func (table Table) ExpectedRisk(weights []float64) float64
- func (table Table) FirstTime() time.Time
- func (table Table) HasRow(tm time.Time) bool
- func (table Table) Join(other Table) Table
- func (table Table) LastTime() time.Time
- func (table Table) List(columnIndex int) List
- func (table Table) Lists() []List
- func (table Table) MarshalBSON() ([]byte, error)
- func (table Table) MarshalJSON() ([]byte, error)
- func (table Table) MostRecentValues() []float64
- func (table Table) NumberOfColumns() int
- func (table Table) NumberOfRows() int
- func (table Table) RangeIndexes(last, first time.Time) (end int, start int)
- func (table Table) Risks() []float64
- func (table Table) Row(tm time.Time) ([]float64, bool)
- func (table Table) TimeAfter(tm time.Time) (time.Time, bool)
- func (table Table) TimeBefore(tm time.Time) (time.Time, bool)
- func (table Table) TimeWeightedReturns() []float64
- func (table Table) Times() []time.Time
- func (table *Table) UnmarshalBSON(buf []byte) error
- func (table *Table) UnmarshalJSON(buf []byte) error
Constants ¶
const DateLayout = "2006-01-02"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnGroup ¶
type ColumnGroup struct {
// contains filtered or unexported fields
}
func (ColumnGroup) Length ¶
func (group ColumnGroup) Length() int
type ErrorNoReturns ¶
type ErrorNoReturns struct{}
func (ErrorNoReturns) Error ¶
func (err ErrorNoReturns) Error() string
type List ¶
type List []Return
func (List) AnnualizedArithmeticReturn ¶
func (List) AnnualizedRisk ¶
AnnualizedRisk must receive at least 2 returns otherwise it returns 0
func (List) AnnualizedTimeWeightedReturn ¶
AnnualizedTimeWeightedReturn must receive at least 2 returns otherwise it returns 0
func (List) Between ¶
Between returns a slice of a list. You may want pass result into slices.Clone() before using any mutating functions (such as Insert).
func (List) Insert ¶
Insert correctly places newReturn in List. If newReturn.Time is the same as an existing return in s, the value of the existing return is overwritten.
func (List) TimeWeightedReturn ¶
type Return ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func AlignTables ¶
AlignTables may be used to ensure multiple tables are date-aligned.
func (Table) AddColumnGroup ¶
func (table Table) AddColumnGroup(lists []List) (ColumnGroup, Table)
func (Table) AddColumns ¶
func (Table) AnnualizedArithmeticReturns ¶
func (Table) AnnualizedRisks ¶
func (Table) ColumnGroupAsTable ¶
func (table Table) ColumnGroupAsTable(group ColumnGroup) Table
func (Table) ColumnGroupColumnIndex ¶
func (table Table) ColumnGroupColumnIndex(group ColumnGroup, groupIndex int) (columnIndex int)
func (Table) ColumnGroupLists ¶
func (table Table) ColumnGroupLists(group ColumnGroup) []List
func (Table) ColumnGroupValues ¶
func (table Table) ColumnGroupValues(group ColumnGroup) [][]float64
func (Table) ColumnValues ¶
func (Table) CorrelationMatrix ¶
func (Table) CorrelationMatrixValues ¶
func (Table) EndAndStartDates ¶
func (Table) ExpectedRisk ¶
func (Table) MarshalBSON ¶
func (Table) MarshalJSON ¶
func (Table) MostRecentValues ¶
func (Table) NumberOfColumns ¶
func (Table) NumberOfRows ¶
func (Table) RangeIndexes ¶
RangeIndexes is a helper to be used to align additional non-return columns to a table