analysis

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

type Analysis interface {
	Analyze(*trading.TradingRecord) float64
}

Analysis is an interface that describes a methodology for taking a trading.TradingRecord as input, and giving back some float value that describes it's performance with respect to that methodology.

type AverageProfitAnalysis

type AverageProfitAnalysis struct{}

AverageProfitAnalysis returns the average profit for the trading record. Average profit is represented as the total profit divided by the number of trades executed.

func (AverageProfitAnalysis) Analyze

func (apa AverageProfitAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze returns the average profit of the trading record

type BuyAndHoldAnalysis

type BuyAndHoldAnalysis struct {
	TimeSeries    *series.TimeSeries
	StartingMoney float64
}

BuyAndHoldAnalysis returns the profit based on a hypothetical where a purchase order was made on the first period available and held until the date on the last trade of the trading record. It's useful for comparing the performance of your strategy against a simple long position.

func (BuyAndHoldAnalysis) Analyze

func (baha BuyAndHoldAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze returns the profit based on a simple buy and hold strategy

type LogTradesAnalysis

type LogTradesAnalysis struct {
	io.Writer
}

LogTradesAnalysis is a wrapper around an io.Writer, which logs every trade executed to that writer

func (LogTradesAnalysis) Analyze

func (lta LogTradesAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze logs trades to provided io.Writer

type NumTradesAnalysis

type NumTradesAnalysis string

NumTradesAnalysis analyzes the trading record for the number of trades executed

func (NumTradesAnalysis) Analyze

func (nta NumTradesAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze analyzes the trading record for the number of trades executed

type PercentGainAnalysis

type PercentGainAnalysis struct{}

PercentGainAnalysis analyzes the trading record for the percentage profit gained relative to start

func (PercentGainAnalysis) Analyze

func (pga PercentGainAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze analyzes the trading record for the percentage profit gained relative to start

type PeriodProfitAnalysis

type PeriodProfitAnalysis struct {
	Period time.Duration
}

PeriodProfitAnalysis analyzes the trading record for the average profit based on the time period provided. i.e., if the trading record spans a year of trading, and PeriodProfitAnalysis wraps one month, Analyze will return the total profit for the whole time period divided by 12.

func (PeriodProfitAnalysis) Analyze

func (ppa PeriodProfitAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze returns the average profit for the trading record based on the given duration

type ProfitableTradesAnalysis

type ProfitableTradesAnalysis struct{}

ProfitableTradesAnalysis analyzes the trading record for the number of profitable trades

func (ProfitableTradesAnalysis) Analyze

Analyze returns the number of profitable trades in a trading record

type TotalProfitAnalysis

type TotalProfitAnalysis struct{}

TotalProfitAnalysis analyzes the trading record for total profit.

func (TotalProfitAnalysis) Analyze

func (tps TotalProfitAnalysis) Analyze(record *trading.TradingRecord) float64

Analyze analyzes the trading record for total profit.

Jump to

Keyboard shortcuts

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