portfolio

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STRATEGY  = "STRATEGY"
	BENCHMARK = "BENCHMARK"
	RISKFREE  = "RISKFREE"
)
View Source
const (
	SellTransaction     = "SELL"
	BuyTransaction      = "BUY"
	InterestTransaction = "INTEREST"
	DividendTransaction = "DIVIDEND"
	SplitTransaction    = "SPLIT"
	DepositTransaction  = "DEPOSIT"
	WithdrawTransaction = "WITHDRAW"
)
View Source
const (
	Roth        = "ROTH"
	TaxDeferred = "DEFERRED"
	Taxable     = "TAXABLE"
)

account types

View Source
const (
	LTC                  = "LTC"
	STC                  = "STC"
	QualifiedDividend    = "QUALIFIED"
	NonQualifiedDividend = "NON-QUALIFIED"
)

capital gains

View Source
const (
	SourceName = "PV"
)
View Source
const (
	SplitFactor = "SplitFactor"
)
View Source
const (
	TaxLotFIFOMethod = "TaxLotFIFO"
)

Variables

View Source
var (
	ErrInvalidTransactionType = errors.New("unrecognized transaction type")
	ErrNoTransactions         = errors.New("portfolio has no transactions")
	ErrSerialize              = errors.New("could not serialize data")
	ErrNoMeasurementFound     = errors.New("no measurement found")
)
View Source
var (
	ErrEmptyUserID               = errors.New("user id empty")
	ErrStrategyNotFound          = errors.New("strategy not found")
	ErrHoldings                  = errors.New("holdings are out of sync, cannot rebalance portfolio")
	ErrInvalidSell               = errors.New("refusing to sell 0 shares - cannot rebalance portfolio; target allocation broken")
	ErrTimeInverted              = errors.New("start date occurs after through date")
	ErrPortfolioNotFound         = errors.New("could not find portfolio ID in database")
	ErrGenerateHash              = errors.New("could not create a new hash")
	ErrTransactionsOutOfOrder    = errors.New("transactions would be out-of-order if executed")
	ErrRebalancePercentWrong     = errors.New("rebalance total must equal 1.0")
	ErrSecurityPriceNotAvailable = errors.New("security price not available for date")
	ErrNoTickerColumn            = errors.New("no ticker column present")
	ErrInvalidDateRange          = errors.New("invalid date range")
)
View Source
var (
	// ColferSizeMax is the upper limit for serial byte sizes.
	ColferSizeMax = 16 * 1024 * 1024
	// ColferListMax is the upper limit for the number of elements in a list.
	ColferListMax = 4 * 1024 * 1024
)

Colfer configuration attributes

View Source
var (
	ErrDidNotConverge = errors.New("did not converge")
)

Functions

func CircularBootstrap

func CircularBootstrap(timeSeries []float64, blockSize int, n int, m int) [][]float64

CircularBootstrap returns n arrays if length m of bootstrapped values from timeSeries

func DynamicWithdrawalRate

func DynamicWithdrawalRate(mc [][]float64, inflation float64) float64

DynamicWithdrawalRate calculates the maximum % that can be withdrawn per year and expect the balance to be greater than or equal to the inflation adjusted starting balance. Inflation should be provided as an annual rate.

func PerpetualWithdrawalRate

func PerpetualWithdrawalRate(mc [][]float64, inflation float64) float64

PerpetualWithdrawalRate

func SafeWithdrawalRate

func SafeWithdrawalRate(mc [][]float64, inflation float64) float64

SafeWithdrawalRate

Types

type Activity

type Activity struct {
	Date time.Time
	Msg  string
	Tags []string
}

type AnnualReturn

type AnnualReturn struct {
	Year uint16

	Return float32
}

func (*AnnualReturn) MarshalBinary

func (o *AnnualReturn) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*AnnualReturn) MarshalLen

func (o *AnnualReturn) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*AnnualReturn) MarshalTo

func (o *AnnualReturn) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*AnnualReturn) Unmarshal

func (o *AnnualReturn) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*AnnualReturn) UnmarshalBinary

func (o *AnnualReturn) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type ColferError

type ColferError int

ColferError signals a data mismatch as as a byte index.

func (ColferError) Error

func (i ColferError) Error() string

Error honors the error interface.

type ColferMax

type ColferMax string

ColferMax signals an upper limit breach.

func (ColferMax) Error

func (m ColferMax) Error() string

Error honors the error interface.

type ColferTail

type ColferTail int

ColferTail signals data continuation as a byte index.

func (ColferTail) Error

func (i ColferTail) Error() string

Error honors the error interface.

type DrawDown

