quotes

package
v1.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 31 Imported by: 15

Documentation

Index

Constants

View Source
const (
	DefaultRetryTimes  = 3 // 重试次数
	MessageHeaderBytes = 0x10
	MessageMaxBytes    = 1 << 15
)
View Source
const (
	// POOL_INITED 连接池初始化
	POOL_INITED = 1
	// POOL_MAX 连接池最大 2
	POOL_MAX = 5
	// CONN_TIMEOUT 链接超时 10 s
	CONN_TIMEOUT = 10
	// RECV_TIMEOUT 接收数据超时
	RECV_TIMEOUT = 2
)
View Source
const (
	// HQ_HOSTS 标准市场 主机列表
	HQ_HOSTS = `` /* 2678-byte string literal not displayed */

	// EX_HOSTS 扩展市场主机列表
	EX_HOSTS = `` /* 684-byte string literal not displayed */

	// GP_HOSTS 财务数据 主机列表
	GP_HOSTS = `[
{"name":"默认财务数据线路", "host":"120.76.152.87", "port": 7709}
]`
)
View Source
const (
	TDX_HOST_HQ = "HQ"
	TDX_HOST_EX = "EX"
	TDX_HOST_GP = "GP"
)
View Source
const (
	BLOCK_ZHISHU      = "block_zs.dat" // 指数
	BLOCK_FENGGE      = "block_fg.dat" // 风格
	BLOCK_GAINIAN     = "block_gn.dat" // 概念
	BLOCK_DEFAULT     = "block.dat"    // 早期的板块数据文件, 与block_zs.dat
	BLOCK_CHUNKS_SIZE = 0x7530         // 板块文件默认一个请求包最大数据
)

板块相关参数

View Source
const (
	TDX_SECURITY_BARS_MAX = 800 // 单次最大获取800条K线数据
)
View Source
const (
	TDX_SECURITY_LIST_MAX = 1000 // 单次最大获取多少条股票数据
)
View Source
const (
	TDX_SECURITY_QUOTES_MAX = 80 // 单次最大获取80条实时数据
)
View Source
const (
	TDX_SECURITY_QUOTES_MAX_V2 = 80 // 单次最大获取80条实时数据
)
View Source
const (
	TDX_TRANSACTION_MAX = 1800 // 单次最多获取多少条分笔成交记录
)

Variables

View Source
var (
	ErrBadData = errors.New("more than 8M data")
)
View Source
var (
	XDXR_CATEGORY_MAPPING = map[int]string{
		1:  "除权除息",
		2:  "送配股上市",
		3:  "非流通股上市",
		4:  "未知股本变动",
		5:  "股本变化",
		6:  "增发新股",
		7:  "股份回购",
		8:  "增发新股上市",
		9:  "转配股上市",
		10: "可转债上市",
		11: "扩缩股",
		12: "非流通股缩股",
		13: "送认购权证",
		14: "送认沽权证",
	}
)

Functions

func BestIP

func BestIP()

BestIP 测试最快的服务器

func CacheServers

func CacheServers(as AllServers) error

func CommandWithConn

func CommandWithConn(cli *LabClient, callback std.Factory) (std.Unmarshaler, error)

func ExamplePinger added in v1.5.6

func ExamplePinger()

func Utf8ToGbk

func Utf8ToGbk(text []byte) string

Types

type AllServers

type AllServers struct {
	//Server ServerGroup `json:"Server"`
	BestIP ServerGroup `json:"BestIP"`
}

AllServers 全部主机

func OpenConfig

func OpenConfig() *AllServers

type BlockInfo added in v1.2.7

type BlockInfo struct {
	BlockName  string
	BlockType  uint16
	StockCount uint16
	Codelist   []string
}

type BlockInfoPackage added in v1.2.7

type BlockInfoPackage struct {
	// contains filtered or unexported fields
}

BlockInfoPackage 板块信息

func NewBlockInfoPackage added in v1.2.7

func NewBlockInfoPackage() *BlockInfoPackage

func (*BlockInfoPackage) Reply added in v1.2.7

func (obj *BlockInfoPackage) Reply() interface{}

func (*BlockInfoPackage) Serialize added in v1.2.7

func (obj *BlockInfoPackage) Serialize() ([]byte, error)

func (*BlockInfoPackage) SetParams added in v1.2.7

func (obj *BlockInfoPackage) SetParams(req *BlockInfoRequest)

func (*BlockInfoPackage) UnSerialize added in v1.2.7

func (obj *BlockInfoPackage) UnSerialize(header interface{}, data []byte) error

type BlockInfoReply added in v1.2.7

type BlockInfoReply struct {
	BlockNum uint16      `struc:"uint16,little"` // 板块个数
	Block    []BlockInfo // 板块列表
}

type BlockInfoRequest added in v1.2.7

type BlockInfoRequest struct {
	Start     uint32    `struc:"uint32,little"`
	Size      uint32    `struc:"uint32,little"`
	BlockFile [100]byte `struc:"[100]byte,little"` // 板块文件名
}

BlockInfoRequest 请求包

type BlockInfoResponse added in v1.2.7

type BlockInfoResponse struct {
	Size uint32 `struc:"uint32,little"`
	Data []byte `struc:"sizefrom=Size"`
}

type BlockMeta added in v1.2.7

type BlockMeta struct {
	Size      uint32   `struc:"uint32,little"`   // 尺寸
	C1        byte     `struc:"byte,little"`     // C1
	HashValue [32]byte `struc:"[32]byte,little"` // hash值
	C2        byte     `struc:"byte,little"`     // C2
}

BlockMeta 响应包结构

type BlockMetaPackage added in v1.2.7

