models

package
v0.0.0-...-b9d0dff Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func MigrateTables

func MigrateTables(conn *database.Connection) (err error)

Types

type Candle

type Candle struct {
	ID        uint `gorm:"primarykey;autoIncrement"`
	CreatedAt time.Time
	UpdatedAt time.Time

	// Friendly name of the exchange
	ExchangeName string `gorm:"index;not null;uniqueIndex:unique_candle"`
	// Trading currency of the symbol
	Currency *Currency `gorm:"index;not null;uniqueIndex:unique_candle"`
	// API source, useful from identifying from where the data was retrieved
	Source string `gorm:"index;not null;uniqueIndex:unique_candle"`
	// Ticker symbol
	Symbol string `gorm:"index;not null;uniqueIndex:unique_candle"`
	// Interval in which the prices are moving daily, weekly or monthly
	Interval Interval `gorm:"index;not null;uniqueIndex:unique_candle"`
	// Timezone of the passed time
	Timezone *Timezone `gorm:"index;not null;uniqueIndex:unique_candle"`
	// Timestamp of the values
	Time time.Time `gorm:"index;not null;uniqueIndex:unique_candle"`

	Open   uint64 `gorm:"index;not null"`
	High   uint64 `gorm:"index;not null"`
	Low    uint64 `gorm:"index;not null"`
	Close  uint64 `gorm:"index;not null"`
	Volume uint64 `gorm:"index;not null"`
}

Candle records

func (*Candle) String

func (c *Candle) String() (s string)

type Currency

type Currency struct {
	Name   string
	Code   int
	Digits int
}

Helper type to manage currencies inside the database

func NewCurrency

func NewCurrency(s string) (curr *Currency, err error)

func (*Currency) MarshalJSON

func (c *Currency) MarshalJSON() (b []byte, err error)

func (*Currency) Scan

func (c *Currency) Scan(src any) (err error)

func (*Currency) String

func (c *Currency) String() (s string)

func (*Currency) UnmarshalJSON

func (c *Currency) UnmarshalJSON(b []byte) (err error)

func (*Currency) Value

func (c *Currency) Value() (value driver.Value, err error)

type Interval

type Interval string

Helper type to handle intervals into the database

const (
	IntervalDaily   Interval = "daily"
	IntervalWeekly  Interval = "weekly"
	IntervalMonthly Interval = "monthly"
)

func (*Interval) MarshalYAML

func (i *Interval) MarshalYAML() (v interface{}, err error)

func (Interval) Normalize

func (i Interval) Normalize(t time.Time) (out time.Time, err error)

Use in intervals such as [from, to)

func (*Interval) UnmarshalYAML

func (i *Interval) UnmarshalYAML(value *yaml.Node) (err error)

type Timezone

type Timezone struct {
	Location *time.Location
}

Helper type to insert time.Location into the database

func NewTimezone

func NewTimezone(locationS string) (tz *Timezone, err error)

func (*Timezone) MarshalJSON

func (t *Timezone) MarshalJSON() (b []byte, err error)

func (*Timezone) Scan

func (t *Timezone) Scan(src any) (err error)

func (*Timezone) String

func (t *Timezone) String() (s string)

func (*Timezone) UnmarshalJSON

func (t *Timezone) UnmarshalJSON(b []byte) (err error)

func (*Timezone) Value

func (t *Timezone) Value() (value driver.Value, err error)

Directories

Path Synopsis