common

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 8 Imported by: 0

README

GoCryptoTrader Backtester: Common package

Build Status Software License GoDoc Coverage Status Go Report Card

This common 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

Common package overview

Common contains some basic data types which are used throughout.

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

View Source
const (
	// DoNothing is an explicit signal for the backtester to not perform an action
	// based upon indicator results
	DoNothing order.Side = "DO NOTHING"
	// TransferredFunds is a status signal to do nothing
	TransferredFunds order.Side = "TRANSFERRED FUNDS"
	// CouldNotBuy is flagged when a BUY  signal is raised in the strategy/signal phase, but the
	// portfolio manager or exchange cannot place an order
	CouldNotBuy order.Side = "COULD NOT BUY"
	// CouldNotSell is flagged when a SELL  signal is raised in the strategy/signal phase, but the
	// portfolio manager or exchange cannot place an order
	CouldNotSell order.Side = "COULD NOT SELL"
	// MissingData is signalled during the strategy/signal phase when data has been identified as missing
	// No buy or sell events can occur
	MissingData order.Side = "MISSING DATA"
	// CandleStr is a config readable data type to tell the backtester to retrieve candle data
	CandleStr = "candle"
	// TradeStr is a config readable data type to tell the backtester to retrieve trade data
	TradeStr = "trade"
)
View Source
const (
	DataCandle = iota
	DataTrade
)

DataCandle is an int64 representation of a candle data type

View Source

ASCIILogo is a sweet logo that is optionally printed to the command line window

Variables

View Source
var (
	// ErrNilArguments is a common error response to highlight that nils were passed in
	// when they should not have been
	ErrNilArguments = errors.New("received nil argument(s)")
	// ErrNilEvent is a common error for whenever a nil event occurs when it shouldn't have
	ErrNilEvent = errors.New("nil event received")
	// ErrInvalidDataType occurs when an invalid data type is defined in the config
	ErrInvalidDataType = errors.New("invalid datatype received")
)

Functions

func DataTypeToInt

func DataTypeToInt(dataType string) (int64, error)

DataTypeToInt converts the config string value into an int

Types

type DataEventHandler

type DataEventHandler interface {
	EventHandler
	GetClosePrice() decimal.Decimal
	GetHighPrice() decimal.Decimal
	GetLowPrice() decimal.Decimal
	GetOpenPrice() decimal.Decimal
}

DataEventHandler interface used for loading and interacting with Data

type Directioner

type Directioner interface {
	SetDirection(side order.Side)
	GetDirection() order.Side
}

Directioner dictates the side of an order

type EventHandler

type EventHandler interface {
	GetOffset() int64
	SetOffset(int64)
	IsEvent() bool
	GetTime() time.Time
	Pair() currency.Pair
	GetExchange() string
	GetInterval() kline.Interval
	GetAssetType() asset.Item
	GetReason() string
	AppendReason(string)
}

EventHandler interface implements required GetTime() & Pair() return

Jump to

Keyboard shortcuts

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