type DrawDown struct {
	Begin time.Time

	End time.Time

	Recovery time.Time

	LossPercent float64

	Active bool
}

func (*DrawDown) MarshalBinary

func (o *DrawDown) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*DrawDown) MarshalLen

func (o *DrawDown) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*DrawDown) MarshalTo

func (o *DrawDown) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*DrawDown) MarshalZerologObject added in v0.5.0

func (o *DrawDown) MarshalZerologObject(e *zerolog.Event)

func (*DrawDown) Unmarshal

func (o *DrawDown) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*DrawDown) UnmarshalBinary

func (o *DrawDown) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type Holding

type Holding struct {
	Date time.Time

	CompositeFIGI string

	Ticker string

	Shares float64
}

func (*Holding) MarshalBinary

func (o *Holding) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*Holding) MarshalLen

func (o *Holding) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Holding) MarshalTo

func (o *Holding) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*Holding) Unmarshal

func (o *Holding) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Holding) UnmarshalBinary

func (o *Holding) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type Justification

type Justification struct {
	Key string

	Value float64
}

func (*Justification) MarshalBinary

func (o *Justification) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*Justification) MarshalLen

func (o *Justification) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Justification) MarshalTo

func (o *Justification) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*Justification) Unmarshal

func (o *Justification) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Justification) UnmarshalBinary

func (o *Justification) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type Metrics

type Metrics struct {
	AlphaSinceInception float64

	AvgDrawDown float64

	BestYear *AnnualReturn

	BetaSinceInception float64

	DownsideDeviationSinceInception float64

	ExcessKurtosisSinceInception float64

	FinalBalance float64

	SharpeRatioSinceInception float64

	Skewness float64

	SortinoRatioSinceInception float64

	StdDevSinceInception float64

	TaxCostRatio float64

	TotalDeposited float64

	TotalWithdrawn float64

	UlcerIndexAvg float64

	UlcerIndexP50 float64

	UlcerIndexP90 float64

	UlcerIndexP99 float64

	WorstYear *AnnualReturn

	DynamicWithdrawalRateSinceInception float64

	PerpetualWithdrawalRateSinceInception float64

	SafeWithdrawalRateSinceInception float64
}

func (*Metrics) MarshalBinary

func (o *Metrics) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*Metrics) MarshalLen

func (o *Metrics) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Metrics) MarshalTo

func (o *Metrics) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*Metrics) MarshalZerologObject

func (metrics *Metrics) MarshalZerologObject(e *zerolog.Event)

func (*Metrics) Unmarshal

func (o *Metrics) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Metrics) UnmarshalBinary

func (o *Metrics) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type Model

type Model struct {
	Portfolio *Portfolio
	// contains filtered or unexported fields
}

Model stores a portfolio and associated price data that is used for computation

func LoadFromDB

func LoadFromDB(ctx context.Context, portfolioIDs []string, userID string) ([]*Model, error)

func NewPortfolio

func NewPortfolio(name string, startDate time.Time, initial float64) *Model

NewPortfolio create a portfolio

func (*Model) AddActivity

func (pm *Model) AddActivity(date time.Time, msg string, tags []string)

func (*Model) FillCorporateActions

func (pm *Model) FillCorporateActions(ctx context.Context, through time.Time) error

FillCorporateActions finds any corporate actions and creates transactions for them. The search occurs from the date of the last transaction to `through`

func (*Model) LoadTransactionsFromDB

func (pm *Model) LoadTransactionsFromDB(ctx context.Context) error

func (*Model) NotificationsForDate

func (pm *Model) NotificationsForDate(ctx context.Context, forDate time.Time, perf *Performance) []*Notification

func (*Model) RebalanceTo

func (pm *Model) RebalanceTo(ctx context.Context, allocation *data.SecurityAllocation, justifications []*Justification) error

RebalanceTo rebalance the portfolio to the target percentages Assumptions: can only rebalance current holdings

func (*Model) RequestedNotificationsForDate

func (pm *Model) RequestedNotificationsForDate(forDate time.Time) []NotificationFrequency

RequestedNotificationsForDate evaluates a portfolios notifications against the requested date and returns those notifications that are valid for the given date.

func (*Model) Save

func (pm *Model) Save(ctx context.Context, userID string) error

Save portfolio to database along with all transaction data

func (*Model) SaveActivities

func (pm *Model) SaveActivities(ctx context.Context) error

func (*Model) SaveWithTransaction

func (pm *Model) SaveWithTransaction(ctx context.Context, trx pgx.Tx, userID string, permanent bool) error

func (*Model) SetStatus

func (pm *Model) SetStatus(ctx context.Context, msg string) error

