Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInitialFundsZero = errors.New("initial funds < 0")
ErrInitialFundsZero is an error when initial funds are zero or less
Functions ¶
This section is empty.
Types ¶
type ClosePriceReader ¶
type ClosePriceReader interface { common.EventHandler GetClosePrice() decimal.Decimal }
ClosePriceReader is used for holdings calculations without needing to consider event types
type Holding ¶
type Holding struct { Offset int64 Item currency.Code Pair currency.Pair Asset asset.Item `json:"asset"` Exchange string `json:"exchange"` Timestamp time.Time `json:"timestamp"` BaseInitialFunds decimal.Decimal `json:"base-initial-funds"` BaseSize decimal.Decimal `json:"base-size"` BaseValue decimal.Decimal `json:"base-value"` QuoteInitialFunds decimal.Decimal `json:"quote-initial-funds"` TotalInitialValue decimal.Decimal `json:"total-initial-value"` QuoteSize decimal.Decimal `json:"quote-size"` SoldAmount decimal.Decimal `json:"sold-amount"` SoldValue decimal.Decimal `json:"sold-value"` BoughtAmount decimal.Decimal `json:"bought-amount"` BoughtValue decimal.Decimal `json:"bought-value"` TotalValueDifference decimal.Decimal ChangeInTotalValuePercent decimal.Decimal BoughtValueDifference decimal.Decimal SoldValueDifference decimal.Decimal PositionsValueDifference decimal.Decimal TotalValue decimal.Decimal `json:"total-value"` TotalFees decimal.Decimal `json:"total-fees"` TotalValueLostToVolumeSizing decimal.Decimal `json:"total-value-lost-to-volume-sizing"` TotalValueLostToSlippage decimal.Decimal `json:"total-value-lost-to-slippage"` TotalValueLost decimal.Decimal `json:"total-value-lost"` }
Holding contains pricing statistics for a given time for a given exchange asset pair
func Create ¶
func Create(ev ClosePriceReader, funding funding.IPairReader) (Holding, error)
Create makes a Holding struct to track total values of strategy holdings over the course of a backtesting run
func (*Holding) HasInvestments ¶
HasInvestments determines whether there are any holdings in the base funds
func (*Holding) Update ¶
func (h *Holding) Update(e fill.Event, f funding.IPairReader)
Update calculates holding statistics for the events time
func (*Holding) UpdateValue ¶
func (h *Holding) UpdateValue(d common.DataEventHandler)
UpdateValue calculates the holding's value for a data event's time and price
Click to show internal directories.
Click to hide internal directories.