Documentation ¶
Index ¶
- Constants
- Variables
- func Db() *xorm.Engine
- func GetOrderTableName(symbol string) string
- func Init(db *xorm.Engine, rdc *redis.Client)
- type OrderSide
- type OrderType
- type TradeBy
- type TradeOrder
- func NewLimitOrder(user_id int64, trade_symbol string, side OrderSide, price, qty string) (order *TradeOrder, err error)
- func NewMarketOrderByAmount(user_id int64, trade_symbol string, side OrderSide, amount string) (order *TradeOrder, err error)
- func NewMarketOrderByQty(user_id int64, trade_symbol string, side OrderSide, qty string) (*TradeOrder, error)
- type TradeRecord
- type UnfinishedOrder
Constants ¶
Variables ¶
View Source
var ChCancel chan TradeOrder
Functions ¶
func GetOrderTableName ¶
Types ¶
type TradeOrder ¶
type TradeOrder struct { Id int64 `xorm:"pk autoincr bigint" json:"-"` Symbol string `xorm:"-" json:"symbol"` PairId int `xorm:"notnull index(pair_id)" json:"-"` OrderId string `xorm:"varchar(30) unique(order_id) notnull" json:"order_id"` OrderSide OrderSide `xorm:"varchar(10) index(order_side)" json:"order_side"` OrderType OrderType `xorm:"varchar(10)" json:"order_type"` //价格策略,市价单,限价单 UserId int64 `xorm:"bigint index(userid) notnull" json:"-"` FeeRate string `xorm:"decimal(40,20) notnull default(0)" json:"-"` //用户委托原始信息 OriginalPrice string `xorm:"decimal(40,20) notnull default(0)" json:"original_price"` OriginalQuantity string `xorm:"decimal(40,20) notnull default(0)" json:"original_quantity"` OriginalAmount string `xorm:"decimal(40,20) notnull default(0)" json:"-"` //根据订单方向不同,冻结的资产也不同 FreezeAsset string `xorm:"decimal(40,20) notnull default(0)" json:"-"` //成交的部分信息 TradeAvgPrice string `xorm:"decimal(40,20) notnull default(0)" json:"trade_avg_price"` TradeQty string `xorm:"decimal(40,20) notnull default(0)" json:"trade_qty"` TradeAmount string `xorm:"decimal(40,20) notnull default(0)" json:"trade_amount"` Fee string `xorm:"decimal(40,20) notnull default(0)" json:"-"` Status orderStatus `xorm:"tinyint(1)" json:"status"` CreateTime int64 `xorm:"bigint" json:"create_time"` //时间戳 精确到纳秒 UpdateTime time.Time `xorm:"timestamp updated" json:"-"` }
委托记录表
func NewLimitOrder ¶
func NewLimitOrder(user_id int64, trade_symbol string, side OrderSide, price, qty string) (order *TradeOrder, err error)
限价订单
func NewMarketOrderByAmount ¶
func NewMarketOrderByQty ¶
func (*TradeOrder) TableName ¶
func (to *TradeOrder) TableName() string
type TradeRecord ¶
type TradeRecord struct { Id int64 `xorm:"pk autoincr bigint" json:"-"` Symbol string `xorm:"-" json:"-"` TradeId string `xorm:"varchar(30) unique(trade)" json:"trade_id"` Ask string `xorm:"varchar(30) unique(trade)" json:"ask"` Bid string `xorm:"varchar(30) unique(trade)" json:"bid"` TradeBy TradeBy `xorm:"tinyint(1)" json:"trade_by"` AskUid int64 `xorm:"bigint notnull" json:"-"` BidUid int64 `xorm:"bigint notnull" json:"-"` Price string `xorm:"decimal(40,20) notnull default(0)" json:"price"` Quantity string `xorm:"decimal(40,20) notnull default(0)" json:"quantity"` Amount string `xorm:"decimal(40,20) notnull default(0)" json:"amount"` AskFeeRate string `xorm:"decimal(40,20) notnull default(0)" json:"-"` AskFee string `xorm:"decimal(40,20) notnull default(0)" json:"-"` BidFeeRate string `xorm:"decimal(40,20) notnull default(0)" json:"-"` BidFee string `xorm:"decimal(40,20) notnull default(0)" json:"-"` CreateTime types.Time `xorm:"timestamp created" json:"trade_at"` UpdateTime time.Time `xorm:"timestamp updated" json:"-"` }
成交记录表
func (*TradeRecord) GetTableName ¶
func (tr *TradeRecord) GetTableName(symbol string) string
func (*TradeRecord) TableName ¶
func (tr *TradeRecord) TableName() string
type UnfinishedOrder ¶
type UnfinishedOrder struct {
TradeOrder TradeOrder `xorm:"extends"`
}
未完全成交的委托订单记录表
func (*UnfinishedOrder) TableName ¶
func (u *UnfinishedOrder) TableName() string
Click to show internal directories.
Click to hide internal directories.