func (*Model) Table added in v0.5.0

func (pm *Model) Table() string

Table formats the portfolio into a human-readable string representation

func (*Model) TargetPortfolio

func (pm *Model) TargetPortfolio(ctx context.Context, target data.PortfolioPlan) error

TargetPortfolio invests the portfolio in the ratios specified by the PieHistory `target`.

func (*Model) UpdateTransactions

func (pm *Model) UpdateTransactions(ctx context.Context, through time.Time) error

UpdateTransactions calculates new transactions based on the portfolio strategy from the portfolio end date to `through`

type Notification

type Notification struct {
	ForDate      time.Time
	ForFrequency NotificationFrequency
	Holdings     map[data.Security]float64
	Portfolio    *Portfolio
	PeriodReturn float64
	YTDReturn    float64
}

func (*Notification) SendEmail

func (n *Notification) SendEmail(userFullName string, emailAddress string) error

type NotificationFrequency

type NotificationFrequency int32
const (
	NotifyDaily    NotificationFrequency = 0x00000010
	NotifyWeekly   NotificationFrequency = 0x00000100
	NotifyMonthly  NotificationFrequency = 0x00001000
	NotifyAnnually NotificationFrequency = 0x00010000
)

func (NotificationFrequency) String

func (nf NotificationFrequency) String() string

type Performance

type Performance struct {
	PortfolioID []byte

	PeriodStart time.Time

	PeriodEnd time.Time

	ComputedOn time.Time

	CurrentAssets []*ReportableHolding

	Measurements []*PerformanceMeasurement

	DrawDowns []*DrawDown

	PortfolioReturns *Returns

	BenchmarkReturns *Returns

	PortfolioMetrics *Metrics

	BenchmarkMetrics *Metrics
}

func LoadPerformanceFromDB

func LoadPerformanceFromDB(ctx context.Context, portfolioID uuid.UUID, userID string) (*Performance, error)

func NewPerformance

func NewPerformance(p *Portfolio) *Performance

func (*Performance) ActiveReturn

func (perf *Performance) ActiveReturn(periods uint) float64

ActiveReturn calculates the difference in return vs a benchmark this is considered the amount of return that the "active" management yielded. The value of this metric is highly dependent on appropriate selection of benchmark. For example, comparing a small-cap value fund to the S&P500 benchmark doesn't say much because the underlying return of the assets held does not match the S&P500 well.

func (*Performance) AllDrawDowns

func (perf *Performance) AllDrawDowns(periods uint, kind string) []*DrawDown

AllDrawDowns computes all portfolio draw downs. A draw down is defined as the period in which a portfolio falls from its previous peak. Draw downs include the time period of the loss, percent of loss, and when the portfolio recovered

func (*Performance) Alpha

func (perf *Performance) Alpha(periods uint) float64

alpha is a measure of excess return of a portfolio α = Rp – [Rf + (Rm – Rf) β]

func (*Performance) AverageDrawDown

func (perf *Performance) AverageDrawDown(periods uint, kind string) float64

AverageDrawDown computes the average portfolio draw down. A draw down is defined as the period in which a portfolio falls from its previous peak. Draw downs include the time period of the loss, percent of loss, and when the portfolio recovered

func (*Performance) AvgUlcerIndex

func (perf *Performance) AvgUlcerIndex(periods uint) float64

AvgUlcerIndex compute average ulcer index over the last N periods

func (*Performance) Beta

func (perf *Performance) Beta(periods uint) float64

Beta is a measure of the volatility—or systematic risk—of a security or portfolio compared to the market as a whole. Beta is used in the capital asset pricing model (CAPM), which describes the relationship between systematic risk and expected return for assets (usually stocks). CAPM is widely used as a method for pricing risky securities and for generating estimates of the expected returns of assets, considering both the risk of those assets and the cost of capital.

func (*Performance) CalculateThrough

func (perf *Performance) CalculateThrough(ctx context.Context, pm *Model, through time.Time) error

CalculateThrough computes performance metrics for the given portfolio until `through`

func (*Performance) CalmarRatio

func (perf *Performance) CalmarRatio(periods uint, kind string) float64

CalmarRatio is a gauge of the risk adjusted performance of a portfolio. It is a function of the fund's average compounded annual rate of return versus its maximum drawdown. The higher the Calmar ratio, the better the portfolio performed on a risk-adjusted basis during the given time frame, which is typically set at 36 months.

func (*Performance) DownsideDeviation

func (perf *Performance) DownsideDeviation(periods uint, kind string) float64

DownsideDeviation compute the standard deviation of negative excess returns on a monthly basis, result is annualized

func (*Performance) ExcessKurtosis

