models

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeltaRange

func DeltaRange(resolution Resolution, delta int) (time.Time, time.Time)

func MonthsDiff

func MonthsDiff(from, to time.Time) int64

func NormalizeTimestamp

func NormalizeTimestamp(res Resolution, t time.Time) (time.Time, error)

func RangeBetweenTimestamps

func RangeBetweenTimestamps(res Resolution, from, to time.Time) (int64, error)

Types

type Candle

type Candle struct {
	Source     string     `json:"source,omitempty" gorm:"index:idx_unique_candle,unique"`
	Symbol     string     `json:"symbol,omitempty" gorm:"index:idx_unique_candle,unique"`
	Timestamp  time.Time  `json:"timestamp,omitempty" gorm:"index:idx_unique_candle,unique"`
	Resolution Resolution `json:"resolution,omitempty" gorm:"index:idx_unique_candle,unique"`
	Open       float64    `json:"open,omitempty"`
	High       float64    `json:"high,omitempty"`
	Low        float64    `json:"low,omitempty"`
	Close      float64    `json:"close,omitempty"`
	PrevClose  float64    `json:"prevClose,omitempty"`
	Volume     float64    `json:"volume,omitempty"`
	Value      float64    `json:"value,omitempty"`
}

func (*Candle) Normalize

func (c *Candle) Normalize() error

type Quote

type Quote struct {
	Source    string    `json:"source"`
	Symbol    string    `json:"symbol"`
	Timestamp time.Time `json:"timestamp"`
	Last      float64   `json:"last"`
}

type Resolution

type Resolution string
const (
	Second         Resolution = "s"
	ThirtySeconds  Resolution = "30s"
	Minute         Resolution = "1m"
	FiveMinutes    Resolution = "5m"
	TenMinutes     Resolution = "10m"
	FifteenMinutes Resolution = "15m"
	ThirtyMinutes  Resolution = "30m"
	Hour           Resolution = "H"
	Day            Resolution = "D"
	Week           Resolution = "W"
	Month          Resolution = "M"
	ThreeMonths    Resolution = "3M"
)

Jump to

Keyboard shortcuts

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