holdings

package
v0.0.0-...-ae86ed1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 7 Imported by: 0

README

GoCryptoTrader Backtester: Holdings package

Build Status Software License GoDoc Coverage Status Go Report Card

This holdings package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Holdings package overview

Holdings are used to calculate the holdings at any given time for a given exchange, asset, currency pair. If an order is placed, funds are removed from funding and placed under assets. Every data event will update and calculate holdings value based on the new price. This will allow for statistics to be easily calculated at the end of a backtesting run

Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

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 Holding

type Holding struct {
	Offset         int64
	Pair           currency.Pair `json:"pair"`
	Asset          asset.Item    `json:"asset"`
	Exchange       string        `json:"exchange"`
	Timestamp      time.Time     `json:"timestamp"`
	InitialFunds   float64       `json:"initial-funds"`
	PositionsSize  float64       `json:"positions-size"`
	PositionsValue float64       `json:"postions-value"`
	SoldAmount     float64       `json:"sold-amount"`
	SoldValue      float64       `json:"sold-value"`
	BoughtAmount   float64       `json:"bought-amount"`
	BoughtValue    float64       `json:"bought-value"`
	RemainingFunds float64       `json:"remaining-funds"`
	CommittedFunds float64       `json:"committed-funds"`

	TotalValueDifference      float64
	ChangeInTotalValuePercent float64
	BoughtValueDifference     float64
	SoldValueDifference       float64
	PositionsValueDifference  float64

	TotalValue                   float64 `json:"total-value"`
	TotalFees                    float64 `json:"total-fees"`
	TotalValueLostToVolumeSizing float64 `json:"total-value-lost-to-volume-sizing"`
	TotalValueLostToSlippage     float64 `json:"total-value-lost-to-slippage"`
	TotalValueLost               float64 `json:"total-value-lost"`

	RiskFreeRate float64 `json:"risk-free-rate"`
}

Holding contains pricing statistics for a given time for a given exchange asset pair

func Create

func Create(f fill.Event, initialFunds, riskFreeRate float64) (Holding, error)

Create takes a fill event and creates a new holding for the exchange, asset, pair

func (*Holding) Update

func (h *Holding) Update(f fill.Event)

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

Jump to

Keyboard shortcuts

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