func (perf *Performance) ExcessKurtosis(periods uint) float64

ExcessKurtosis calculates the amount of kurtosis relative to the normal distribution. Kurtosis is a statistical measure that is used to describe the size of the tails on a distribution. Excess kurtosis helps determine how much risk is involved in a specific investment. It signals that the probability of obtaining an extreme outcome or value from the event in question is higher than would be found in a probabilistically normal distribution of outcomes.

func (*Performance) InformationRatio

func (perf *Performance) InformationRatio(periods uint) float64

InformationRatio is a measurement of portfolio returns beyond the returns of the benchmark, compared to the volatility of those returns.

func (*Performance) KRatio

func (perf *Performance) KRatio(periods uint) float64

KRatio The K-ratio is a valuation metric that examines the consistency of an equity's return over time. k-ratio = (Slope logVAMI regression line) / n(Standard Error of the Slope)

func (*Performance) KellerRatio

func (perf *Performance) KellerRatio(periods uint, kind string) float64

KellerRatio adjusts return for drawdown such as to reflect the severity of the observed maximum drawdown. In case maximum drawdown is small, the return adjustment is only limited. But with large maximum drawdown, the impact of the return adjustment is amplified.

K = R * ( 1 - D / ( 1 - D ) ), if R >= 0% and D <= 50%, and K = 0% otherwise

func (*Performance) LoadMeasurementsFromDB

func (perf *Performance) LoadMeasurementsFromDB(ctx context.Context, userID string) error

loadMeasurementsFromDB populates the measurements array with values from the database

func (*Performance) LogSummary

func (perf *Performance) LogSummary()

LogSummary will log a summary of the performance simulation

func (*Performance) MWRR

func (perf *Performance) MWRR(periods uint, kind string) float64

MWRR computes the money-weighted rate of return for the specified number of periods if periods = 2, then return (p1 - deposits + withdraws) / p0 if 1 < periods < 252, then return xirr(cashflows) un-annualized else return xirr(cashflows) which is annualized return

func (*Performance) MWRRYtd

func (perf *Performance) MWRRYtd(kind string) float64

MWRRYtd calculates the money weighted YTD return

func (*Performance) MarshalBinary

func (o *Performance) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.CurrentAssets will be replaced with a new value. All nil entries in o.Measurements will be replaced with a new value. All nil entries in o.DrawDowns will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*Performance) MarshalLen

func (o *Performance) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Performance) MarshalTo

func (o *Performance) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.CurrentAssets will be replaced with a new value. All nil entries in o.Measurements will be replaced with a new value. All nil entries in o.DrawDowns will be replaced with a new value.

func (*Performance) MaxDrawDown

func (perf *Performance) MaxDrawDown(periods uint, kind string) *DrawDown

MaxDrawDown returns the largest drawdown over the given number of periods

func (*Performance) NetProfit

func (perf *Performance) NetProfit() float64

NetProfit total profit earned on portfolio

func (*Performance) NetProfitPercent

func (perf *Performance) NetProfitPercent() float64

NetProfitPercent profit earned on portfolio expressed as a percent

func (*Performance) Save

func (perf *Performance) Save(ctx context.Context, userID string) error

func (*Performance) SaveWithTransaction

func (perf *Performance) SaveWithTransaction(ctx context.Context, trx pgx.Tx, userID string) error

func (*Performance) SharpeRatio

func (perf *Performance) SharpeRatio(periods uint, kind string) float64

SharpeRatio The ratio is the average return earned in excess of the risk-free rate per unit of volatility or total risk. Volatility is a measure of the price fluctuations of an asset or portfolio.

Sharpe = (Rp - Rf) / (annualized std. dev)

Monthly values are chosen here to remain consistent with Morningstar and other online data providers.

func (*Performance) Skew

func (perf *Performance) Skew(periods uint, kind string) float64

Skew computes the skew of the portfolio measurements relative to the normal distribution

func (*Performance) SortinoRatio

func (perf *Performance) SortinoRatio(periods uint, kind string) float64

SortinoRatio a variation of the Sharpe ratio that differentiates harmful volatility from total overall volatility by using the asset's standard deviation of negative portfolio returns—downside deviation—instead of the total standard deviation of portfolio returns. The Sortino ratio takes an asset or portfolio's return and subtracts the risk-free rate, and then divides that amount by the asset's downside deviation.

Calculation is based on this paper by Red Rock Capital http://www.redrockcapital.com/Sortino__A__Sharper__Ratio_Red_Rock_Capital.pdf

func (*Performance) StdDev

func (perf *Performance) StdDev(periods uint, kind string) float64

