model

package
v0.0.0-...-69a75dd Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB Database
	DB *gorm.DB
)

Functions

This section is empty.

Types

type Algorithm

type Algorithm struct {
	ID             int64      `gorm:"primary_key" json:"id"`
	UserID         int64      `gorm:"index" json:"userId"`
	Name           string     `gorm:"type:varchar(200)" json:"name"`
	Description    string     `gorm:"type:text" json:"description"`
	DefaultDataApi string     `gorm:"type:varchar(30)" json:"defaultDataApi"`
	Script         string     `gorm:"type:text" json:"script"`
	EvnDefault     string     `gorm:"type:text" json:"evnDefault"`
	CreatedAt      time.Time  `json:"createdAt"`
	UpdatedAt      time.Time  `json:"updatedAt"`
	DeletedAt      *time.Time `sql:"index" json:"-"`

	Traders []Trader `gorm:"-" json:"traders"`
}

Algorithm struct

type ApiConfig

type ApiConfig struct {
	ID           int64      `gorm:"primary_key" json:"id"`
	UserID       int64      `gorm:"index" json:"userId"`
	FuncName     string     `gorm:"type:varchar(50)" json:"funcName"`
	ExchangeType string     `gorm:"type:varchar(50)" json:"exchangeType"`
	Status       string     `gorm:"type:varchar(50);default:N" json:"status"`
	InstId       string     `gorm:"type:varchar(50);default:N" json:"instId"`
	Period       int        `gorm:"type:int" json:"period"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	DeletedAt    *time.Time `sql:"index" json:"-"`
	Exchanges    Exchange   `gorm:"-" json:"exchange"`
}

ApiConfig struct

func GetTaskConfig

func GetTaskConfig(exchangeType, funcName string, instId string, period int) (apiConfig ApiConfig, err error)

GetUser ...

func GetTaskConfigById

func GetTaskConfigById(id int) (apiConfig ApiConfig, err error)

func ListApiConfig

func ListApiConfig() (apiConfig []ApiConfig, err error)

ListAlgorithm ...

type Exchange

type Exchange struct {
	ID           int64      `gorm:"primary_key" json:"id"`
	UserID       int64      `gorm:"index" json:"userId"`
	Name         string     `gorm:"type:varchar(50)" json:"name"`
	ExchangeType string     `gorm:"type:varchar(50)" json:"type"`
	AccessKey    string     `gorm:"type:varchar(200)" json:"accessKey"`
	SecretKey    string     `gorm:"type:varchar(200)" json:"secretKey"`
	Passphrase   string     `gorm:"type:varchar(200)" json:"passphrase"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	DeletedAt    *time.Time `sql:"index" json:"-"`
	Test         string
}

Exchange struct

func GetExchange

func GetExchange(exchangeType string) (exchange Exchange, err error)

GetUser ...

type Log

type Log struct {
	ID           int64   `gorm:"primary_key;AUTO_INCREMENT" json:"id"`
	TraderID     int64   `gorm:"index" json:"-"`
	Timestamp    int64   `json:"-"`
	ExchangeType string  `gorm:"type:varchar(50)" json:"exchangeType"`
	Type         string  `json:"type"` // [-1"error", 0"info", 1"profit", 2"buy", 3"sell", 4"cancel", 5"long", 6"short", 7"long_close", 8"short_close"]
	StockType    string  `gorm:"type:varchar(20)" json:"stockType"`
	Price        float64 `json:"price"`
	Amount       float64 `json:"amount"`
	Message      string  `gorm:"type:text" json:"message"`

	Time time.Time `gorm:"-" json:"time"`
}

Log struct

type Logger

type Logger struct {
	TraderID     int64
	ExchangeType string
}

Logger struct

func (Logger) Log

func (l Logger) Log(method string, stockType string, price, amount float64, messages ...interface{})

Log ...

type Trader

type Trader struct {
	ID          int64       `gorm:"primary_key" json:"id"`
	UserID      int64       `gorm:"index" json:"userId"`
	AlgorithmID int64       `gorm:"index" json:"algorithmId"`
	Api         []ApiConfig `gorm:"-" json:"api"`
	Name        string      `gorm:"type:varchar(200)" json:"name"`
	Environment string      `gorm:"type:text" json:"environment"`
	LastRunAt   time.Time   `json:"lastRunAt"`
	CreatedAt   time.Time   `json:"createdAt"`
	UpdatedAt   time.Time   `json:"updatedAt"`
	DeletedAt   *time.Time  `sql:"index" json:"-"`

	Exchanges []Exchange `gorm:"-" json:"exchanges"`
	Status    int64      `gorm:"-" json:"status"`
	Algorithm Algorithm  `gorm:"-" json:"algorithm"`
}

Trader struct

type TraderApiConfig

type TraderApiConfig struct {
	ID          int64 `gorm:"primary_key"`
	TraderID    int64 `gorm:"index"`
	ApiConfigID int64 `gorm:"index"`

	ApiConfig `gorm:"-"`
}

TraderExchange struct

type TraderExchange

type TraderExchange struct {
	ID         int64 `gorm:"primary_key"`
	TraderID   int64 `gorm:"index"`
	ExchangeID int64 `gorm:"index"`

	Exchange `gorm:"-"`
}

TraderExchange struct

type User

type User struct {
	ID        int64      `gorm:"primary_key" json:"id"`
	Username  string     `gorm:"type:varchar(25);unique_index" json:"username"`
	Password  string     `gorm:"not null" json:"-"`
	Level     int64      `json:"level"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"-"`
}

User struct

func GetUser

func GetUser(username interface{}) (user User, err error)

GetUser ...

func GetUserByID

func GetUserByID(id interface{}) (user User, e error)

GetUserByID ...

func (User) GetAlgorithm

func (user User) GetAlgorithm(id int64) (algorithm Algorithm, err error)

func (User) GetTrader

func (user User) GetTrader(id interface{}) (trader Trader, err error)

GetTrader ...

func (User) GetTraderExchanges

func (user User) GetTraderExchanges(id interface{}) (traderExchanges []TraderExchange, err error)

GetTraderExchanges ...

func (User) ListAlgorithm

func (user User) ListAlgorithm(size, page int, order string) (total int64, algorithms []Algorithm, err error)

func (User) ListExchange

func (user User) ListExchange(size, page int, order string) (total int64, exchanges []Exchange, err error)

ListExchange ...

func (User) ListLog

func (user User) ListLog(id, size, page int) (total int64, logs []Log, err error)

ListLog ...

func (User) ListTrader

func (user User) ListTrader(algorithmID int64) (traders []Trader, err error)

ListTrader ...

func (User) ListUser

func (user User) ListUser(size, page int, order string) (total int64, users []User, err error)

ListUser ...

func (User) UpdateTrader

func (user User) UpdateTrader(req Trader) (err error)

UpdateTrader ...

Jump to

Keyboard shortcuts

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