type BlockMetaPackage struct {
	// contains filtered or unexported fields
}

BlockMetaPackage 板块信息

func NewBlockMetaPackage added in v1.2.7

func NewBlockMetaPackage() *BlockMetaPackage

func (*BlockMetaPackage) Reply added in v1.2.7

func (obj *BlockMetaPackage) Reply() interface{}

func (*BlockMetaPackage) Serialize added in v1.2.7

func (obj *BlockMetaPackage) Serialize() ([]byte, error)

func (*BlockMetaPackage) SetParams added in v1.2.7

func (obj *BlockMetaPackage) SetParams(req *BlockMetaRequest)

func (*BlockMetaPackage) UnSerialize added in v1.2.7

func (obj *BlockMetaPackage) UnSerialize(header interface{}, data []byte) error

type BlockMetaRequest added in v1.2.7

type BlockMetaRequest struct {
	BlockFile [40]byte // 板块文件名
}

BlockMetaRequest 请求包

type ConnPool

type ConnPool struct {
	// contains filtered or unexported fields
}

ConnPool 连接池

func NewConnPool

func NewConnPool(opt Opt, size int, factory func() (interface{}, error), close func(interface{}) error, ping func(interface{}) error) (*ConnPool, error)

NewConnPool 创新一个新连接池

func (*ConnPool) Close

func (p *ConnPool) Close()

func (*ConnPool) CloseConn added in v1.3.0

func (p *ConnPool) CloseConn(conn interface{}) error

func (*ConnPool) GetConn

func (p *ConnPool) GetConn() interface{}

func (*ConnPool) ReturnConn

func (p *ConnPool) ReturnConn(conn interface{})

type FinanceInfo

type FinanceInfo struct {
	LiuTongGuBen       float64 `struc:"float32,little" json:"liu_tong_gu_ben"`
	Province           uint16  `struc:"uint16,little" json:"province"`
	Industry           uint16  `struc:"uint16,little" json:"industry"`
	UpdatedDate        uint32  `struc:"uint32,little" json:"updatedDate"`
	IPODate            uint32  `struc:"uint32,little" json:"ipo_date"`
	ZongGuBen          float64 `struc:"float32,little" json:"zong_gu_ben"`
	GuoJiaGu           float64 `struc:"float32,little" json:"guo_jia_gu"`
	FaQiRenFaRenGu     float64 `struc:"float32,little" json:"fa_qi_ren_fa_ren_gu"`
	FaRenGu            float64 `struc:"float32,little" json:"fa_ren_gu"`
	BGu                float64 `struc:"float32,little" json:"b_gu"`
	HGu                float64 `struc:"float32,little" json:"h_gu"`
	ZhiGongGu          float64 `struc:"float32,little" json:"zhi_gong_gu"`
	ZongZiChan         float64 `struc:"float32,little" json:"zong_zi_chan"`
	LiuDongZiChan      float64 `struc:"float32,little" json:"liu_dong_zi_chan"`
	GuDingZiChan       float64 `struc:"float32,little" json:"gu_ding_zi_chan"`
	WuXingZiChan       float64 `struc:"float32,little" json:"wu_xing_zi_chan"`
	GuDongRenShu       float64 `struc:"float32,little" json:"gu_dong_ren_shu"`
	LiuDongFuZhai      float64 `struc:"float32,little" json:"liu_dong_fu_zhai"`
	ChangQiFuZhai      float64 `struc:"float32,little" json:"chang_qi_fu_zhai"`
	ZiBenGongJiJin     float64 `struc:"float32,little" json:"zi_ben_gong_ji_jin"`
	JingZiChan         float64 `struc:"float32,little" json:"jing_zi_chan"`
	ZhuYingShouRu      float64 `struc:"float32,little" json:"zhu_ying_shou_ru"`
	ZhuYingLiRun       float64 `struc:"float32,little" json:"zhu_ying_li_run"`
	YingShouZhangKuan  float64 `struc:"float32,little" json:"ying_shou_zhang_kuan"`
	YingyeLiRun        float64 `struc:"float32,little" json:"yingye_li_run"`
	TouZiShouYu        float64 `struc:"float32,little" json:"tou_zi_shou_yu"`
	JingYingxianJinLiu float64 `struc:"float32,little" json:"jing_yingxian_jin_liu"`
	ZongXianJinLiu     float64 `struc:"float32,little" json:"zong_xian_jin_liu"`
	CunHuo             float64 `struc:"float32,little" json:"cun_huo"`
	LiRunZongHe        float64 `struc:"float32,little" json:"li_run_zong_he"`
	ShuiHouLiRun       float64 `struc:"float32,little" json:"shui_hou_li_run"`
	JingLiRun          float64 `struc:"float32,little" json:"jing_li_run"`
	WeiFenLiRun        float64 `struc:"float32,little" json:"wei_fen_li_run"`
	MeiGuJingZiChan    float64 `struc:"float32,little" json:"mei_gu_jing_zi_chan"`
	BaoLiu2            float64 `struc:"float32,little" json:"bao_liu_2"`
}

type FinanceInfoPackage

type FinanceInfoPackage struct {
	// contains filtered or unexported fields
}

FinanceInfoPackage 基本信息

func NewFinanceInfoPackage

func NewFinanceInfoPackage() *FinanceInfoPackage

func (*FinanceInfoPackage) Reply

func (obj *FinanceInfoPackage) Reply() interface{}

func (*FinanceInfoPackage) Serialize

func (obj *FinanceInfoPackage) Serialize() ([]byte, error)

func (*FinanceInfoPackage) SetParams