StdDev calculates the annualized standard deviation based off of the monthly price changes. Monthly values are chosen here to remain consistent with Morningstar and other online data providers.

func (*Performance) TWRR

func (perf *Performance) TWRR(periods uint, kind string) float64

TWRR computes the time-weighted rate of return for the specified number of periods

func (*Performance) TWRRYtd

func (perf *Performance) TWRRYtd(kind string) float64

TWRRYtd calculates the time-weighted YTD return

func (*Performance) Top10DrawDowns

func (perf *Performance) Top10DrawDowns(periods uint, kind string) []*DrawDown

Top10DrawDowns computes the top 10 portfolio draw downs. A draw down is defined as the period in which a portfolio falls from its previous peak. Draw downs include the time period of the loss, percent of loss, and when the portfolio recovered

func (*Performance) TrackingError

func (perf *Performance) TrackingError(periods uint) float64

TrackingError is the divergence between the price behavior of a portfolio and the price behavior of a benchmark.

func (*Performance) TreynorRatio

func (perf *Performance) TreynorRatio(periods uint) float64

TreynorRatio also known as the reward-to-volatility ratio, is a performance metric for determining how much excess return was generated for each unit of risk taken on by a portfolio. treynor = Excess Return / Beta

func (*Performance) UlcerIndex

func (perf *Performance) UlcerIndex() float64

UlcerIndex The Ulcer Index (UI) is a technical indicator that measures downside risk in terms of both the depth and duration of price declines. The index increases in value as the price moves farther away from a recent high and falls as the price rises to new highs. The indicator is usually calculated over a 14-day period, with the Ulcer Index showing the percentage drawdown a trader can expect from the high over that period.

The greater the value of the Ulcer Index, the longer it takes for a stock to get back to the former high. Simply stated, it is designed as one measure of volatility only on the downside.

Percentage Drawdown = [(Close - 14-period High Close)/14-period High Close] x 100 Squared Average = (14-period Sum of Percentage Drawdown Squared)/14 Ulcer Index = Square Root of Squared Average

period is number of days to lookback

func (*Performance) UlcerIndexPercentile

func (perf *Performance) UlcerIndexPercentile(periods uint, percentile float64) float64

UlcerIndexPercentile compute average ulcer index over the last N periods

func (*Performance) Unmarshal

func (o *Performance) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Performance) UnmarshalBinary

func (o *Performance) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

func (*Performance) ValueAtYearStart

func (perf *Performance) ValueAtYearStart(dt time.Time) float64

type PerformanceMeasurement

type PerformanceMeasurement struct {
	Time time.Time

	Value float64

	BenchmarkValue float64

	RiskFreeValue float64

	StrategyGrowthOf10K float64

	BenchmarkGrowthOf10K float64

	RiskFreeGrowthOf10K float64

	Holdings []*ReportableHolding

	Justification []*Justification

	TaxLots *TaxLotInfo

	TotalDeposited float64

	TotalWithdrawn float64
	// Time-weighted rate of return
	TWRROneDay float32

	TWRRWeekToDate float32

	TWRROneWeek float32

	TWRRMonthToDate float32

	TWRROneMonth float32

	TWRRThreeMonth float32

	TWRRYearToDate float32

	TWRROneYear float32

	TWRRThreeYear float32

	TWRRFiveYear float32

	TWRRTenYear float32
	// Money-weighted rate of return
	MWRROneDay float32

	MWRRWeekToDate float32

	MWRROneWeek float32

	MWRRMonthToDate float32

	MWRROneMonth float32

	MWRRThreeMonth float32

	MWRRYearToDate float32

	MWRROneYear float32

	MWRRThreeYear float32

	MWRRFiveYear float32

	MWRRTenYear float32
	// GainLoss bucketed by tax treatment
	AfterTaxReturn float64

	BeforeTaxReturn float64

	TaxCostRatio float64

	LongTermCapitalGain float64

	ShortTermCapitalGain float64

	UnrealizedLongTermCapitalGain float64

	UnrealizedShortTermCapitalGain float64

	QualifiedDividend float64

	NonQualifiedDividendAndInterestIncome float64
	// active return
	ActiveReturnOneYear float32

	ActiveReturnThreeYear float32

	ActiveReturnFiveYear float32

	ActiveReturnTenYear float32
	// alpha
	AlphaOneYear float32

	AlphaThreeYear float32

	AlphaFiveYear float32

	AlphaTenYear float32
	// beta
	BetaOneYear float32

	BetaThreeYear float32

	BetaFiveYear float32

	BetaTenYear float32
	// ratios
	CalmarRatio float32

	DownsideDeviation float32

	InformationRatio float32

	KRatio float32

	KellerRatio float32

	SharpeRatio float32

	SortinoRatio float32

	StdDev float32

	TreynorRatio float32

	UlcerIndex float32
}

