data

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 7 Imported by: 0

README

GoCryptoTrader Backtester: Data package

Build Status Software License GoDoc Coverage Status Go Report Card

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

Data package overview

The data package defines and implements a base version of the Streamer interface which is part of the Handler interface. These interfaces allow for the translation of data into individual intervals to be accessed and assessed as part of the backtest package. This is a base implementation, the more proper implementation that is used throughout the backtester is under ./kline

This can also be used to implement other means to load data for the backtester to process, however kline is currently the only supported method.

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

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

Base is the base implementation of some interface functions where further specific functions are implmented in DataFromKline

func (*Base) AppendStream

func (b *Base) AppendStream(s ...common.DataEventHandler)

AppendStream appends new datas onto the stream, however, will not add duplicates. Used for live analysis

func (*Base) GetStream

func (b *Base) GetStream() []common.DataEventHandler

GetStream will return entire data list

func (*Base) History

func (b *Base) History() []common.DataEventHandler

History will return all previous data events that have happened

func (*Base) Latest

func (b *Base) Latest() common.DataEventHandler

Latest will return latest data event

func (*Base) List

func (b *Base) List() []common.DataEventHandler

List returns all future data events from the current iteration ill-advised to use this in strategies because you don't know the future in real life

func (*Base) Next

func (b *Base) Next() (dh common.DataEventHandler)

Next will return the next event in the list and also shift the offset one

func (*Base) Offset

func (b *Base) Offset() int

Offset returns the current iteration of candle data the backtester is assessing

func (*Base) Reset

func (b *Base) Reset()

Reset loaded data to blank state

func (*Base) SetStream

func (b *Base) SetStream(s []common.DataEventHandler)

SetStream sets the data stream for candle analysis

func (*Base) SortStream

func (b *Base) SortStream()

SortStream sorts the stream by timestamp

type Handler

type Handler interface {
	Loader
	Streamer
	Reset()
}

Handler interface for Loading and Streaming data

type HandlerPerCurrency

type HandlerPerCurrency struct {
	// contains filtered or unexported fields
}

HandlerPerCurrency stores an event handler per exchange asset pair

func (*HandlerPerCurrency) GetAllData

func (h *HandlerPerCurrency) GetAllData() map[string]map[asset.Item]map[currency.Pair]Handler

GetAllData returns all set data in the data map

func (*HandlerPerCurrency) GetDataForCurrency

func (h *HandlerPerCurrency) GetDataForCurrency(e string, a asset.Item, p currency.Pair) Handler

GetDataForCurrency returns the Handler for a specific exchange, asset, currency

func (*HandlerPerCurrency) Reset

func (h *HandlerPerCurrency) Reset()

Reset returns the struct to defaults

func (*HandlerPerCurrency) SetDataForCurrency

func (h *HandlerPerCurrency) SetDataForCurrency(e string, a asset.Item, p currency.Pair, k Handler)

SetDataForCurrency assigns a data Handler to the data map by exchange, asset and currency

func (*HandlerPerCurrency) Setup

func (h *HandlerPerCurrency) Setup()

Setup creates a basic map

type Holder

type Holder interface {
	Setup()
	SetDataForCurrency(string, asset.Item, currency.Pair, Handler)
	GetAllData() map[string]map[asset.Item]map[currency.Pair]Handler
	GetDataForCurrency(string, asset.Item, currency.Pair) Handler
	Reset()
}

Holder interface dictates what a data holder is expected to do

type Loader

type Loader interface {
	Load() error
}

Loader interface for Loading data into backtest supported format

type Streamer

type Streamer interface {
	Next() common.DataEventHandler
	GetStream() []common.DataEventHandler
	History() []common.DataEventHandler
	Latest() common.DataEventHandler
	List() []common.DataEventHandler
	Offset() int

	StreamOpen() []decimal.Decimal
	StreamHigh() []decimal.Decimal
	StreamLow() []decimal.Decimal
	StreamClose() []decimal.Decimal
	StreamVol() []decimal.Decimal

	HasDataAtTime(time.Time) bool
}

Streamer interface handles loading, parsing, distributing BackTest data

Directories

Path Synopsis
api
csv

Jump to

Keyboard shortcuts

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