Documentation
¶
Index ¶
- Constants
- Variables
- func AddPrefix(code string) string
- func Bytes(n any) []byte
- func CutInt(bs []byte) ([]byte, int)
- func FloatUnit(f float64) (float64, string)
- func FloatUnitString(f float64) string
- func GetHourMinute(bs [2]byte) string
- func GetTime(bs [4]byte, Type uint8) time.Time
- func Int64UnitString(n int64) string
- func IntUnitString(n int) string
- func IsBJStock(code string) bool
- func IsETF(code string) bool
- func IsIndex(code string) bool
- func IsSHStock(code string) bool
- func IsSZStock(code string) bool
- func IsStock(code string) bool
- func ReadFrom(r io.Reader) (result []byte, err error)
- func Reverse(bs []byte) []byte
- func String(bs []byte) string
- func UTF8ToGBK(text []byte) []byte
- func Uint16(bs []byte) uint16
- func Uint32(bs []byte) uint32
- type CallAuction
- type CallAuctionResp
- type Code
- type CodeResp
- type ConnectResp
- type Control
- type CountResp
- type Exchange
- type Frame
- type HistoryTradeResp
- type K
- type Kline
- type KlineCache
- type KlineReq
- type KlineResp
- type Klines
- type Message
- type MinuteResp
- type Price
- type PriceLevel
- type PriceLevels
- type PriceNumber
- type Quote
- type QuotesResp
- type Response
- type Trade
- type TradeCache
- type TradeResp
- type Trades
Constants ¶
View Source
const ( TypeConnect = 0x000D //建立连接 TypeHeart = 0x0004 //心跳 TypeCount = 0x044E //获取股票数量 TypeCode = 0x0450 //获取股票代码 TypeQuote = 0x053E //行情信息 TypeMinute = 0x051D //分时数据 TypeCallAuction = 0x056a //集合竞价 TypeMinuteTrade = 0x0FC5 //分时交易 TypeHistoryMinute = 0x0FB4 //历史分时数据 TypeHistoryMinuteTrade = 0x0FB5 //历史分时交易 TypeKline = 0x052D //K线图 )
View Source
const ( // Prefix 固定帧头 Prefix = 0x0C // PrefixResp 响应帧头 PrefixResp = 0xB1CB7400 )
View Source
const ( TypeKline5Minute uint8 = 0 // 5分钟K 线 TypeKline15Minute uint8 = 1 // 15分钟K 线 TypeKline30Minute uint8 = 2 // 30分钟K 线 TypeKline60Minute uint8 = 3 // 60分钟K 线 TypeKlineHour uint8 = 3 // 1小时K 线 TypeKlineDay2 uint8 = 4 // 日K 线, 发现和Day的区别是这个要除以100,其他未知 TypeKlineWeek uint8 = 5 // 周K 线 TypeKlineMonth uint8 = 6 // 月K 线 TypeKlineMinute uint8 = 7 // 1分钟 TypeKlineMinute2 uint8 = 8 // 1分钟K 线,未知啥区别 TypeKlineDay uint8 = 9 // 日K 线 TypeKlineQuarter uint8 = 10 // 季K 线 TypeKlineYear uint8 = 11 // 年K 线 )
View Source
const ( KindIndex = "index" KindStock = "stock" )
Variables ¶
View Source
var ( MConnect = connect{} MHeart = heart{} MCount = count{} MQuote = quote{} MCode = code{} MMinute = minute{} MHistoryMinute = historyMinute{} MCallAuction = callAuction{} MTrade = trade{} MHistoryTrade = historyTrade{} MKline = kline{} )
View Source
var ( // ExchangeEstablish 交易所成立时间 ExchangeEstablish = time.Date(1990, 12, 19, 0, 0, 0, 0, time.Local) )
Functions ¶
func FloatUnitString ¶
func GetHourMinute ¶
func Int64UnitString ¶
func IntUnitString ¶
Types ¶
type CallAuction ¶ added in v0.0.56
type CallAuctionResp ¶ added in v0.0.56
type CallAuctionResp struct {
Count uint16
List []*CallAuction
}
type Code ¶
type ConnectResp ¶
type ConnectResp struct {
Info string
}
type Frame ¶
type Frame struct {
MsgID uint32 //消息ID
Control Control //控制码,这个还不知道怎么定义
Type uint16 //请求类型,如建立连接,请求分时数据等
Data []byte //数据
}
Frame 数据帧 0c 02189300 01 0300 0300 0d00 01 0c 00000000 00 0200 0200 1500 0c 01000000 01 0300 0300 0d00 01 0c 01000000 01 0300 0300 0d00 01 0c 02000000 01 1a00 1a00 3e05 050000000000000002000030303030303101363030303038
0c0100000001030003000d0001
type K ¶
type K struct {
Last Price //昨天收盘价
Open Price //今日开盘价
High Price //今日最高价
Low Price //今日最低价
Close Price //今日收盘价
}
K k线图
type Kline ¶
type Kline struct {
Last Price //昨日收盘价,这个是列表的上一条数据的收盘价,如果没有上条数据,那么这个值为0
Open Price //开盘价
High Price //最高价
Low Price //最低价
Close Price //收盘价,如果是当天,则是最新价/实时价
Order int //成交单数,不一定有值
Volume int64 //成交量
Amount Price //成交额
Time time.Time //时间
UpCount int //上涨数量,指数有效
DownCount int //下跌数量,指数有效
}
func FixKlineTime ¶
FixKlineTime 修复盘内下午(13~15点)拉取数据的时候,11.30的时间变成13.00
type KlineCache ¶
type MinuteResp ¶
type MinuteResp struct {
Count uint16
List []PriceNumber
}
type PriceLevel ¶
type PriceLevels ¶
type PriceLevels [5]PriceLevel
func (PriceLevels) String ¶
func (this PriceLevels) String() string
type PriceNumber ¶
func (PriceNumber) String ¶
func (this PriceNumber) String() string
type Quote ¶
type Quote struct {
Exchange Exchange // 市场
Code string // 股票代码 6个ascii字符串
Active1 uint16 // 活跃度
K K //k线
ServerTime string // 时间
ReversedBytes0 int // 保留(时间 ServerTime)
ReversedBytes1 int // 保留 这个等于 负的收盘价格?
TotalHand int // 总手(东财的盘口-总手)
Intuition int // 现量(东财的盘口-现量)现在成交量
Amount float64 // 金额(东财的盘口-金额)
InsideDish int // 内盘(东财的盘口-外盘)(和东财对不上)
OuterDisc int // 外盘(东财的盘口-外盘)(和东财对不上)
ReversedBytes2 int // 保留,未知
ReversedBytes3 int // 保留,未知,基金的昨收净值?
BuyLevel PriceLevels // 5档买盘(买1-5)
SellLevel PriceLevels // 5档卖盘(卖1-5)
ReversedBytes4 uint16 // 保留,未知
ReversedBytes5 int // 保留,未知
ReversedBytes6 int // 保留,未知
ReversedBytes7 int // 保留,未知
ReversedBytes8 int // 保留,未知
ReversedBytes9 uint16 // 保留,未知
Rate float64 // 涨速,好像都是0
Active2 uint16 // 活跃度
}
type QuotesResp ¶
type QuotesResp []*Quote
func (QuotesResp) String ¶
func (this QuotesResp) String() string
type Response ¶
type Response struct {
Prefix uint32 //未知,猜测是帧头
Control uint8 //响应的控制码,目前发现0c是错误,1c是成功,猜测左数右第4位代表是否成功
MsgID uint32 //消息ID
Unknown uint8 //未知,猜测是响应的控制码
Type uint16 //响应类型,对应请求类型,如建立连接,请求分时数据等
ZipLength uint16 //数据长度
Length uint16 //未压缩长度
Data []byte //数据域
}
type Trade ¶
type Trade struct {
Time time.Time //时间, 09:30
Price Price //价格
Volume int //成交量,手
Status int //0是买,1是卖,2中性/汇总 中途也可能出现2,例20241115(sz000001)的14:56
Number int //单数,历史数据该字段无效
}
Trade 分时成交,todo 时间没有到秒,客户端上也没有,东方客户端能显示秒
func (*Trade) StatusString ¶
type TradeCache ¶
Click to show internal directories.
Click to hide internal directories.