storage

package
v0.0.0-...-148b98b Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

type Analysis struct {
	ID              uint      `json:"id" gorm:"primary_key;auto_increment"`
	Strategy        string    `json:"strategy" validate:"required"`
	Symbol          string    `json:"symbol" validate:"required"`
	Buys            uint      `json:"buys"`
	Sells           uint      `json:"sells"`
	SuccessfulSells uint      `json:"successfulSells"`
	ProfitUSD       float64   `json:"profitUSD"`
	SuccessRate     float64   `json:"successRate"`
	Timeframe       string    `json:"timeframe"`
	Start           time.Time `json:"start"`
	End             time.Time `json:"end"`
	CreatedAt       time.Time `json:"createdAt"`
}

type GORMClient

type GORMClient struct {
	*gorm.DB
}

func NewGORMClient

func NewGORMClient(dialect gorm.Dialector) (*GORMClient, error)

func (*GORMClient) AutoMigrateAll

func (c *GORMClient) AutoMigrateAll()

func (*GORMClient) AutoMigrateAnalyses

func (c *GORMClient) AutoMigrateAnalyses()

func (*GORMClient) AutoMigrateOrders

func (c *GORMClient) AutoMigrateOrders()

func (*GORMClient) AutoMigrateSettings

func (c *GORMClient) AutoMigrateSettings()

func (*GORMClient) DropAll

func (c *GORMClient) DropAll()

func (*GORMClient) GetAllOrders

func (c *GORMClient) GetAllOrders() ([]Order, error)

func (*GORMClient) GetAllSettings

func (c *GORMClient) GetAllSettings() (map[string]Setting, error)

func (*GORMClient) GetLastOrder

func (c *GORMClient) GetLastOrder(strategy, symbol string) (*Order, error)

func (*GORMClient) GetSetting

func (c *GORMClient) GetSetting(name string) (Setting, error)

func (*GORMClient) StoreAnalyses

func (c *GORMClient) StoreAnalyses(analyses map[string]Analysis) error

func (*GORMClient) StoreOrder

func (c *GORMClient) StoreOrder(order *Order) error

func (*GORMClient) StoreSetting

func (c *GORMClient) StoreSetting(name, value string) error

func (*GORMClient) UpdateSetting

func (c *GORMClient) UpdateSetting(name, value string) (Setting, error)

type InMemoryClient

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

func NewInMemoryClient

func NewInMemoryClient() *InMemoryClient

func (*InMemoryClient) AutoMigrateAll

func (c *InMemoryClient) AutoMigrateAll()

func (*InMemoryClient) AutoMigrateAnalyses

func (c *InMemoryClient) AutoMigrateAnalyses()

func (*InMemoryClient) AutoMigrateOrders

func (c *InMemoryClient) AutoMigrateOrders()

func (*InMemoryClient) AutoMigrateSettings

func (c *InMemoryClient) AutoMigrateSettings()

func (*InMemoryClient) DropAll

func (c *InMemoryClient) DropAll()

func (*InMemoryClient) GetAllOrders

func (c *InMemoryClient) GetAllOrders() ([]Order, error)

func (*InMemoryClient) GetAllSettings

func (c *InMemoryClient) GetAllSettings() (map[string]Setting, error)

func (*InMemoryClient) GetLastOrder

func (c *InMemoryClient) GetLastOrder(strategy, symbol string) (*Order, error)

func (*InMemoryClient) GetSetting

func (c *InMemoryClient) GetSetting(name string) (Setting, error)

func (*InMemoryClient) StoreAnalyses

func (c *InMemoryClient) StoreAnalyses(analyses map[string]Analysis) error

func (*InMemoryClient) StoreOrder

func (c *InMemoryClient) StoreOrder(order *Order) error

func (*InMemoryClient) StoreSetting

func (c *InMemoryClient) StoreSetting(name, value string) error

func (*InMemoryClient) UpdateSetting

func (c *InMemoryClient) UpdateSetting(name, value string) (Setting, error)

type Order

type Order struct {
	ID         uint              `json:"id" gorm:"primary_key;auto_increment"`
	Strategy   string            `json:"strategy"`
	Symbol     string            `json:"symbol"`
	Decision   string            `json:"decision"`
	Quantity   float64           `json:"quantity"`
	Price      float64           `json:"price"`
	Indicators map[string]string `json:"indicators" gorm:"serializer:json"`
	Timeframe  string            `json:"timeframe"`
	Successful bool              `json:"successful"`
	CreatedAt  time.Time         `json:"createdAt"`
}

type Setting

type Setting struct {
	Name     string   `json:"name" gorm:"primary_key"`
	Value    string   `json:"value"`
	ValueArr []string `json:"valueArr" gorm:"-"`
}

type StorageClient

type StorageClient interface {
	AutoMigrateAll()
	AutoMigrateOrders()
	AutoMigrateSettings()
	AutoMigrateAnalyses()
	DropAll()
	GetAllSettings() (map[string]Setting, error)
	GetSetting(name string) (Setting, error)
	UpdateSetting(name, value string) (Setting, error)
	StoreSetting(name, value string) error
	GetAllOrders() ([]Order, error)
	GetLastOrder(strategy, symbol string) (*Order, error)
	StoreOrder(order *Order) error
	StoreAnalyses(analyses map[string]Analysis) error
}

Jump to

Keyboard shortcuts

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