func (obj *FinanceInfoPackage) SetParams(req *FinanceInfoRequest)

func (*FinanceInfoPackage) UnSerialize

func (obj *FinanceInfoPackage) UnSerialize(header interface{}, data []byte) error

type FinanceInfoReply

type FinanceInfoReply struct {
	Count uint16 //  总数
	//Market uint8   `struc:"uint8,little"`
	//Code   [6]byte `struc:"[6]byte,little"`
	First RawFinanceInfo
}

FinanceInfoReply 响应包结构

type FinanceInfoRequest

type FinanceInfoRequest struct {
	Count  uint16  // 总数
	Market uint8   // 市场代码
	Code   [6]byte // 股票代码
}

type HeartBeatPackage added in v1.5.0

type HeartBeatPackage struct {
	// contains filtered or unexported fields
}

func NewHeartBeat added in v1.5.0

func NewHeartBeat() *HeartBeatPackage

func (*HeartBeatPackage) Reply added in v1.5.0

func (obj *HeartBeatPackage) Reply() interface{}

func (*HeartBeatPackage) Serialize added in v1.5.0

func (obj *HeartBeatPackage) Serialize() ([]byte, error)

func (*HeartBeatPackage) UnSerialize added in v1.5.0

func (obj *HeartBeatPackage) UnSerialize(header interface{}, data []byte) error

type HeartBeatReply added in v1.5.0

type HeartBeatReply struct {
	Info string // 10个字节的消息, 未解
}

type HeartBeatRequest added in v1.5.0

type HeartBeatRequest struct {
}

type Hello1Package

type Hello1Package struct {
	// contains filtered or unexported fields
}

func NewHello1

func NewHello1() *Hello1Package

func (*Hello1Package) Reply

func (obj *Hello1Package) Reply() interface{}

func (*Hello1Package) Serialize

func (obj *Hello1Package) Serialize() ([]byte, error)

func (*Hello1Package) UnSerialize

func (obj *Hello1Package) UnSerialize(header interface{}, data []byte) error

00e60708051 50 f0 00 d3 a02b2020c03840384038403840384033a02b2020c0384038403840384038403 00 5a8a3401 f94a0100 5a8a3401 fd4a0100ff00e 700000101013f

分  时    秒                                                                      日期

type Hello1Reply

type Hello1Reply struct {
	Info string
	// contains filtered or unexported fields
}

type Hello1Request

type Hello1Request struct {
}

type Hello2Package

type Hello2Package struct {
	// contains filtered or unexported fields
}

func NewHello2

func NewHello2() *Hello2Package

func (*Hello2Package) Reply

func (obj *Hello2Package) Reply() interface{}

func (*Hello2Package) Serialize

func (obj *Hello2Package) Serialize() ([]byte, error)

func (*Hello2Package) UnSerialize

func (obj *Hello2Package) UnSerialize(header interface{}, data []byte) error

0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011f85e34068747470733a2f2f626967352e6e65776f6e652e636f6d2e636e2f7a797968742f7a645f7a737a712e7a6970000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004150503a414c4c0d0a54494d453a303a30312d31353a30352c31353a30362d32333a35390d0a20202020c4facab9d3c3b5c4b0e6b1bebcb4bdabcda3d3c3a3acceaac1cbc4fab5c4d5fdb3a3cab9d3c32cc7ebbea1bfecc9fdd6c1d5d0c9ccd6a4c8af5043b0e6a1a30d0a20202020c8e7b9fbb2bbc4dcd7d4b6afc9fdbcb6a3acc7ebb5bdb9d9cdf868747470733a2f2f7777772e636d736368696e612e636f6d2fcfc2d4d8b0b2d7b0a3acd0bbd0bbc4fab5c4d6a7b3d6a3a100 年月日 年月日

type Hello2Reply

type Hello2Reply struct {
	Info string
	// contains filtered or unexported fields
}

type Hello2Request

type Hello2Request struct {
}

type HistoryMinuteTime

type HistoryMinuteTime struct {
	Price float32
	Vol   int
}

type HistoryMinuteTimePackage

type HistoryMinuteTimePackage struct {
	// contains filtered or unexported fields
}

func NewHistoryMinuteTimePackage

func NewHistoryMinuteTimePackage() *HistoryMinuteTimePackage

func (*HistoryMinuteTimePackage) Reply

func (obj *HistoryMinuteTimePackage) Reply() interface{}

func (*HistoryMinuteTimePackage) Serialize

func (obj *HistoryMinuteTimePackage) Serialize() ([]byte, error)

func (*HistoryMinuteTimePackage) SetParams

SetParams 设置参数

func (*HistoryMinuteTimePackage) UnSerialize

func (obj *HistoryMinuteTimePackage) UnSerialize(header interface{}, data []byte) error

type HistoryMinuteTimeReply

type HistoryMinuteTimeReply struct {
	Count uint16
	List  []HistoryMinuteTime
}

type HistoryMinuteTimeRequest

type HistoryMinuteTimeRequest struct {
	Date   uint32
	Market uint8
	Code   [6]byte
}

type HistoryTransactionPackage

type HistoryTransactionPackage struct {
	// contains filtered or unexported fields
}

func NewHistoryTransactionPackage

func NewHistoryTransactionPackage() *HistoryTransactionPackage

func (*HistoryTransactionPackage) Reply

func (obj *HistoryTransactionPackage) Reply() interface{}

func (*HistoryTransactionPackage) Serialize

func (obj *HistoryTransactionPackage) Serialize() ([]byte, error)

func (*HistoryTransactionPackage) SetParams

SetParams 设置参数

func (*HistoryTransactionPackage) UnSerialize

