kline

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FifteenSecond = Interval(15 * time.Second)
	OneMin        = Interval(time.Minute)
	ThreeMin      = 3 * OneMin
	FiveMin       = 5 * OneMin
	TenMin        = 10 * OneMin
	FifteenMin    = 15 * OneMin
	ThirtyMin     = 30 * OneMin
	OneHour       = Interval(time.Hour)
	TwoHour       = 2 * OneHour
	FourHour      = 4 * OneHour
	SixHour       = 6 * OneHour
	EightHour     = 8 * OneHour
	TwelveHour    = 12 * OneHour
	OneDay        = 24 * OneHour
	ThreeDay      = 3 * OneDay
	SevenDay      = 7 * OneDay
	FifteenDay    = 15 * OneDay
	OneWeek       = 7 * OneDay
	TwoWeek       = 2 * OneWeek
	OneMonth      = 31 * OneDay
	OneYear       = 365 * OneDay
)

Consts here define basic time intervals

View Source
const (
	// ErrRequestExceedsExchangeLimits locale for exceeding rate limits message
	ErrRequestExceedsExchangeLimits = "requested data would exceed exchange limits please lower range or use GetHistoricCandlesEx"
)

Variables

This section is empty.

Functions

func StoreInDatabase

func StoreInDatabase(in *Item) (uint64, error)

StoreInDatabase returns Item from database seeded data

func TotalCandlesPerInterval

func TotalCandlesPerInterval(start, end time.Time, interval Interval) (out uint32)

TotalCandlesPerInterval turns total candles per period for interval

Types

type Candle

type Candle struct {
	Time   time.Time
	Open   float64
	High   float64
	Low    float64
	Close  float64
	Volume float64
}

Candle holds historic rate information.

func LoadFromGCTScriptCSV

func LoadFromGCTScriptCSV(file string) (out []Candle, errRet error)

LoadFromGCTScriptCSV loads kline data from a CSV file

type DateRange

type DateRange struct {
	Start time.Time
	End   time.Time
}

DateRange holds a start and end date for kline usage

func CalcDateRanges

func CalcDateRanges(start, end time.Time, interval Interval, limit uint32) (out []DateRange)

CalcDateRanges returns slice of start/end times based on start & end date

type ErrorKline

type ErrorKline struct {
	Asset    asset.Item
	Pair     currency.Pair
	Interval Interval
	Err      error
}

ErrorKline struct to hold kline interval errors

func (*ErrorKline) Error

func (k *ErrorKline) Error() string

Error returns short interval unsupported message

func (*ErrorKline) Unwrap

func (k *ErrorKline) Unwrap() error

Unwrap returns interval unsupported message

type ExchangeCapabilitiesEnabled

type ExchangeCapabilitiesEnabled struct {
	Intervals   map[string]bool `json:"intervals,omitempty"`
	ResultLimit uint32
}

ExchangeCapabilitiesEnabled all kline related exchange enabled options

type ExchangeCapabilitiesSupported

type ExchangeCapabilitiesSupported struct {
	Intervals  bool
	DateRanges bool
}

ExchangeCapabilitiesSupported all kline related exchange supported options

type Interval

type Interval time.Duration

Interval type for kline Interval usage

func (Interval) Duration

func (i Interval) Duration() time.Duration

Duration returns interval casted as time.Duration for compatibility

func (Interval) Short

func (i Interval) Short() string

Short returns short string version of interval

func (Interval) String

func (i Interval) String() string

String returns numeric string

func (Interval) Word

func (i Interval) Word() string

Word returns text version of Interval

type Item

type Item struct {
	Exchange string
	Pair     currency.Pair
	Asset    asset.Item
	Interval Interval
	Candles  []Candle
}

Item holds all the relevant information for internal kline elements

func CreateKline

func CreateKline(trades []order.TradeHistory, interval Interval, p currency.Pair, a asset.Item, exchange string) (Item, error)

CreateKline creates candles out of trade history data for a set time interval

func LoadFromDatabase

func LoadFromDatabase(exchange string, pair currency.Pair, a asset.Item, interval Interval, start, end time.Time) (Item, error)

LoadFromDatabase returns Item from database seeded data

func (*Item) FormatDates

func (k *Item) FormatDates()

FormatDates converts all date to UTC time

func (*Item) SortCandlesByTimestamp

func (k *Item) SortCandlesByTimestamp(desc bool)

SortCandlesByTimestamp sorts candles by timestamp

Jump to

Keyboard shortcuts

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