store

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeTimestamp added in v0.8.4

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

Types

type Candle

type Candle struct {
	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"`
	High       float64    `json:"high"`
	Low        float64    `json:"low"`
	Close      float64    `json:"close"`
	PrevClose  float64    `json:"prevClose,omitempty"`
	Volume     float64    `json:"volume,omitempty"`
}

func NormalizeCandles added in v0.8.4

func NormalizeCandles(candles []*Candle) []*Candle

func (*Candle) Bytes

func (candle *Candle) Bytes() []byte

func (*Candle) FromBytes

func (candle *Candle) FromBytes(b []byte)

type Combined added in v0.6.42

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

func (*Combined) Candles added in v0.6.42

func (c *Combined) Candles(res Resolution, symbol string, from, to time.Time) ([]*Candle, error)

func (*Combined) Peers added in v0.6.42

func (c *Combined) Peers(symbol string) ([]string, error)

func (*Combined) Quote added in v0.6.42

func (c *Combined) Quote(symbol string) (*Candle, error)

func (*Combined) RecommendationTrends added in v0.6.42

func (c *Combined) RecommendationTrends(symbol string) (*RecommendationTrends, error)

type Finnhub

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

func (*Finnhub) Candles

func (f *Finnhub) Candles(res Resolution, symbol string, from time.Time, to time.Time) ([]*Candle, error)

func (*Finnhub) Peers

func (f *Finnhub) Peers(symbol string) ([]string, error)

func (*Finnhub) Quote

func (f *Finnhub) Quote(symbol string) (*Candle, error)

func (*Finnhub) RecommendationTrends

func (f *Finnhub) RecommendationTrends(symbol string) (*RecommendationTrends, error)

type NOP added in v0.6.42

type NOP struct {
}

func (*NOP) Candles added in v0.6.42

func (nop *NOP) Candles(res Resolution, symbol string, from, to time.Time) ([]*Candle, error)

func (*NOP) Peers added in v0.6.42

func (nop *NOP) Peers(symbol string) ([]string, error)

func (*NOP) Quote added in v0.6.42

func (nop *NOP) Quote(symbol string) (*Candle, error)

func (*NOP) RecommendationTrends added in v0.6.42

func (nop *NOP) RecommendationTrends(symbol string) (*RecommendationTrends, error)

type Note added in v0.7.1

type Note struct {
	Name    string `gorm:"primarykey" json:"name"`
	Content string `json:"content"`
}

type RecommendationTrends

type RecommendationTrends struct {
	Buy        int64 `json:"buy"`
	StrongBuy  int64 `json:"strongBuy"`
	Sell       int64 `json:"sell"`
	StrongSell int64 `json:"strongSell"`
	Hold       int64 `json:"hold"`
}

func (*RecommendationTrends) Bytes

func (rt *RecommendationTrends) Bytes() []byte

func (*RecommendationTrends) FromBytes

func (rt *RecommendationTrends) FromBytes(b []byte)

type Resolution

type Resolution byte
const (
	Minute Resolution = iota
	Hour
	Day
	Month
)

type Source

type Source interface {
	Quote(symbol string) (*Candle, error)
	Candles(res Resolution, symbol string, from, to time.Time) ([]*Candle, error)
	RecommendationTrends(symbol string) (*RecommendationTrends, error)
	Peers(symbol string) ([]string, error)
}

func NewCombined added in v0.6.42

func NewCombined(source ...Source) Source

func NewFinnhub

func NewFinnhub(token string) Source

func NewNOP added in v0.6.42

func NewNOP() Source

func NewYahoo added in v0.6.42

func NewYahoo() Source

type Store

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

func NewStore

func NewStore(db *gorm.DB, cache *cache.Cache[[]byte], source Source) *Store

func NewTestStore

func NewTestStore() *Store

func (*Store) Candles

func (s *Store) Candles(res Resolution, symbol string, from, to time.Time) ([]*Candle, error)

func (*Store) Close

func (s *Store) Close()

func (*Store) CreateNote added in v0.7.1

func (s *Store) CreateNote(name, content string) error

func (*Store) DeleteNote added in v0.7.1

func (s *Store) DeleteNote(name string) error

func (*Store) GetNote added in v0.7.1

func (s *Store) GetNote(name string) (*Note, error)

func (*Store) ListNotes added in v0.7.1

func (s *Store) ListNotes() ([]*Note, error)

func (*Store) Peers

func (s *Store) Peers(symbol string) ([]string, error)

func (*Store) Quote

func (s *Store) Quote(symbol string) (*Candle, error)

func (*Store) RecommendationTrends

func (s *Store) RecommendationTrends(symbol string) (*RecommendationTrends, error)

func (*Store) UpdateNote added in v0.7.1

func (s *Store) UpdateNote(name, content string) error

type Yahoo added in v0.6.42

type Yahoo struct {
	http.Client
}

func (*Yahoo) Candles added in v0.6.42

func (y *Yahoo) Candles(res Resolution, symbol string, from, to time.Time) ([]*Candle, error)

func (*Yahoo) Peers added in v0.6.42

func (y *Yahoo) Peers(symbol string) ([]string, error)

func (*Yahoo) Quote added in v0.6.42

func (y *Yahoo) Quote(symbol string) (*Candle, error)

func (*Yahoo) RecommendationTrends added in v0.6.42

func (y *Yahoo) RecommendationTrends(symbol string) (*RecommendationTrends, error)

Jump to

Keyboard shortcuts

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