func (obj *HistoryTransactionPackage) UnSerialize(header interface{}, data []byte) error

type HistoryTransactionRequest

type HistoryTransactionRequest struct {
	Date   uint32
	Market uint16
	Code   [6]byte
	Start  uint16
	Count  uint16
}

type IndexBarsPackage

type IndexBarsPackage struct {
	// contains filtered or unexported fields
}

IndexBarsPackage 指数K线

func NewIndexBarsPackage

func NewIndexBarsPackage() *IndexBarsPackage

func (*IndexBarsPackage) Reply

func (obj *IndexBarsPackage) Reply() interface{}

func (*IndexBarsPackage) Serialize

func (obj *IndexBarsPackage) Serialize() ([]byte, error)

func (*IndexBarsPackage) SetParams

func (obj *IndexBarsPackage) SetParams(req *SecurityBarsRequest)

func (*IndexBarsPackage) UnSerialize

func (obj *IndexBarsPackage) UnSerialize(header interface{}, data []byte) error

type LabClient added in v1.3.0

type LabClient struct {

	//Host          string
	//Port          int
	Timeout       time.Duration
	MaxRetryTimes int
	RetryDuration time.Duration
	// contains filtered or unexported fields
}

func NewClientForTest added in v1.3.0

func NewClientForTest(addr string) (*LabClient, error)

func (*LabClient) Close added in v1.3.0

func (cli *LabClient) Close() error

func (*LabClient) Do added in v1.3.0

func (cli *LabClient) Do(request std.Marshaler, response std.Unmarshaler) error

type Level

type Level struct {
	Price float64
	Vol   int
}

type Message

type Message interface {
	// Serialize 编码
	Serialize() ([]byte, error)
	// UnSerialize 解码
	UnSerialize(head interface{}, in []byte) error
	// Reply 获取返回值
	Reply() interface{}
}

Message 消息接口

type MinuteTime

type MinuteTime struct {
	Price float32
	Vol   int
}

type MinuteTimePackage

type MinuteTimePackage struct {
	// contains filtered or unexported fields
}

func NewMinuteTimePackage

func NewMinuteTimePackage() *MinuteTimePackage

func (*MinuteTimePackage) Reply

func (obj *MinuteTimePackage) Reply() interface{}

func (*MinuteTimePackage) Serialize

func (obj *MinuteTimePackage) Serialize() ([]byte, error)

func (*MinuteTimePackage) SetParams

func (obj *MinuteTimePackage) SetParams(req *MinuteTimeRequest)

func (*MinuteTimePackage) UnSerialize

func (obj *MinuteTimePackage) UnSerialize(header interface{}, data []byte) error

type MinuteTimeReply

type MinuteTimeReply struct {
	Count uint16
	List  []MinuteTime
}

type MinuteTimeRequest

type MinuteTimeRequest struct {
	Market uint16
	Code   [6]byte
	Date   uint32
}

type Opt

type Opt struct {
	Servers []Server // 服务器组

	ConnectionTimeout time.Duration // 连接超时
	ReadTimeout       time.Duration // 读超时
	WriteTimeout      time.Duration // 写超时
	MaxRetryTimes     int           // 最大重试次数
	RetryDuration     time.Duration // 重试时间
	// contains filtered or unexported fields
}

type RawFinanceInfo added in v1.1.3

type RawFinanceInfo struct {
	//Unknown1           [2]byte `struc:"[2]byte,little"`
	Market             uint8   `struc:"uint8,little"`
	Code               [6]byte `struc:"[6]byte,little"`
	LiuTongGuBen       float32 `struc:"float32,little"` // 流通股本
	Province           uint16  `struc:"uint16,little"`  // 所属省份
	Industry           uint16  `struc:"uint16,little"`
	UpdatedDate        uint32  `struc:"uint32,little"`
	IPODate            uint32  `struc:"uint32,little"`
	ZongGuBen          float32 `struc:"float32,little"`
	GuoJiaGu           float32 `struc:"float32,little"`
	FaQiRenFaRenGu     float32 `struc:"float32,little"`
	FaRenGu            float32 `struc:"float32,little"`
	BGu                float32 `struc:"float32,little"` // B股
	HGu                float32 `struc:"float32,little"` // H股
	ZhiGongGu          float32 `struc:"float32,little"`
	ZongZiChan         float32 `struc:"float32,little"`
	LiuDongZiChan      float32 `struc:"float32,little"`
	GuDingZiChan       float32 `struc:"float32,little"`
	WuXingZiChan       float32 `struc:"float32,little"`
	GuDongRenShu       float32 `struc:"float32,little"`
	LiuDongFuZhai      float32 `struc:"float32,little"`
	ChangQiFuZhai      float32 `struc:"float32,little"`
	ZiBenGongJiJin     float32 `struc:"float32,little"`
	JingZiChan         float32 `struc:"float32,little"`
	ZhuYingShouRu      float32 `struc:"float32,little"`
	ZhuYingLiRun       float32 `struc:"float32,little"`
	Yingshouzhangkuan  float32 `struc:"float32,little"`
	YingyeLiRun        float32 `struc:"float32,little"`
	TouZiShouYu        float32 `struc:"float32,little"`
	JingYingxianJinLiu float32 `struc:"float32,little"`
	ZongXianJinLiu     float32 `struc:"float32,little"`
	CunHuo             float32 `struc:"float32,little"`
	LiRunZongHe        float32 `struc:"float32,little"`
	ShuiHouLiRun       float32 `struc:"float32,little"`
	JingLiRun          float32 `struc:"float32,little"`
	WeiFenLiRun        float32 `struc:"float32,little"`
	BaoLiu1            float32 `struc:"float32,little"`
	BaoLiu2            float32 `struc:"float32,little"`
}