func LoadMeasurementFromDB

func LoadMeasurementFromDB(ctx context.Context, portfolioID []byte, userID string, forDate time.Time) (*PerformanceMeasurement, error)

LoadMeasurementFromDB reads a single measurement for the `portfolio` on the specified `date`

func (*PerformanceMeasurement) MarshalBinary

func (o *PerformanceMeasurement) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Holdings will be replaced with a new value. All nil entries in o.Justification will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*PerformanceMeasurement) MarshalLen

func (o *PerformanceMeasurement) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*PerformanceMeasurement) MarshalTo

func (o *PerformanceMeasurement) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Holdings will be replaced with a new value. All nil entries in o.Justification will be replaced with a new value.

func (*PerformanceMeasurement) Unmarshal

func (o *PerformanceMeasurement) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*PerformanceMeasurement) UnmarshalBinary

func (o *PerformanceMeasurement) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type PerformanceMeasurementItem

type PerformanceMeasurementItem struct {
	Time time.Time

	Value1 float64

	Value2 float64
}

func (*PerformanceMeasurementItem) MarshalBinary

func (o *PerformanceMeasurementItem) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*PerformanceMeasurementItem) MarshalLen

func (o *PerformanceMeasurementItem) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*PerformanceMeasurementItem) MarshalTo

func (o *PerformanceMeasurementItem) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*PerformanceMeasurementItem) Unmarshal

func (o *PerformanceMeasurementItem) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*PerformanceMeasurementItem) UnmarshalBinary

func (o *PerformanceMeasurementItem) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type PerformanceMeasurementItemList

type PerformanceMeasurementItemList struct {
	Items []*PerformanceMeasurementItem

	FieldNames []string
}

func (*PerformanceMeasurementItemList) MarshalBinary

func (o *PerformanceMeasurementItemList) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Items will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*PerformanceMeasurementItemList) MarshalLen

func (o *PerformanceMeasurementItemList) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*PerformanceMeasurementItemList) MarshalTo

func (o *PerformanceMeasurementItemList) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Items will be replaced with a new value.

func (*PerformanceMeasurementItemList) Unmarshal

func (o *PerformanceMeasurementItemList) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*PerformanceMeasurementItemList) UnmarshalBinary

func (o *PerformanceMeasurementItemList) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type Period

type Period struct {
	Begin time.Time
	End   time.Time
}

type Portfolio

type Portfolio struct {
	ID []byte

	UserID string

	AccountNumber string

	Brokerage string

	AccountType string

	Name string

	IsOpen bool

	LastViewed time.Time

	StartDate time.Time

	EndDate time.Time

	Benchmark string

	StrategyShortcode string

	StrategyArguments string

	Schedule string

	Notifications int32

	Transactions []*Transaction

	CurrentHoldings []*Holding

	TaxLots *TaxLotInfo

	PortfolioType string

	LinkedPortfolios [][]byte

	PredictedAssets *PortfolioHoldingItem
}

func (*Portfolio) MarshalBinary

func (o *Portfolio) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Transactions will be replaced with a new value. All nil entries in o.CurrentHoldings will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*Portfolio) MarshalLen

func (o *Portfolio) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Portfolio) MarshalTo

func (o *Portfolio) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Transactions will be replaced with a new value. All nil entries in o.CurrentHoldings will be replaced with a new value.

func (*Portfolio) Unmarshal

func (o *Portfolio) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Portfolio) UnmarshalBinary

func (o *Portfolio) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type PortfolioHoldingItem

type PortfolioHoldingItem struct {
	Time time.Time

	Holdings []*ReportableHolding

	Justification []*Justification

	PercentReturn float64

	Value float64

	Predicted bool
}

func BuildPredictedHoldings

func BuildPredictedHoldings(tradeDate time.Time, target map[data.Security]float64, justificationMap map[string]float64) *PortfolioHoldingItem

BuildPredictedHoldings creates a PortfolioHoldingItem from a date, target map, and justification map

func (*PortfolioHoldingItem) MarshalBinary

func (o *PortfolioHoldingItem) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Holdings will be replaced with a new value. All nil entries in o.Justification will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*PortfolioHoldingItem) MarshalLen

func (o *PortfolioHoldingItem) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*PortfolioHoldingItem) MarshalTo

func (o *PortfolioHoldingItem) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Holdings will be replaced with a new value. All nil entries in o.Justification will be replaced with a new value.

func (*PortfolioHoldingItem) Unmarshal

