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.

471 lines
23 KiB

2 months ago
package model
import (
"github.com/shopspring/decimal"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type SpotsModel struct {
Symbol string `json:"symbol"` //交易对 例如:btcusdt, ethbtc
Period string `json:"period"` //返回数据时间粒度,也就是每根蜡烛的时间区间
Size int `json:"size"` //返回K线数据条数 例如:[1-2000]
Depth int `json:"depth"` //返回深度的数量 例如:5,10,20
Type string `json:"type"` //深度的价格聚合度,具体说明见下方 例如:step0,step1,step2,step3,step4,step5
}
type ContractModel struct {
ContractCode string `json:"contract_code"` //合约代码 或 合约标识
Type string `json:"type"` //深度类型
BusinessType string `json:"business_type"` //业务类型,不填默认永续 例如:futures:交割、swap:永续、all:全部
Size int `json:"size"` //获取数量,默认150 [1,2000]
Period string `json:"period"` //K线类型 1min, 5min, 15min, 30min, 60min,4hour,1day,1week,1mon
From int64 `json:"from"` //开始时间戳 10位 单位S
To int64 `json:"to"` //结束时间戳 10位 单位S
Pair string `json:"pair"` //交易对 备注:BTC-USDT
ContractType string `json:"contract_type"` //备注:swap(永续)、this_week(当周)、next_week(次周)、quarter(当季)、next_quarter(次季)
AmountType int `json:"amount_type"` //备注:1:张,2:币
BasisPriceType string `json:"basis_price_type"` //基差价格类型,表示在周期内计算基差使用的价格类型, 不填,默认使用开盘价
}
type GetSpotsTickCompleteList struct {
Status string `json:"status"`
Ch string `json:"ch"`
Ts int64 `json:"ts"`
Tick *SpotsTickS `json:"tick"`
Icon string `json:"icon"`
FullName string `json:"fullName"`
}
type GetSpotsTickList struct {
Status string `json:"status"`
Ch string `json:"ch"`
Ts int64 `json:"ts"`
Tick *SpotsTickS `json:"tick"`
}
type SpotsTickS struct {
Id int64 `json:"id"`
Version int64 `json:"version"`
Open decimal.Decimal `json:"open"`
Close decimal.Decimal `json:"close"`
Low decimal.Decimal `json:"low"`
High decimal.Decimal `json:"high"`
Amount decimal.Decimal `json:"amount"`
Vol decimal.Decimal `json:"vol"`
Count int64 `json:"count"`
Bid []decimal.Decimal `json:"bid"`
Ask []decimal.Decimal `json:"ask"`
}
type GetContractTickCompleteList struct {
Status string `json:"status"`
Ch string `json:"ch"`
Ts int64 `json:"ts"`
Tick *ContractTick `json:"tick"`
Icon string `json:"icon"`
FullName string `json:"fullName"`
}
type GetContractTickList struct {
Status string `json:"status"`
Ch string `json:"ch"`
Ts int64 `json:"ts"`
Tick *ContractTick `json:"tick"`
}
type ContractTick struct {
Id int64 `json:"id"`
Version int64 `json:"version"`
Open decimal.Decimal `json:"open"`
Close decimal.Decimal `json:"close"`
Low decimal.Decimal `json:"low"`
High decimal.Decimal `json:"high"`
Amount decimal.Decimal `json:"amount"`
Vol decimal.Decimal `json:"vol"`
Count int64 `json:"count"`
Bid []decimal.Decimal `json:"bid"`
Ask []decimal.Decimal `json:"ask"`
TradeTurnover string `json:"trade_turnover"`
}
type Subscribe struct {
Action string `json:"action"`
Symbols string `json:"symbols"`
}
// Sequence analysis
type ClientMessage struct {
S string `json:"s,omitempty"` // 股票代码
P decimal.Decimal `json:"p,omitempty"` // 价格
C []decimal.Decimal `json:"c,omitempty"` // 条件,有关更多信息,请参阅贸易条件术语表
V int64 `json:"v,omitempty"` // 交易量,代表在相应时间戳处交易的股票数量
Dp bool `json:"dp,omitempty"` // 暗池真/假
Ms string `json:"ms,omitempty"` // 市场状态,指示股票市场的当前状态(“开盘”、“收盘”、“延长交易时间”)
T int64 `json:"t,omitempty"` // 以毫秒为单位的时间戳
Av int64 `json:"av,omitempty"` // 今天累计交易量 1
Op decimal.Decimal `json:"op,omitempty"` // 今天正式开盘价格
Vw decimal.Decimal `json:"vw,omitempty"` // 即时报价的成交量加权平均价格
Cl decimal.Decimal `json:"cl,omitempty"` // 此聚合窗口的收盘价
H decimal.Decimal `json:"h,omitempty"` // 此聚合窗口的最高逐笔报价
L decimal.Decimal `json:"l,omitempty"` // 此聚合窗口的最低价格变动价格
A decimal.Decimal `json:"a,omitempty"` // 今天的成交量加权平均价格
Z int64 `json:"z,omitempty"` // 此聚合窗口的平均交易规模
Se int64 `json:"se,omitempty"` // 此聚合窗口的起始报价的时间戳(以 Unix 毫秒为单位)
ClosingMarket bool `json:"closing_market"`
}
type ClientMessageParam struct {
Data []ClientMessage `json:"data"`
Token string `json:"token"`
}
// Original parsing
type ClientMessageNew struct {
Ev string `json:"ev,omitempty"` // 事件类型
Sym string `json:"sym,omitempty"` // 股票代码 1
V int64 `json:"v,omitempty"` // 报价交易量 1
Av int64 `json:"av,omitempty"` // 今天累计交易量 1
Op decimal.Decimal `json:"op,omitempty"` // 今天正式开盘价格
Vw decimal.Decimal `json:"vw,omitempty"` // 即时报价的成交量加权平均价格
O decimal.Decimal `json:"o,omitempty"` // 此聚合窗口的开盘价格 1
C decimal.Decimal `json:"c,omitempty"` // 此聚合窗口的收盘价
H decimal.Decimal `json:"h,omitempty"` // 此聚合窗口的最高逐笔报价
L decimal.Decimal `json:"l,omitempty"` // 此聚合窗口的最低价格变动价格
A decimal.Decimal `json:"a,omitempty"` // 今天的成交量加权平均价格
Z int64 `json:"z,omitempty"` // 此聚合窗口的平均交易规模
S int64 `json:"s,omitempty"` // 此聚合窗口的起始报价的时间戳(以 Unix 毫秒为单位)
E int64 `json:"e,omitempty"` // 此聚合窗口的结束时钟周期的时间戳(以 Unix 毫秒为单位)
}
type FinnhubMessage struct {
Data []FinnhubMessageData `json:"data"`
}
type FinnhubMessageNew struct {
Topic string `json:"topic"`
Content string `json:"content"`
}
type FinnhubMessageData struct {
S string `json:"s,omitempty"` // 股票代码
P decimal.Decimal `json:"p,omitempty"` // 此聚合窗口的落盘价
V int64 `json:"v,omitempty"` // 交易量
T int64 `json:"t,omitempty"` // 此聚合窗口的结束时钟周期的时间戳(以 Unix 毫秒为单位)
C []decimal.Decimal `json:"c"`
}
type OrderWss struct {
Code int `json:"code,omitempty"`
Data Data `json:"data,omitempty"`
Msg string `json:"msg,omitempty"`
}
type Data struct {
Id int64 `json:"id,omitempty"`
UserId int64 `json:"userId,omitempty"`
SystemBoursesId int64 `json:"systemBoursesId,omitempty"`
BourseType int `json:"bourseType,omitempty"`
StockCode string `json:"stockCode,omitempty"`
Icon string `json:"icon,omitempty"`
Unit string `json:"unit,omitempty"`
FullName string `json:"fullName,omitempty"`
BeforeClose decimal.Decimal `json:"beforeClose,omitempty"`
YesterdayClose decimal.Decimal `json:"yesterdayClose,omitempty"`
KeepDecimal int `json:"keepDecimal"`
Currency string `json:"currency"`
}
type Token struct {
State bool `json:"state,omitempty"`
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Data string `json:"data,omitempty"`
}
type LoginPost struct {
Check string `json:"check,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
Password string `json:"password,omitempty"`
InvitationCode string `json:"invitationCode,omitempty"`
Code string `json:"code,omitempty"`
Id string `json:"id,omitempty"`
TerminalEquipmentName string `json:"terminalEquipmentName,omitempty"`
LoginCountry string `json:"loginCountry,omitempty"`
LoginCity string `json:"loginCity,omitempty"`
LoginIp string `json:"loginIp,omitempty"`
}
type StockParam struct {
Symbol string `json:"symbol"` //交易所:股票代码
StockCode string `json:"stock_code"` // 股票代码
StockName string `json:"stock_name"` // 股票名,可能为空
Price float64 `json:"price"` // 实时价格
UpDownRate decimal.Decimal `json:"up_down_rate"` // 涨跌%
UpDown decimal.Decimal `json:"up_down"` // // 涨跌额
TradeV decimal.Decimal `json:"trade_v"` // 技术评级指标值
TradeK string `json:"trade_k"` // 技术评级
Vol int64 `json:"vol"` // 成交量
TurnoverPriceTotal decimal.Decimal `json:"turnover_price_total"` // 成交量*价格
PriceTotal string `json:"price_total"` // 总市值
PE string `json:"p_e"` //pe
Eps string `json:"eps"` // EPS
EmployeesNumber string `json:"employees_number"` // 雇员
Plate string `json:"plate"` // 板块
Desc string `json:"desc"` // 股票说明
PriceCode string `json:"price_code"` // 货币单位
Country string `json:"country"` //国家
Ts int64 `json:"ts"` // 时间戳 毫秒
Token string `json:"token"`
ClosingMarket bool `json:"closing_market"`
}
type StockMonParam struct {
Symbol string `json:"symbol"` //交易所:股票代码
StockCode string `json:"stock_code"` // 股票代码
StockName string `json:"stock_name"` // 股票名,可能为空
OpenPrice decimal.Decimal `json:"open_price"` // 开盘价
HighPrice decimal.Decimal `json:"high_price"` // 最高价
LowPrice decimal.Decimal `json:"low_price"` // 最低价
ClosePrice decimal.Decimal `json:"close_price"` // 当前时段市价
Desc string `json:"desc"` // 股票说明
PriceCode string `json:"price_code"` // 货币单位
Country string `json:"country"` //国家
Vol int64 `json:"vol"`
Ts int64 `json:"ts"` // 蜡烛图的开端 时间戳 毫秒
}
type StockMonRes struct {
Result []StockMonParam `json:"result"`
Token string `json:"token"`
Country string `json:"country"`
Status string `json:"status"` // 5min 15min 30min 1hour 1day 1week 1mon
}
type StockNews struct {
Country string `json:"country"` //国家
Title string `json:"title"` //标题
Source string `json:"source"` //来源
Pubdate string `json:"pubdate"` //发布时间
Link string `json:"link"` // 链接
Code int64 `json:"code"` // 链接
}
type StockNewsRes struct {
Result []StockNews `json:"result"`
Token string `json:"token"`
Country string `json:"country"`
}
type StockMogoParam struct {
Symbol string `json:"symbol"` //交易所:股票代码
StockCode string `json:"stock_code" bson:"stock_code"` // 股票代码
StockName string `json:"stock_name" bson:"stock_name"` // 股票名,可能为空
Price float64 `json:"price"` // 实时价格
OpenPrice string `json:"open_price" bson:"open_price"` // 开盘价
PreviousPrice string `json:"previous_price" bson:"previous_price"` //上一次的闭盘价
HighPrice string `json:"high_price" bson:"high_price"` // 最高价
LowPrice string `json:"low_price" bson:"low_price"` // 最低价
ClosePrice string `json:"close_price" bson:"close_price"` // 当前时段市价
StringVal float64 `json:"stringVal" bson:"stringVal"`
UpDownRate string `json:"up_down_rate" bson:"up_down_rate"` // 涨跌%
UpDown string `json:"up_down" bson:"up_down"` // // 涨跌额
TradeV string `json:"trade_v" bson:"trade_v"` // 技术评级指标值
TradeK string `json:"trade_k" bson:"trade_k"` // 技术评级
Vol interface{} `json:"vol"` // 成交量
TurnoverPriceTotal string `json:"turnover_price_total" bson:"turnover_price_total"` // 成交量*价格
PriceTotal string `json:"price_total" bson:"price_total"` // 总市值
PE string `json:"p_e" bson:"p_e"` //pe
Eps string `json:"eps"` // EPS
EmployeesNumber string `json:"employees_number" bson:"employees_number"` // 雇员
Plate string `json:"plate"` // 板块
Desc string `json:"desc"` // 股票说明
PriceCode string `json:"price_code" bson:"price_code"` // 货币单位
Country string `json:"country"` //国家
Ts int64 `json:"ts" bson:"timestamp"` // 时间戳 毫秒
Vw string `json:"vw"`
PrimaryExchange string `json:"primary_exchange"`
NumericCode string `json:"numeric_code"`
ID primitive.ObjectID `bson:"_id"`
}
type StockIndexParam struct {
StockCode string `json:"stock_code" bson:"stock_code"` // 股票代码
StockName string `json:"stock_name" bson:"stock_name"` // 股票名,可能为空
Price float64 `json:"price"` // 最新价格
HighPrice float64 `json:"high_price" bson:"high_price"` // 最高价格
LowPrice float64 `json:"low_price" bson:"low_price"` // 最低价格
OpenPrice float64 `json:"open_price" bson:"open_price"` // 开盘价格
UpDownRate decimal.Decimal `json:"up_down_rate" bson:"up_down_rate"` // 涨跌%
UpDown decimal.Decimal `json:"up_down" bson:"up_down"` // 涨跌额
Vol int64 `json:"vol"` // 成交量
PriceCode string `json:"price_code" bson:"price_code"` // 货币单位
Country string `json:"country"` //国家
Ts int64 `json:"ts" bson:"timestamp"` // 时间戳 毫秒
Token string `json:"token"`
IsStockIndex bool `json:"is_stock_index"`
//ClosingMarket bool `json:"closing_market"`
}
type StockMogoParams struct {
Symbol string `json:"symbol"` //交易所:股票代码
StockCode string `json:"stock_code" bson:"stock_code"` // 股票代码
StockName string `json:"stock_name" bson:"stock_name"` // 股票名,可能为空
Price float64 `json:"price"` // 实时价格
OpenPrice string `json:"open_price" bson:"open_price"` // 开盘价
PreviousPrice string `json:"previous_price" bson:"previous_price"` //上一次的闭盘价
HighPrice string `json:"high_price" bson:"high_price"` // 最高价
LowPrice string `json:"low_price" bson:"low_price"` // 最低价
ClosePrice string `json:"close_price" bson:"close_price"` // 当前时段市价
UpDownRate interface{} `json:"up_down_rate" bson:"up_down_rate"` // 涨跌%
UpDown interface{} `json:"up_down" bson:"up_down"` // // 涨跌额
TradeV string `json:"trade_v" bson:"trade_v"` // 技术评级指标值
TradeK string `json:"trade_k" bson:"trade_k"` // 技术评级
Vol interface{} `json:"vol"` // 成交量
TurnoverPriceTotal string `json:"turnover_price_total" bson:"turnover_price_total"` // 成交量*价格
PriceTotal string `json:"price_total" bson:"price_total"` // 总市值
PE string `json:"p_e" bson:"p_e"` //pe
Eps string `json:"eps"` // EPS
EmployeesNumber string `json:"employees_number" bson:"employees_number"` // 雇员
Plate string `json:"plate"` // 板块
Desc string `json:"desc"` // 股票说明
PriceCode string `json:"price_code" bson:"price_code"` // 货币单位
Country string `json:"country"` //国家
Ts int64 `json:"ts" bson:"timestamp"` // 时间戳 毫秒
Vw string `json:"vw"`
PrimaryExchange string `json:"primary_exchange"`
}
type StrikeInfo struct {
Strike string `json:"strike"`
IsDefault bool `json:"is_default"`
Calls StrikeInfos `json:"calls"`
Puts StrikeInfos `json:"puts"`
Compute ComputePayload `json:"compute"`
}
type ComputePayload struct {
TickSize string `json:"tick_size"`
LotSize string `json:"lot_size"`
Multiplier string `json:"multiplier"`
ExpiryType string `json:"expiry_type"`
ScriptDate string `json:"script_date"`
}
type StrikeInfos struct {
GammaOn string `json:"gamma_on"`
GammaOff string `json:"gamma_off"`
VegaOn string `json:"vega_on"`
VegaOff string `json:"vega_off"`
ThetaOn string `json:"theta_on"`
ThetaOff string `json:"theta_off"`
DeltaOn string `json:"delta_on"`
DeltaOff string `json:"delta_off"`
PCR string `json:"pcr,omitempty"`
POP string `json:"pop"`
Volume string `json:"volume"`
OIChg string `json:"oi_chg"`
OIChgPercent string `json:"oi_chg_percent"` //olchg%
OIlakh string `json:"oi_lakh"`
BidOn string `json:"bid_on"`
BidOff string `json:"bid_off"`
OfferOn string `json:"offer_on"`
OfferOff string `json:"offer_off"`
IntValFOn string `json:"int_val_f_on"`
IntValFOff string `json:"int_val_f_off"`
IntValSOn string `json:"int_val_s_on"`
IntValSOff string `json:"int_val_s_off"`
TimeValueOn string `json:"time_value_on"`
TimeValueOff string `json:"time_value_off"`
LTPOn string `json:"ltp_on"` //开启 一手期权
LTPOff string `json:"ltp_off"` // 默认 一股 期权
IV string `json:"iv,omitempty"`
IVChg string `json:"iv_chg,omitempty"`
Name string `json:"name"`
}
type OptionInfoParam struct {
Country string `json:"country"`
Stock string `json:"stock"` // 期权code
FutPrice string `json:"fut_price"` //
Percent float64 `json:"percent"`
ATMIV string `json:"atmiv"`
IVP string `json:"ivp"`
Results map[string][]StrikeInfo `json:"results"`
Token string `json:"token"`
IsOptionInfo bool `json:"is_option_info"`
IsClose bool `json:"is_close"`
CloseDate string `json:"option_date"`
}
type OptionInfoExchange struct {
Country string `json:"country"`
Stock string `json:"stock"` // 期权code
FutPrice string `json:"fut_price"` //
Percent float64 `json:"percent"`
ATMIV string `json:"atmiv"`
IVP string `json:"ivp"`
Strike map[string]string `json:"strike"` //key 日期 value strike
IsOptionInfo bool `json:"is_option_info"`
}
type OptionInfoMogo struct {
Country string `json:"country" bson:"country"`
Stock string `json:"stock" bson:"code"` // 期权code
FutPrice string `json:"fut_price" bson:"fut_price"` //
Percent float64 `json:"percent" bson:"percent"`
ATMIV string `json:"atmiv" bson:"atmiv"`
IVP string `json:"ivp" bson:"ivp"`
Results string `json:"results"`
}
type OptionInfoExpiryMogo struct {
Stock string `json:"stock" bson:"code"` // 期权code
Expiry string `json:"expiry" bson:"expiry"`
Info string `json:"info" bson:"info"`
}
type OptionInfoRes struct {
Country string `json:"country"`
Stock string `json:"stock"` // 期权code
Results string `json:"results"`
}
type OptionInfo struct {
Stock string `json:"stock"` // 期权code
Results []OptionPolygon `json:"results"`
Token string `json:"token"`
}
type OptionPolygon struct {
Stock string `json:"stock" bson:"Code"` // 期权code
FutPrice string `json:"fut_price"` //
Percent float64 `json:"percent"` //涨跌幅
IVChg string `json:"iv_chg"`
ATMIV string `json:"atmiv"`
IVP string `json:"ivp"`
Country string `json:"country"`
PrimaryExchange string `json:"primary_exchange" bson:"Exchange"`
IsOptionList bool `json:"is_option_list"`
Rate float64 `json:"rate"`
DateTime string `json:"date_time" bson:"DateTime"`
IsClose bool `json:"is_close"`
CloseDate string `json:"option_date"`
}
type OptionIndexList struct {
Results []OptionPolygon `json:"results"`
Token string `json:"token"`
}
// offer 替换 ask ltp 替换 price chg 换 oi chg
type StrikePrice struct {
Price string `json:"price"`
Bid string `json:"bid"`
Ask string `json:"ask"`
Code string `json:"code"`
BeforeClose string `json:"before_close"`
YesterdayClose string `json:"yesterday_close"`
CloseDate string `json:"option_date"`
DueDate int64 `json:"due_date"`
}