RawFinanceInfo 响应包结构

一次返回145个字节, 现在有136个字节, 空余9个字节分别是总数、市场和代码
Num每加1, 返回字节数增加143

type RawFinanceInfo1 added in v1.1.3

type RawFinanceInfo1 struct {
	//Unknown1           [2]byte `struc:"[2]byte,little"`
	//Market             uint8   `struc:"uint8,little"`
	//Code               [6]byte `struc:"[6]byte,little"`
	LiuTongGuBen       float32 `struc:"float32,little"`
	Province           uint16  `struc:"uint16,little"`
	Industry           uint16  `struc:"uint16,little"`
	UpdatedDate        uint32  `struc:"uint32,little"`
	IPODate            uint32  `struc:"uint32,little"`
	ZongGuBen          float32 `struc:"float32,little"`
	GuoJiaGu           float32 `struc:"float32,little"`
	FaQiRenFaRenGu     float32 `struc:"float32,little"`
	FaRenGu            float32 `struc:"float32,little"`
	BGu                float32 `struc:"float32,little"`
	HGu                float32 `struc:"float32,little"`
	ZhiGongGu          float32 `struc:"float32,little"`
	ZongZiChan         float32 `struc:"float32,little"`
	LiuDongZiChan      float32 `struc:"float32,little"`
	GuDingZiChan       float32 `struc:"float32,little"`
	WuXingZiChan       float32 `struc:"float32,little"`
	GuDongRenShu       float32 `struc:"float32,little"`
	LiuDongFuZhai      float32 `struc:"float32,little"`
	ChangQiFuZhai      float32 `struc:"float32,little"`
	ZiBenGongJiJin     float32 `struc:"float32,little"`
	JingZiChan         float32 `struc:"float32,little"`
	ZhuYingShouRu      float32 `struc:"float32,little"`
	ZhuYingLiRun       float32 `struc:"float32,little"`
	Yingshouzhangkuan  float32 `struc:"float32,little"`
	YingyeLiRun        float32 `struc:"float32,little"`
	TouZiShouYu        float32 `struc:"float32,little"`
	JingYingxianJinLiu float32 `struc:"float32,little"`
	ZongXianJinLiu     float32 `struc:"float32,little"`
	CunHuo             float32 `struc:"float32,little"`
	LiRunZongHe        float32 `struc:"float32,little"`
	ShuiHouLiRun       float32 `struc:"float32,little"`
	JingLiRun          float32 `struc:"float32,little"`
	WeiFenLiRun        float32 `struc:"float32,little"`
	BaoLiu1            float32 `struc:"float32,little"`
	BaoLiu2            float32 `struc:"float32,little"`
	BaoLiu3            [7]byte `struc:"[7]byte,little"`
}

type RawXdxrInfo added in v1.2.4

type RawXdxrInfo struct {
	Market   int    `struc:"uint8,little"`   // 市场代码
	Code     string `struc:"[6]byte,little"` // 股票代码
	Unknown  int    `struc:"uint8,little"`   // 未知
	Date     uint32 `struc:"uint32,little"`  // 日期
	Category int    `struc:"uint8,little"`   // 类型
	Data     []byte `struc:"[16]byte,little"`
}

type Security

type Security struct {
	Code      string
	VolUnit   uint16
	Reversed1 [4]byte `dataframe:"-"`
	//R1           uint32
	//P1           float64
	DecimalPoint int8
	Name         string
	PreClose     float64
	Reversed2    [4]byte `dataframe:"-"`
}

type SecurityBar

type SecurityBar struct {
	Open      float64
	Close     float64
	High      float64
	Low       float64
	Vol       float64
	Amount    float64
	Year      int
	Month     int
	Day       int
	Hour      int
	Minute    int
	DateTime  string
	UpCount   uint16 // 指数有效, 上涨家数
	DownCount uint16 // 指数有效, 下跌家数
}

SecurityBar K线数据

type SecurityBarsPackage

type SecurityBarsPackage struct {
	// contains filtered or unexported fields
}

SecurityBars K线

func NewSecurityBarsPackage

func NewSecurityBarsPackage() *SecurityBarsPackage

func (*SecurityBarsPackage) Reply

func (obj *SecurityBarsPackage) Reply() interface{}

func (*SecurityBarsPackage) Serialize

func (obj *SecurityBarsPackage) Serialize() ([]byte, error)

func (*SecurityBarsPackage) SetParams

func (obj *SecurityBarsPackage) SetParams(req *SecurityBarsRequest)

func (*SecurityBarsPackage) UnSerialize

func (obj *SecurityBarsPackage) UnSerialize(header interface{}, data []byte) error

type SecurityBarsReply

type SecurityBarsReply struct {
	Count uint16
	List  []SecurityBar
}

type SecurityBarsRequest

type SecurityBarsRequest struct {
	Market   uint16
	Code     [6]byte
	Category uint16 // 种类 5分钟  10分钟
	I        uint16 // 未知 填充
	Start    uint16
	Count    uint16
}

type SecurityCountPackage

type SecurityCountPackage struct {
	// contains filtered or unexported fields
}

SecurityCountPackage 市场股票数量

func NewSecurityCountPackage

func NewSecurityCountPackage() *SecurityCountPackage

func (*SecurityCountPackage) Reply

func (obj *SecurityCountPackage) Reply() interface{}

func (*SecurityCountPackage) Serialize

func (obj *SecurityCountPackage) Serialize() ([]byte, error)

func (*SecurityCountPackage) SetParams

