package stock

import (
	"github.com/shopspring/decimal"
)

type RealTimeMessage struct {
	S  string            `json:"s,omitempty"`  // ticker code
	P  decimal.Decimal   `json:"p,omitempty"`  // price
	C  []decimal.Decimal `json:"c,omitempty"`  // conditions, see trade conditions glossary for more information
	V  int64             `json:"v,omitempty"`  // volume, representing the number of shares traded at the corresponding time stamp
	Dp bool              `json:"dp,omitempty"` // dark pool true/false
	Ms string            `json:"ms,omitempty"` // market status, indicating the current state of the market for the stock ( “open”, “closed”, “extended hours”)
	T  int64             `json:"t,omitempty"`  // timestamp in milliseconds
}

type EodTimeMessage struct {
	Date          string          `json:"date,omitempty"`
	Open          decimal.Decimal `json:"open,omitempty"`
	High          decimal.Decimal `json:"s,omitempty"`
	Low           decimal.Decimal `json:"high,omitempty"`
	Close         decimal.Decimal `json:"close,omitempty"`
	AdjustedClose decimal.Decimal `json:"adjusted_close,omitempty"`
	Volume        decimal.Decimal `json:"volume,omitempty"`
}

type UsDateClose struct {
	Status     string          `json:"status,omitempty"`
	From       string          `json:"from,omitempty"`
	Symbol     string          `json:"symbol,omitempty"`
	Open       decimal.Decimal `json:"open,omitempty"`
	High       decimal.Decimal `json:"high,omitempty"`
	Low        decimal.Decimal `json:"low,omitempty"`
	Close      decimal.Decimal `json:"close,omitempty"`
	Volume     interface{}     `json:"volume,omitempty"`
	AfterHours decimal.Decimal `json:"afterHours,omitempty"`
	PreMarket  decimal.Decimal `json:"preMarket,omitempty"`
}

// list message
type Finance struct {
	Result []Result    `json:"result"`
	Error  interface{} `json:"error"`
}

type Result struct {
	Count         decimal.Decimal `json:"count"`
	JobTimestamp  decimal.Decimal `json:"jobTimestamp"`
	StartInterval decimal.Decimal `json:"startInterval"`
	Quotes        []QuotesModel   `json:"quotes"`
}

type QuotesModel struct {
	Language                   string          `json:"language"`
	Region                     string          `json:"region"`
	QuoteType                  string          `json:"quoteType"`
	TypeDisp                   string          `json:"typeDisp"`
	QuoteSourceName            string          `json:"quoteSourceName"`
	Triggerable                bool            `json:"triggerable"`
	CustomPriceAlertConfidence string          `json:"customPriceAlertConfidence"`
	TrendingScore              decimal.Decimal `json:"trendingScore"`
	RegularMarketChange        decimal.Decimal `json:"regularMarketChange"`
	RegularMarketChangePercent decimal.Decimal `json:"regularMarketChangePercent"`
	RegularMarketTime          decimal.Decimal `json:"regularMarketTime"`
	RegularMarketPrice         decimal.Decimal `json:"regularMarketPrice"`
	RegularMarketPreviousClose decimal.Decimal `json:"regularMarketPreviousClose"`
	Exchange                   string          `json:"exchange"`
	Market                     string          `json:"market"`
	FullExchangeName           string          `json:"fullExchangeName"`
	ShortName                  string          `json:"shortName"`
	SourceInterval             decimal.Decimal `json:"sourceInterval"`
	ExchangeDataDelayedBy      decimal.Decimal `json:"exchangeDataDelayedBy"`
	ExchangeTimezoneName       string          `json:"exchangeTimezoneName"`
	ExchangeTimezoneShortName  string          `json:"exchangeTimezoneShortName"`
	QmtOffSetMilliseconds      decimal.Decimal `json:"gmtOffSetMilliseconds"`
	EsgPopulated               bool            `json:"esgPopulated"`
	Tradeable                  bool            `json:"tradeable"`
	CryptoTradeable            bool            `json:"cryptoTradeable"`
	MarketState                string          `json:"marketState"`
	FirstTradeDateMilliseconds decimal.Decimal `json:"firstTradeDateMilliseconds"`
	Symbol                     string          `json:"symbol"`
}

