|
@@ -5,21 +5,6 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-// TradePositionAnalysis 持仓数据汇总表
|
|
|
-type TradePositionAnalysis struct {
|
|
|
- Id uint64 `orm:"column(id);pk"`
|
|
|
- ClassifyName string //分类名称
|
|
|
- ClassifyType string //分类名称下的类型
|
|
|
- DealShortName string //成交量公司简称
|
|
|
- DealValue int //成交量
|
|
|
- DealChange int //成交变化量
|
|
|
- DataTime string //数据日期
|
|
|
- CreateTime time.Time //插入时间
|
|
|
- ModifyTime time.Time //修改时间
|
|
|
- DealType int //交易类型:1多单,2空单,3净多单,4净空单
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
// 持仓榜单表
|
|
|
type TradePositionTop struct {
|
|
|
Id uint64 `orm:"column(id);pk"`
|
|
@@ -29,14 +14,17 @@ type TradePositionTop struct {
|
|
|
CreateTime time.Time //插入时间
|
|
|
ModifyTime time.Time //修改时间
|
|
|
DealShortName string //成交量公司简称
|
|
|
- DealValue int //成交量
|
|
|
- DealChange int //成交变化量
|
|
|
+ DealValue int //成交量
|
|
|
+ DealChange int //成交变化量
|
|
|
DealType int //交易类型:1多单,2空单,3净多单,4净空单
|
|
|
- AnalysisId uint64 //持仓数据
|
|
|
+ SourceType int //数据来源,0是原始数据的值,1是由T+1日推算出的值,2是由T日的榜单数据推算出的值
|
|
|
+ Rank int //排名
|
|
|
}
|
|
|
|
|
|
type TradeClassifyNameList struct {
|
|
|
Exchange string `description:"交易所" json:"exchange"`
|
|
|
+ Num int `description:"品种数量" json:"num"`
|
|
|
+ DataTime string `description:"最新更新时间" json:"data_time"`
|
|
|
Items []TradeClassifyNameListItem `description:"子类" json:"items"`
|
|
|
}
|
|
|
|
|
@@ -69,6 +57,18 @@ func GetExchangeClassify(exchange string) (list []TradeClassifyName, err error)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+type LastTimeItem struct {
|
|
|
+ CreateTime time.Time
|
|
|
+}
|
|
|
+func GetExchangeLastTime(exchange string) (item LastTimeItem, err error) {
|
|
|
+ tableName := "base_from_trade_" + exchange + "_index"
|
|
|
+ err = global.MYSQL["data"].
|
|
|
+ Table(tableName).
|
|
|
+ Select("create_time").
|
|
|
+ Order("create_time desc").First(&item).Error
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
type GetPositionTopReq struct {
|
|
|
Exchange string `json:"exchange" form:"exchange"` //交易所
|
|
|
ClassifyName string `json:"classify_name" form:"classify_name"` //分类名称
|
|
@@ -105,7 +105,7 @@ func GetTradePositionTop(exchange string, classifyName, classifyType, dataTime s
|
|
|
tableName := "trade_position_" + exchange + "_top"
|
|
|
err = global.MYSQL["data"].
|
|
|
Table(tableName).
|
|
|
- Where("classify_name=? and classify_type=? and data_time=? ", classifyName, classifyType, dataTime).
|
|
|
+ Where("classify_name=? and classify_type=? and data_time=? and rank <=20", classifyName, classifyType, dataTime).
|
|
|
Order("deal_value desc").Scan(&list).Error
|
|
|
return
|
|
|
}
|