Documentation
¶
Index ¶
- Variables
- type Algorithm
- type ApiConfig
- type Exchange
- type Log
- type Logger
- type Trader
- type TraderApiConfig
- type TraderExchange
- type User
- func (user User) GetAlgorithm(id int64) (algorithm Algorithm, err error)
- func (user User) GetTrader(id interface{}) (trader Trader, err error)
- func (user User) GetTraderExchanges(id interface{}) (traderExchanges []TraderExchange, err error)
- func (user User) ListAlgorithm(size, page int, order string) (total int64, algorithms []Algorithm, err error)
- func (user User) ListExchange(size, page int, order string) (total int64, exchanges []Exchange, err error)
- func (user User) ListLog(id, size, page int) (total int64, logs []Log, err error)
- func (user User) ListTrader(algorithmID int64) (traders []Trader, err error)
- func (user User) ListUser(size, page int, order string) (total int64, users []User, err error)
- func (user User) UpdateTrader(req Trader) (err error)
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 ¶
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
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 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 (User) GetTraderExchanges ¶
func (user User) GetTraderExchanges(id interface{}) (traderExchanges []TraderExchange, err error)
GetTraderExchanges ...
func (User) ListAlgorithm ¶
func (User) ListExchange ¶
func (user User) ListExchange(size, page int, order string) (total int64, exchanges []Exchange, err error)
ListExchange ...
func (User) ListTrader ¶
ListTrader ...
Click to show internal directories.
Click to hide internal directories.