package model

type StockDaily struct {
	ID           int     `gorm:"primaryKey" json:"id"`
	Code         string  `gorm:"column:code;type:varchar(10)" json:"code"`
	Date         string  `gorm:"column:date;type:date" json:"date"`
	Open         float64 `gorm:"column:open" json:"open"`
	Close        float64 `gorm:"column:close" json:"close"`
	High         float64 `gorm:"column:high" json:"high"`
	Low          float64 `gorm:"column:low" json:"low"`
	Volume       float64 `gorm:"column:volume" json:"volume"`
	Turnover     float64 `gorm:"column:turnover" json:"turnover"`
	Amplitude    float64 `gorm:"column:amplitude" json:"amplitude"`
	PctChange    float64 `gorm:"column:pct_change" json:"pct_change"`
	Change       float64 `gorm:"column:change" json:"change"`
	TurnoverRate float64 `gorm:"column:turnover_rate" json:"turnover_rate"`
}

func (StockDaily) TableName() string {
	return "stock_daily"
}

type StockInfo struct {
	Code    string `gorm:"primaryKey;column:code;type:varchar(10)" json:"code"`
	Name    string `gorm:"column:name;type:varchar(50)" json:"name"`
	IpoDate string `gorm:"column:ipo_date;type:date" json:"ipo_date"`
}

func (StockInfo) TableName() string {
	return "stock_info"
}

type StockRank struct {
	Code      string  `json:"code"`
	Name      string  `json:"name"`
	PctChange float64 `json:"pct_change"`
	Close     float64 `json:"close"`
}

type DailySummary struct {
	Date                  string  `gorm:"column:date" json:"date"`
	TotalStocks           int     `gorm:"column:total_stocks" json:"total_stocks"`
	UpCount               int     `gorm:"column:up_count" json:"up_count"`
	DownCount             int     `gorm:"column:down_count" json:"down_count"`
	FlatCount             int     `gorm:"column:flat_count" json:"flat_count"`
	TotalTurnover         float64 `gorm:"column:total_turnover" json:"total_turnover"`
	AvgPctChange          float64 `gorm:"column:avg_pct_change" json:"avg_pct_change"`
	LimitUp10             int     `gorm:"column:limit_up_10" json:"limit_up_10"`
	LimitDown10           int     `gorm:"column:limit_down_10" json:"limit_down_10"`
	LimitUp20             int     `gorm:"column:limit_up_20" json:"limit_up_20"`
	LimitDown20           int     `gorm:"column:limit_down_20" json:"limit_down_20"`
	ConsecutiveLimitCount int     `gorm:"column:consecutive_limit_count" json:"consecutive_limit_count"`
}

type DashboardSummary struct {
	TotalStocks   int64       `json:"total_stocks"`
	UpCount       int64       `json:"up_count"`
	DownCount     int64       `json:"down_count"`
	FlatCount     int64       `json:"flat_count"`
	TotalTurnover float64     `json:"total_turnover"`
	AvgPctChange  float64     `json:"avg_pct_change"`
	LimitUpList   []StockRank `json:"limit_up_list"`
	LimitDownList []StockRank `json:"limit_down_list"`
	High100List   []StockRank `json:"high_100_list"`
}

type ConsecutiveLimit struct {
	Code      string  `json:"code"`
	Name      string  `json:"name"`
	Streak    int     `json:"streak"`
	Close     float64 `json:"close"`
	PctChange float64 `json:"pct_change"`
}