func (obj *SecurityCountPackage) SetParams(req *SecurityCountRequest)

func (*SecurityCountPackage) UnSerialize

func (obj *SecurityCountPackage) UnSerialize(header interface{}, data []byte) error

type SecurityCountReply

type SecurityCountReply struct {
	Count uint16
}

type SecurityCountRequest

type SecurityCountRequest struct {
	Market uint16
}

type SecurityListPackage

type SecurityListPackage struct {
	// contains filtered or unexported fields
}

SecurityListPackage 股票列表

func NewSecurityListPackage

func NewSecurityListPackage() *SecurityListPackage

func (*SecurityListPackage) Reply

func (obj *SecurityListPackage) Reply() interface{}

func (*SecurityListPackage) Serialize

func (obj *SecurityListPackage) Serialize() ([]byte, error)

func (*SecurityListPackage) SetParams

func (obj *SecurityListPackage) SetParams(req *SecurityListRequest)

func (*SecurityListPackage) UnSerialize

func (obj *SecurityListPackage) UnSerialize(header interface{}, data []byte) error

type SecurityListReply

type SecurityListReply struct {
	Count uint16
	List  []Security
}

type SecurityListRequest

type SecurityListRequest struct {
	Market uint16
	Start  uint16
}

type SecurityQuote

type SecurityQuote struct {
	State           TradeState // 交易状态
	Market          uint8      // 市场
	Code            string     // 代码
	Active1         uint16     // 活跃度
	Price           float64    // 现价
	LastClose       float64    // 昨收
	Open            float64    // 开盘
	High            float64    // 最高
	Low             float64    // 最低
	ServerTime      string     // 时间
	ReversedBytes0  int        // 保留(时间 ServerTime)
	ReversedBytes1  int        // 保留
	Vol             int        // 总量
	CurVol          int        // 现量
	Amount          float64    // 总金额
	SVol            int        // 内盘
	BVol            int        // 外盘
	IndexOpenAmount int        // 指数-集合竞价成交金额=开盘成交金额
	StockOpenAmount int        // 个股-集合竞价成交金额=开盘成交金额
	OpenVolume      int        // 集合竞价-开盘量, 单位是股
	Bid1            float64
	Ask1            float64
	BidVol1         int
	AskVol1         int
	Bid2            float64
	Ask2            float64
	BidVol2         int
	AskVol2         int
	Bid3            float64
	Ask3            float64
	BidVol3         int
	AskVol3         int
	Bid4            float64
	Ask4            float64
	BidVol4         int
	AskVol4         int
	Bid5            float64
	Ask5            float64
	BidVol5         int
	AskVol5         int
	ReversedBytes4  uint16  // 保留
	ReversedBytes5  int     // 保留
	ReversedBytes6  int     // 保留
	ReversedBytes7  int     // 保留
	ReversedBytes8  int     // 保留
	Rate            float64 // 涨速
	Active2         uint16  // 活跃度, 如果是指数则为0, 个股同Active1
}

type SecurityQuotesPackage

type SecurityQuotesPackage struct {
	// contains filtered or unexported fields
}

SecurityQuotesPackage 盘口五档报价

func NewSecurityQuotesPackage added in v1.3.9

func NewSecurityQuotesPackage() *SecurityQuotesPackage

func (*SecurityQuotesPackage) Reply

func (obj *SecurityQuotesPackage) Reply() interface{}

func (*SecurityQuotesPackage) Serialize

func (obj *SecurityQuotesPackage) Serialize() ([]byte, error)

func (*SecurityQuotesPackage) SetParams

func (obj *SecurityQuotesPackage) SetParams(req *SecurityQuotesRequest)

func (*SecurityQuotesPackage) UnSerialize

func (obj *SecurityQuotesPackage) UnSerialize(header interface{}, data []byte) error

type SecurityQuotesReply

type SecurityQuotesReply struct {
	Count uint16
	List  []SecurityQuote
}

type SecurityQuotesRequest

type SecurityQuotesRequest struct {
	Count     uint16
	StockList []Stock
}

type Server

type Server struct {
	Name      string `json:"name"`
	Host      string `json:"host"`
	Port      int    `json:"port"`
	CrossTime int64  `json:"crossTime"`
}

Server 主机信息

var (
	DefaultHQServer Server
	DefaultEXServer Server
)

func GetFastHost

func GetFastHost(key string) []Server

func (Server) Addr added in v1.1.3

func (s Server) Addr() string

type ServerGroup

type ServerGroup struct {
	HQ []Server `json:"HQ"`
	EX []Server `json:"EX"`
	GP []Server `json:"GP"`
}

ServerGroup 主机组

type StdApi

type StdApi struct {
	// contains filtered or unexported fields
}

func NewStdApi

func NewStdApi() (*StdApi, error)

NewStdApi 创建一个标准接口

func NewStdApiWithServers added in v1.1.1

func NewStdApiWithServers(srvs []Server) (*StdApi, error)

NewStdApiWithServers 通过服务器组创建一个标准接口

func (*StdApi) Close

func (this *StdApi) Close()

Close 关闭

func (*StdApi) GetBlockInfo added in v1.2.7

func (this *StdApi) GetBlockInfo(block_file string) (*BlockInfoResponse, error)

func (*StdApi) GetBlockMeta added in v1.2.7

func (this *StdApi) GetBlockMeta(block_file string) (*BlockMeta, error)

func (*StdApi) GetFinanceInfo

func (this *StdApi) GetFinanceInfo(market proto.Market, code string, num uint16) (*FinanceInfo, error)

GetFinanceInfo 基本面

func (*StdApi) GetHistoryMinuteTimeData

