You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
3.9 KiB
54 lines
3.9 KiB
package entity |
|
|
|
import ( |
|
"github.com/govalues/decimal" |
|
) |
|
|
|
// TradeOrder 交易计划订单 |
|
type TradeOrder struct { |
|
Id int64 `gorm:"column:id;primaryKey" json:"id"` // 订单id |
|
UserId int64 `gorm:"column:user_id" json:"userId"` // 用户id |
|
PlanId int64 `gorm:"column:plan_id" json:"planId"` // 交易计划id |
|
Side int8 `gorm:"column:side" json:"side"` // 交易方向:0.空,1.多 |
|
Status int8 `gorm:"column:status" json:"status"` // 状态:0.padding,1交易完成,2.交易中,3交易取消 |
|
Exchange int8 `gorm:"column:exchange" json:"exchange"` // 交易所: 1.okx, 2.binance |
|
InstId string `gorm:"column:inst_id" json:"instId"` // 交易产品id |
|
InstType int8 `gorm:"column:inst_type" json:"instType"` // 交易产品类型:1现货2永续合约 |
|
OrderType int8 `gorm:"column:order_type" json:"orderType"` // 订单类型:1.限价单,2.市价单 |
|
Leverage int `gorm:"column:leverage" json:"leverage"` // 杠杆倍数 |
|
SigPrice decimal.Decimal `gorm:"column:sig_price" json:"sigPrice"` // 下单价格(市价单为空 |
|
SigVol decimal.Decimal `gorm:"column:sig_vol" json:"sigVol"` // 下单数量 |
|
SigVolQuantity decimal.Decimal `gorm:"column:sig_vol_quantity" json:"sigVolQuantity"` // 下单金额 |
|
TradePrice decimal.Decimal `gorm:"column:trade_price" json:"tradePrice"` // 成交价格(平均价 |
|
TradeQuantity decimal.Decimal `gorm:"column:trade_quantity" json:"tradeQuantity"` // 成交数量 |
|
TradeAmount decimal.Decimal `gorm:"column:trade_amount" json:"tradeAmount"` // 成交金额 |
|
TradeTime int64 `gorm:"column:trade_time" json:"tradeTime"` // 成交时间 |
|
CreateTime int64 `gorm:"column:create_time" json:"createTime"` // 创建时间 |
|
UpdateTime int64 `gorm:"column:update_time" json:"updateTime"` // 更新时间 |
|
} |
|
|
|
func (TradeOrder) TableName() string { |
|
return "t_trade_order" |
|
} |
|
|
|
// TradeOrderClose 交易平仓订单 |
|
type TradeOrderClose struct { |
|
Id int64 `gorm:"column:id;primaryKey" json:"id"` // 平仓单id |
|
OrderId int64 `gorm:"column:order_id" json:"orderId"` // 交易订单id |
|
Status int8 `gorm:"column:status" json:"status"` // 状态:0.padding,1交易完成,2.交易中,3交易取消 |
|
Exchange int8 `gorm:"column:exchange" json:"exchange"` // 交易所 |
|
InstId string `gorm:"column:inst_id" json:"instId"` // 交易产品id |
|
CloseSide int8 `gorm:"column:close_side" json:"closeSide"` // 平仓方向:0.空,1.多 |
|
ClosePrice decimal.Decimal `gorm:"column:close_price" json:"closePrice"` // 平仓价格 |
|
CloseAmount decimal.Decimal `gorm:"column:close_amount" json:"closeAmount"` // 平仓金额 |
|
CloseQuantity decimal.Decimal `gorm:"column:close_quantity" json:"closeQuantity"` // 平仓数量 |
|
Pnl decimal.Decimal `gorm:"column:pnl" json:"pnl"` // 盈亏金额(计算:(close_price - entry_price) * quantity * side_factor) |
|
PnlPercent decimal.Decimal `gorm:"column:pnl_percent" json:"pnlPercent"` // 盈亏百分比 |
|
TradeTime int64 `gorm:"column:trade_time" json:"tradeTime"` // 成交时间 |
|
CreateTime int64 `gorm:"column:create_time" json:"createTime"` // 创建时间戳毫秒 |
|
UpdateTime int64 `gorm:"column:update_time" json:"updateTime"` // 更新时间戳毫秒 |
|
} |
|
|
|
func (TradeOrderClose) TableName() string { |
|
return "t_trade_order_close" |
|
}
|
|
|