models

package
v0.0.0-...-20fee0d Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbEngine

func DbEngine() *xorm.Engine

func DeleteTableMapCache

func DeleteTableMapCache()

func InitDbEngine

func InitDbEngine(opt *viper.Viper)

func ParseTime

func ParseTime(tt string) time.Time

Types

type Kline

type Kline struct {
	Id         int64     `xorm:"autoincr pk" json:"-"`
	OpenAt     time.Time `xorm:"notnull timestamp unique(open_at)" json:"open_at"`            //开盘时间
	Open       string    `xorm:"decimal(40, 20) notnull" json:"open"`                         //开盘价
	High       string    `xorm:"decimal(40, 20) notnull" json:"high"`                         // 最高价
	Low        string    `xorm:"decimal(40, 20) notnull" json:"low"`                          //最低价
	Close      string    `xorm:"decimal(40, 20) notnull" json:"close"`                        //收盘价(当前K线未结束的即为最新价)
	Volume     string    `xorm:"decimal(40, 20) notnull" json:"volume"`                       //成交量
	CloseAt    time.Time `xorm:"timestamp notnull default CURRENT_TIMESTAMP" json:"close_at"` // 收盘时间
	Amount     string    `xorm:"decimal(40, 20) notnull" json:"amount"`                       //成交额
	TradeCnt   int64     `json:"trade_count"`                                                 //成交笔数
	CreateTime time.Time `xorm:"timestamp created" json:"-"`
	UpdateTime time.Time `xorm:"timestamp updated" json:"-"`
	// contains filtered or unexported fields
}

func NewKline

func NewKline(symbol string, period Period) *Kline

func (*Kline) Save

func (k *Kline) Save() error

func (*Kline) TableName

func (k *Kline) TableName() string

func (*Kline) ToJson

func (k *Kline) ToJson() string

type Period

type Period string
const (
	PERIOD_M1  Period = "m1"
	PERIOD_M3  Period = "m3"
	PERIOD_M5  Period = "m5"
	PERIOD_M15 Period = "m15"
	PERIOD_M30 Period = "m30"
	PERIOD_H1  Period = "h1"
	PERIOD_H2  Period = "h2"
	PERIOD_H4  Period = "h4"
	PERIOD_H6  Period = "h6"
	PERIOD_H8  Period = "h8"
	PERIOD_H12 Period = "h12"
	PERIOD_D1  Period = "d1"
	PERIOD_D3  Period = "d3"
	PERIOD_W1  Period = "w1"
	PERIOD_MN  Period = "mn"
)

func Periods

func Periods() []Period

type TradeLog

type TradeLog struct {
	Id       int64     `xorm:"autoincr pk"`
	Symbol   string    `xorm:"-"`
	At       time.Time `xorm:"notnull"`
	Price    string    `xorm:"decimal(40, 20) notnull"`
	Quantity string    `xorm:"decimal(40, 20) notnull"`
	Amount   string    `xorm:"decimal(40, 20) notnull"`

	AskId string `xorm:"varchar(64) notnull unique(ask_bid)"`
	BidId string `xorm:"varchar(64) notnull unique(ask_bid)"`
	// contains filtered or unexported fields
}

func PushTradeLog

func PushTradeLog(symbol string, at time.Time, askId, bidId, price, qty, amount string) TradeLog

func (*TradeLog) Clean

func (t *TradeLog) Clean()

func (*TradeLog) GetAt

func (t *TradeLog) GetAt(period Period) (st, et time.Time)

func (*TradeLog) Save

func (t *TradeLog) Save() error

func (*TradeLog) SetTableName

func (t *TradeLog) SetTableName(symbol string)

func (*TradeLog) TableName

func (t *TradeLog) TableName() string

Jump to

Keyboard shortcuts

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