func (this *StdApi) GetHistoryMinuteTimeData(market proto.Market, code string, date uint32) (*HistoryMinuteTimeReply, error)

GetHistoryMinuteTimeData 获取历史分时图数据

func (*StdApi) GetHistoryTransactionData

func (this *StdApi) GetHistoryTransactionData(market proto.Market, code string, date uint32, start uint16, count uint16) (*TransactionReply, error)

GetHistoryTransactionData 获取历史分时成交

func (*StdApi) GetIndexBars

func (this *StdApi) GetIndexBars(market proto.Market, code string, category uint16, start uint16, count uint16) (*SecurityBarsReply, error)

GetIndexBars 指数K线

func (*StdApi) GetKLine

func (this *StdApi) GetKLine(market proto.Market, code string, category uint16, start uint16, count uint16) (*SecurityBarsReply, error)

GetKLine K线

func (*StdApi) GetMinuteTimeData

func (this *StdApi) GetMinuteTimeData(market proto.Market, code string) (*MinuteTimeReply, error)

GetMinuteTimeData 获取分时图数据

func (*StdApi) GetSecurityCount

func (this *StdApi) GetSecurityCount(market proto.Market) (*SecurityCountReply, error)

GetSecurityCount 获取指定市场内的证券数目

func (*StdApi) GetSecurityList

func (this *StdApi) GetSecurityList(market proto.Market, start uint16) (*SecurityListReply, error)

GetSecurityList 股票列表

func (*StdApi) GetSecurityQuotes

func (this *StdApi) GetSecurityQuotes(markets []proto.Market, codes []string) (*SecurityQuotesReply, error)

GetSecurityQuotes 获取盘口五档报价

func (*StdApi) GetTransactionData

func (this *StdApi) GetTransactionData(market proto.Market, code string, start uint16, count uint16) (*TransactionReply, error)

GetTransactionData 获取分时成交

func (*StdApi) GetXdxrInfo added in v1.2.4

func (this *StdApi) GetXdxrInfo(market proto.Market, code string) ([]XdxrInfo, error)

GetXdxrInfo 获取除权除息信息

func (*StdApi) HeartBeat added in v1.5.0

func (this *StdApi) HeartBeat() (*HeartBeatReply, error)

func (*StdApi) Hello1

func (this *StdApi) Hello1() (*Hello1Reply, error)

func (*StdApi) Hello2

func (this *StdApi) Hello2() (*Hello2Reply, error)

func (*StdApi) V2GetSecurityQuotes added in v1.3.10

func (this *StdApi) V2GetSecurityQuotes(markets []proto.Market, codes []string) (*V2SecurityQuotesReply, error)

type StdRequestHeader

type StdRequestHeader struct {
	ZipFlag    uint8  `struc:"uint8,little"`  // ZipFlag
	SeqID      uint32 `struc:"uint32,little"` // 请求编号
	PacketType uint8  `struc:"uint8,little"`  // 包类型
	PkgLen1    uint16 `struc:"uint16,little"` // 消息体长度1
	PkgLen2    uint16 `struc:"uint16,little"` // 消息体长度2
	Method     uint16 `struc:"uint16,little"` // method 请求方法
}

StdRequestHeader 标准行情-请求-消息头

type StdResponseHeader

type StdResponseHeader struct {
	I1        uint32 `struc:"uint32,little"`
	ZipFlag   uint8  `struc:"uint8,little"`  // ZipFlag
	SeqID     uint32 `struc:"uint32,little"` // 请求编号
	I3        uint8  `struc:"uint8,little"`
	Method    uint16 `struc:"uint16,little"` // method
	ZipSize   uint16 `struc:"uint16,little"` // 长度
	UnZipSize uint16 `struc:"uint16,little"` // 未压缩长度
}

StdResponseHeader 标准行情-响应-消息头

type Stock

type Stock struct {
	Market uint8
	Code   string
}

type TcpClient

type TcpClient struct {
	sync.Mutex

	Addr string // 当前连接成功的服务器地址
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opt *Opt) *TcpClient

func (*TcpClient) Close

func (client *TcpClient) Close() error

Close 断开服务器

func (*TcpClient) Command added in v1.5.6

func (client *TcpClient) Command(msg Message) error

Command 执行通达信指令

func (*TcpClient) Connect

func (client *TcpClient) Connect() error

Connect 连接服务器

type TdxMarket

type TdxMarket int

type TickTransaction

type TickTransaction struct {
	Time      string
	Price     float64
	Vol       int
	Num       int
	BuyOrSell int
}

type TradeState added in v1.6.3

type TradeState uint8
const (
	TDX_SECURITY_TRADE_STATE_DELISTING TradeState = iota // 终止上市
	TDX_SECURITY_TRADE_STATE_NORMAL                      // 正常交易
	TDX_SECURITY_TRADE_STATE_SUSPEND                     // 停牌
)
const (
	Q_A TradeState = iota
	Q_B
	Q_C
)

type TradeType added in v1.6.2

type TradeType = int32
const (
	TDX_TICK_BUY     TradeType = iota // 买入
	TDX_TICK_SELL    TradeType = 1    // 卖出
	TDX_TICK_NEUTRAL TradeType = 2    // 中性盘
)

type TransactionPackage

type TransactionPackage struct {
	// contains filtered or unexported fields
}

TransactionPackage 当日分笔成交信息

func NewTransactionPackage

func NewTransactionPackage() *TransactionPackage

func (*TransactionPackage) Reply

func (obj *TransactionPackage) Reply() interface{}

func (*TransactionPackage) Serialize

func (obj *TransactionPackage) Serialize() ([]byte, error)