type EodData struct {
	Date          string  `json:"date" form:"date"`   // 日期
	Open          float64 `json:"open" form:"open"`   // 开盘价格
	High          float64 `json:"high" form:"high"`   // 最高价格
	Low           float64 `json:"low" form:"low"`     // 最低价格
	Close         float64 `json:"close" form:"close"` // 闭盘价格
	AdjustedClose float64 `json:"adjusted_close" form:"adjusted_close"`
	Volume        int64   `json:"volume" form:"volume"` // 交易量
}

type PHPData struct {
	Name        string `json:"name" redis:"name"`
	Code        string `json:"code" redis:"code"`
	LogoLink    string `json:"logo_link" redis:"logo_link"`
	KeepDecimal string `json:"keep_decimal" redis:"keep_decimal"`
	FaceValue   int    `json:"face_value" redis:"face_value"`
	MinPry      int    `json:"min_pry" redis:"min_pry"`
	MaxPry      int    `json:"max_pry" redis:"max_pry"`
	Status      int    `json:"status" redis:"status"`
}

type PHPRes struct {
	Data PHPList `json:"data"`
	Code string  `json:"code"`
}

type PHPList struct {
	List []PHPData `json:"list"`
	Code string    `json:"code"`
}

type MarketTrade struct {
	OrderNumber   string          `json:"order_number" ` //交易数量
	DealPrice     string          `json:"deal_price"`    //成交金额
	OrderTime     int64           `json:"order_time"`    //订单时间
	TradeType     int             `json:"trade_type"`    //交易类型:1买入, 2卖出
	IsHuobi       bool            `json:"is_huobi"`      //是否火币
	TradeTurnover decimal.Decimal `json:"trade_turnover"`
	ID            int64           `json:"id"`
}

type PHPMarketTradeList struct {
	List []MarketTrade `json:"data"`
	Code string        `json:"code"`
}

type IntraDayData struct {
	Timestamp int64   `json:"timestamp"` // 时间格式
	Gmtoffset int64   `json:"gmtoffset"` //
	Datetime  string  `json:"datetime"`  // 日期
	Open      float64 `json:"open"`      // 开盘价格
	High      float64 `json:"high"`      // 最高价格
	Low       float64 `json:"low"`       // 最低价格
	Close     float64 `json:"close"`     // 闭盘价格
	Volume    int64   `json:"volume"`    // 交易量
}

type Symbol struct {
	Code     string `json:"code"`
	Name     string `json:"name"`
	Country  string `json:"country"`
	Exchange string `json:"exchange"`
	Currency string `json:"currency"`
	Type     string `json:"type"`
}

type PreviousCloseResponse struct {
	Adjusted     bool               `json:"adjusted"`
	QueryCount   int                `json:"queryCount"`
	Results      []PreviousCloseRes `json:"results"`
	ResultsCount int                `json:"resultsCount"`
	Status       string             `json:"status"`
	Ticker       string             `json:"ticker"`
}

type PreviousCloseRes struct {
	Ts    string          `json:"T,omitempty"`
	C     decimal.Decimal `json:"c,omitempty"`
	H     decimal.Decimal `json:"h"`
	L     decimal.Decimal `json:"l"`
	O     decimal.Decimal `json:"o"`
	T     int64           `json:"t"`
	V     decimal.Decimal `json:"v,omitempty"`
	VW    decimal.Decimal `json:"vw"`
	N     int64           `json:"n"`
	PC    decimal.Decimal `json:"pc"`
	Error string          `json:"error"`
	DP    decimal.Decimal `json:"dp"`
}

type TypeTradesRes struct {
	Tape int `json:"tape"`
}

type TypeTradesResponse struct {
	Results []TypeTradesRes `json:"results"`
}