func (o *PortfolioHoldingItem) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*PortfolioHoldingItem) UnmarshalBinary

func (o *PortfolioHoldingItem) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type PortfolioHoldingItemList

type PortfolioHoldingItemList struct {
	Items []*PortfolioHoldingItem
}

func (*PortfolioHoldingItemList) MarshalBinary

func (o *PortfolioHoldingItemList) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Items will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*PortfolioHoldingItemList) MarshalLen

func (o *PortfolioHoldingItemList) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*PortfolioHoldingItemList) MarshalTo

func (o *PortfolioHoldingItemList) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Items will be replaced with a new value.

func (*PortfolioHoldingItemList) Unmarshal

func (o *PortfolioHoldingItemList) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*PortfolioHoldingItemList) UnmarshalBinary

func (o *PortfolioHoldingItemList) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type PortfolioTransactionList

type PortfolioTransactionList struct {
	Items []*Transaction
}

func (*PortfolioTransactionList) MarshalBinary

func (o *PortfolioTransactionList) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Items will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*PortfolioTransactionList) MarshalLen

func (o *PortfolioTransactionList) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*PortfolioTransactionList) MarshalTo

func (o *PortfolioTransactionList) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Items will be replaced with a new value.

func (*PortfolioTransactionList) Unmarshal

func (o *PortfolioTransactionList) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*PortfolioTransactionList) UnmarshalBinary

func (o *PortfolioTransactionList) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type ReportableHolding

type ReportableHolding struct {
	CompositeFIGI string

	Ticker string

	Shares float64

	PercentPortfolio float32

	Value float64
}

func (*ReportableHolding) MarshalBinary

func (o *ReportableHolding) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*ReportableHolding) MarshalLen

func (o *ReportableHolding) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*ReportableHolding) MarshalTo

func (o *ReportableHolding) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*ReportableHolding) Unmarshal

func (o *ReportableHolding) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*ReportableHolding) UnmarshalBinary

func (o *ReportableHolding) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type Returns

type Returns struct {
	MWRRSinceInception float64

	MWRRYTD float64

	MWRROneYear float64

	MWRRThreeYear float64

	MWRRFiveYear float64

	MWRRTenYear float64

	TWRRSinceInception float64

	TWRRYTD float64

	TWRROneYear float64

	TWRRThreeYear float64

	TWRRFiveYear float64

	TWRRTenYear float64
}

func (*Returns) MarshalBinary

func (o *Returns) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*Returns) MarshalLen

func (o *Returns) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Returns) MarshalTo

func (o *Returns) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*Returns) Unmarshal

func (o *Returns) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Returns) UnmarshalBinary

func (o *Returns) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type TaxLot added in v0.6.0

type TaxLot struct {
	Date time.Time

	TransactionID []byte

	CompositeFIGI string

	Ticker string

	Shares float64

	PricePerShare float64
}

func (*TaxLot) MarshalBinary added in v0.6.0

func (o *TaxLot) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. The error return option is portfolio.ColferMax.

func (*TaxLot) MarshalLen added in v0.6.0

func (o *TaxLot) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*TaxLot) MarshalTo added in v0.6.0

func (o *TaxLot) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic.

func (*TaxLot) MarshalZerologObject added in v0.6.0

func (o *TaxLot) MarshalZerologObject(e *zerolog.Event)

func (*TaxLot) Security added in v0.6.0

func (t *TaxLot) Security() *data.Security

Security returns the security associated with the tax lot

func (*TaxLot) Unmarshal added in v0.6.0

func (o *TaxLot) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*TaxLot) UnmarshalBinary added in v0.6.0

func (o *TaxLot) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

type TaxLotInfo added in v0.6.0

type TaxLotInfo struct {
	AsOf time.Time

	Items []*TaxLot

	Method string
}

func (*TaxLotInfo) AdjustForSplit added in v0.6.0

func (t *TaxLotInfo) AdjustForSplit(security *data.Security, splitFactor float64)

LinkWithFIFOMethod identifies tax lots using the first-in, first-out method where the oldest shares acquired are sold first

func (*TaxLotInfo) CheckIfDividendIsQualified added in v0.6.0

func (t *TaxLotInfo) CheckIfDividendIsQualified(trx *Transaction) bool

