This commit is contained in:
2026-04-07 14:46:49 +08:00
parent aaa8308a90
commit 35e52bc5ea
14 changed files with 234 additions and 620 deletions

View File

@@ -6,93 +6,11 @@ import (
"gorm.io/gorm"
)
// Status 状态数据结构
type Status struct {
Data Data `json:"data"`
Status Config `json:"status"`
}
// Data 数据部分
type Data struct {
Assets Assets `json:"assets"`
Orders []Order `json:"order"`
Positions []Position `json:"positions"`
TickData map[string]Tick `json:"tick_data"`
}
// Assets 资产信息
type Assets struct {
AccountID string `json:"account_id"`
Cash float64 `json:"cash"`
FrozenCash float64 `json:"frozen_cash"`
MarketValue float64 `json:"market_value"`
Profit float64 `json:"profit"`
TotalAsset float64 `json:"total_asset"`
}
// Order 订单信息
type Order struct {
OrderID int64 `json:"order_id"`
OrderRemark string `json:"order_remark"`
OrderStatus int `json:"order_status"`
OrderTime int64 `json:"order_time"`
Price float64 `json:"price"`
StockCode string `json:"stock_code"`
TradedPrice float64 `json:"traded_price"`
TradedVolume int `json:"traded_volume"`
Volume int `json:"volume"`
}
// Position 持仓信息
type Position struct {
Code string `json:"code"`
Volume int `json:"volume"`
CanUseVolume int `json:"can_use_volume"`
FrozenVolume int `json:"frozen_volume"`
AvgPrice float64 `json:"avg_price"`
OpenPrice float64 `json:"open_price"`
CurrentPrice float64 `json:"current_price"`
MarketValue float64 `json:"market_value"`
Profit float64 `json:"profit"`
ProfitRate float64 `json:"profit_rate"`
MinProfitRate float64 `json:"min_profit_rate"`
}
// Tick 行情数据
type Tick struct {
LastPrice float64 `json:"lastPrice"`
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
LastClose float64 `json:"lastClose"`
Volume int64 `json:"volume"`
Amount float64 `json:"amount"`
PVolume int64 `json:"pvolume"`
BidPrice []float64 `json:"bidPrice"`
BidVol []int `json:"bidVol"`
AskPrice []float64 `json:"askPrice"`
AskVol []int `json:"askVol"`
Time int64 `json:"time"`
TimeTag string `json:"timetag"`
StockStatus int `json:"stockStatus"`
LastSettlementPrice float64 `json:"lastSettlementPrice"`
SettlementPrice float64 `json:"settlementPrice"`
OpenInt int `json:"openInt"`
}
// Config 配置信息
type Config struct {
ConfigKey string `json:"config_key"`
HomeName string `json:"home_name"`
ProjectRoot string `json:"project_root"`
QmtStatus string `json:"qmt_status"`
StartTime int64 `json:"start_time"`
}
// AssetSnapshot 资产快照数据库模型
type AssetSnapshot struct {
type CollectorAssets struct {
ID uint `json:"id" gorm:"primaryKey"`
AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index"`
Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"`
Cash float64 `json:"cash" gorm:"type:decimal(15,2);not null;default:0"`
FrozenCash float64 `json:"frozen_cash" gorm:"type:decimal(15,2);not null;default:0;column:frozen_cash"`
MarketValue float64 `json:"market_value" gorm:"type:decimal(15,2);not null;default:0;column:market_value"`
@@ -105,11 +23,12 @@ type AssetSnapshot struct {
}
// OrderRecord 订单数据库模型
type OrderRecord struct {
type CollectorOrder struct {
ID uint `json:"id" gorm:"primaryKey"`
OrderID int64 `json:"order_id" gorm:"not null;index"`
AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index"`
StockCode string `json:"stock_code" gorm:"type:varchar(20);not null;index"`
Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"`
Price float64 `json:"price" gorm:"type:decimal(10,4);not null;default:0"`
Volume int `json:"volume" gorm:"not null;default:0"`
TradedPrice float64 `json:"traded_price" gorm:"type:decimal(10,4);not null;default:0;column:traded_price"`
@@ -124,10 +43,11 @@ type OrderRecord struct {
}
// PositionRecord 持仓数据库模型
type PositionRecord struct {
type CollectorPosition struct {
ID uint `json:"id" gorm:"primaryKey"`
AccountID string `json:"account_id" gorm:"type:varchar(50);not null;index"`
Code string `json:"code" gorm:"type:varchar(20);not null;index"`
Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"`
Volume int `json:"volume" gorm:"not null;default:0"`
CanUseVolume int `json:"can_use_volume" gorm:"not null;default:0;column:can_use_volume"`
FrozenVolume int `json:"frozen_volume" gorm:"not null;default:0;column:frozen_volume"`
@@ -145,9 +65,10 @@ type PositionRecord struct {
}
// TickRecord 行情数据库模型
type TickRecord struct {
type CollectorTick struct {
ID uint `json:"id" gorm:"primaryKey"`
StockCode string `json:"stock_code" gorm:"type:varchar(20);not null;index"`
Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"`
LastPrice float64 `json:"last_price" gorm:"type:decimal(10,4);not null;default:0;column:last_price"`
Open float64 `json:"open" gorm:"type:decimal(10,4);not null;default:0"`
High float64 `json:"high" gorm:"type:decimal(10,4);not null;default:0"`
@@ -170,9 +91,10 @@ type TickRecord struct {
}
// CollectionLog 采集日志数据库模型
type CollectionLog struct {
type CollectorLog struct {
ID uint `json:"id" gorm:"primaryKey"`
DataHash string `json:"data_hash" gorm:"type:varchar(64);not null;index"`
Ymd int `json:"ymd" gorm:"not null;index;comment:年月日数字格式,如20260407"`
HasChanged bool `json:"has_changed" gorm:"not null;default:false;column:has_changed"`
StatusMessage string `json:"status_message" gorm:"type:text;column:status_message"`
CollectedAt time.Time `json:"collected_at" gorm:"not null;index"`