model

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2016 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func NewOrm

func NewOrm() (*gorm.DB, error)

NewOrm ...

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"`
	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 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"`
	Type      string     `gorm:"type:varchar(50)" json:"type"`
	AccessKey string     `gorm:"type:varchar(200)" json:"accessKey"`
	SecretKey string     `gorm:"type:varchar(200)" json:"secretKey"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"-"`
}

Exchange struct

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"`
	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 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, err error)

GetUserByID ...

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 int64, order string) (total int64, algorithms []Algorithm, err error)

ListAlgorithm ...

func (User) ListExchange

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

ListExchange ...

func (User) ListLog

func (user User) ListLog(id, size, page int64) (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 int64, 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