CheckIfDividendIsQualified verifies if the specified dividend should be treated as a qualified dividend or non-qualified Qualified dividends are defined in IRS publication 550 (https://www.irs.gov/forms-pubs/about-publication-550) The maximum rate on qualified dividends applies only if all of the following requirements are met.

  • The dividends must have been paid by a U.S. corporation or a qualified foreign corporation. (See table 1-3 in pub 550)
  • The dividends are not of the type listed later under Dividends that are not qualified dividends. (see pub 550)
  • Stock has been held for more than 60 days during the 121-day period that begins 60 days before the ex-dividend date. The ex-dividend date is the first date following the declaration of a dividend on which the buyer of a stock is not entitled to receive the next dividend payment. When counting the number of days you held the stock, include the day you disposed of the stock, but not the day you acquired it.

For penny vault's purposes all dividends are assumed to be qualifying *if* the holding requirement is met. If only a portion of the dividend meets the holding requirement then penny vault assumes 100% of the dividend is qualified. This assumption may cause penny vault to understate the true tax percentage.

NOTE: if a dividend is not qualified at the time of the ex-dividend date Penny Vault does not re-evaluate if it would be come qualified at a future date. This may cause Penny Vault to over-state the amount of taxes paid on dividends

func (*TaxLotInfo) Copy added in v0.6.0

func (t *TaxLotInfo) Copy() *TaxLotInfo

func (*TaxLotInfo) LinkTransactionsWithTaxLots added in v0.6.0

func (t *TaxLotInfo) LinkTransactionsWithTaxLots(sell *Transaction) []*Transaction

LinkTransactionsWithTaxLots identifies which tax lots should be linked with the sell transaction and calculate a gain/loss for the transaction based on the identified tax lots

func (*TaxLotInfo) LinkWithFIFOMethod added in v0.6.0

func (t *TaxLotInfo) LinkWithFIFOMethod(sell *Transaction) []*Transaction

LinkWithFIFOMethod identifies tax lots using the first-in, first-out method where the oldest shares acquired are sold first

func (*TaxLotInfo) MarshalBinary added in v0.6.0

func (o *TaxLotInfo) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Items will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*TaxLotInfo) MarshalLen added in v0.6.0

func (o *TaxLotInfo) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*TaxLotInfo) MarshalTo added in v0.6.0

func (o *TaxLotInfo) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Items will be replaced with a new value.

func (*TaxLotInfo) Unmarshal added in v0.6.0

func (o *TaxLotInfo) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*TaxLotInfo) UnmarshalBinary added in v0.6.0

func (o *TaxLotInfo) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

func (*TaxLotInfo) Update added in v0.6.0

func (t *TaxLotInfo) Update(date time.Time, buys []*Transaction, sells []*Transaction) []*Transaction

Update the TaxLotInfo structure wuth the specified buy and sell transactions using the specified trax lot identification method

type Transaction

type Transaction struct {
	ID []byte

	Cleared bool

	Commission float64

	CompositeFIGI string

	Date time.Time

	GainLoss float64

	Justification []*Justification

	Kind string

	Memo string

	Predicted bool

	PricePerShare float64

	Related [][]byte

	Shares float64

	Source string

	SourceID string

	Tags []string

	TaxDisposition string

	Ticker string

	TotalValue float64
}

func (*Transaction) MarshalBinary

func (o *Transaction) MarshalBinary() (data []byte, err error)

MarshalBinary encodes o as Colfer conform encoding.BinaryMarshaler. All nil entries in o.Justification will be replaced with a new value. The error return option is portfolio.ColferMax.

func (*Transaction) MarshalLen

func (o *Transaction) MarshalLen() (int, error)

MarshalLen returns the Colfer serial byte size. The error return option is portfolio.ColferMax.

func (*Transaction) MarshalTo

func (o *Transaction) MarshalTo(buf []byte) int

MarshalTo encodes o as Colfer into buf and returns the number of bytes written. If the buffer is too small, MarshalTo will panic. All nil entries in o.Justification will be replaced with a new value.

func (*Transaction) MarshalZerologObject added in v0.6.0

func (o *Transaction) MarshalZerologObject(e *zerolog.Event)

func (*Transaction) Security added in v0.6.0

func (trx *Transaction) Security() *data.Security

Security returns the security associated with the transaction

func (*Transaction) SplitFactor added in v0.6.0

func (trx *Transaction) SplitFactor() float64

SplitFactor returns the split factor of the split transaction. If the transaction is not a Split transaction then returns 1.0

func (*Transaction) Unmarshal

func (o *Transaction) Unmarshal(data []byte) (int, error)

Unmarshal decodes data as Colfer and returns the number of bytes read. The error return options are io.EOF, portfolio.ColferError and portfolio.ColferMax.

func (*Transaction) UnmarshalBinary

func (o *Transaction) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes data as Colfer conform encoding.BinaryUnmarshaler. The error return options are io.EOF, portfolio.ColferError, portfolio.ColferTail and portfolio.ColferMax.

Jump to

Keyboard shortcuts

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