func (*TransactionPackage) SetParams

func (obj *TransactionPackage) SetParams(req *TransactionRequest)

func (*TransactionPackage) UnSerialize

func (obj *TransactionPackage) UnSerialize(header interface{}, data []byte) error

type TransactionReply

type TransactionReply struct {
	Count uint16
	List  []TickTransaction
}

type TransactionRequest

type TransactionRequest struct {
	Market uint16
	Code   [6]byte
	Start  uint16
	Count  uint16
}

type V2Level added in v1.3.10

type V2Level struct {
	Price float64
	Vol   int
}

type V2SecurityQuote added in v1.3.10

type V2SecurityQuote struct {
	Market         uint8   // 市场
	Code           string  // 代码
	Active1        uint16  // 活跃度
	Price          float64 // 现价
	LastClose      float64 // 昨收
	Open           float64 // 开盘
	High           float64 // 最高
	Low            float64 // 最低
	ServerTime     string  // 时间
	ReversedBytes0 int     // 保留(时间 ServerTime)
	ReversedBytes1 int     // 保留
	Vol            int     // 总量
	CurVol         int     // 现量
	Amount         float64 // 总金额
	SVol           int     // 内盘
	BVol           int     // 外盘
	ReversedBytes2 int     // 保留
	ReversedBytes3 int     // 保留
	Bid1           float64
	Ask1           float64
	BidVol1        int
	AskVol1        int
	//Bid2           float64
	//Ask2           float64
	//BidVol2        int
	//AskVol2        int
	//Bid3           float64
	//Ask3           float64
	//BidVol3        int
	//AskVol3        int
	//Bid4           float64
	//Ask4           float64
	//BidVol4        int
	//AskVol4        int
	//Bid5           float64
	//Ask5           float64
	//BidVol5        int
	//AskVol5        int
	ReversedBytes4 uint16  // 保留
	ReversedBytes5 int     // 保留
	ReversedBytes6 int     // 保留
	ReversedBytes7 int     // 保留
	ReversedBytes8 int     // 保留
	Rate           float64 // 涨速
	Active2        uint16  // 活跃度
}

type V2SecurityQuotesPackage added in v1.3.10

type V2SecurityQuotesPackage struct {
	// contains filtered or unexported fields
}

V2SecurityQuotesPackage 盘口五档报价

func NewV2SecurityQuotesPackage added in v1.3.10

func NewV2SecurityQuotesPackage() *V2SecurityQuotesPackage

func (*V2SecurityQuotesPackage) Reply added in v1.3.10

func (obj *V2SecurityQuotesPackage) Reply() interface{}

func (*V2SecurityQuotesPackage) Serialize added in v1.3.10

func (obj *V2SecurityQuotesPackage) Serialize() ([]byte, error)

func (*V2SecurityQuotesPackage) SetParams added in v1.3.10

func (obj *V2SecurityQuotesPackage) SetParams(req *V2SecurityQuotesRequest)

func (*V2SecurityQuotesPackage) UnSerialize added in v1.3.10

func (obj *V2SecurityQuotesPackage) UnSerialize(header interface{}, data []byte) error

type V2SecurityQuotesReply added in v1.3.10

type V2SecurityQuotesReply struct {
	Count uint16
	List  []V2SecurityQuote
}

type V2SecurityQuotesRequest added in v1.3.10

type V2SecurityQuotesRequest struct {
	Count     uint16
	StockList []V2Stock
}

type V2Stock added in v1.3.10

type V2Stock struct {
	Market uint8
	Code   string
}

type XdxrInfo added in v1.2.4

type XdxrInfo struct {
	Date           string  // 日期
	Category       int     // 类型
	Name           string  // 类型名称
	FenHong        float64 // 分红
	PeiGuJia       float64 // 配股价
	SongZhuanGu    float64 // 送转股
	PeiGu          float64 // 配股
	SuoGu          float64 // 缩股
	PanQianLiuTong float64 // 盘前流通
	PanHouLiuTong  float64 // 盘后流通
	QianZongGuBen  float64 // 前总股本
	HouZongGuBen   float64 // 后总股本
	FenShu         float64 // 份数
	XingGuanJia    float64 // 行权价
}

type XdxrInfoPackage added in v1.2.4

type XdxrInfoPackage struct {
	// contains filtered or unexported fields
}

XdxrInfoPackage 除权除息

func NewXdxrInfoPackage added in v1.2.4

func NewXdxrInfoPackage() *XdxrInfoPackage

func (*XdxrInfoPackage) Reply added in v1.2.4

func (obj *XdxrInfoPackage) Reply() interface{}

func (*XdxrInfoPackage) Serialize added in v1.2.4

func (obj *XdxrInfoPackage) Serialize() ([]byte, error)

func (*XdxrInfoPackage) SetParams added in v1.2.4

func (obj *XdxrInfoPackage) SetParams(req *XdxrInfoRequest)

func (*XdxrInfoPackage) UnSerialize added in v1.2.4

func (obj *XdxrInfoPackage) UnSerialize(header interface{}, data []byte) error

type XdxrInfoReply added in v1.2.4

type XdxrInfoReply struct {
	Unknown []byte        `struc:"[9]byte,little"`            // 未知
	Count   uint16        `struc:"uint16,little,sizeof=List"` //  总数
	List    []RawXdxrInfo `struc:"[29]byte, little"`          // [29]byte和title中间必须要有一个空格
}

XdxrInfoReply 响应包结构

type XdxrInfoRequest added in v1.2.4

type XdxrInfoRequest struct {
	//Count  uint16  // 总数
	Market uint8   // 市场代码
	Code   [6]byte // 股票代码
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL