std

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMarshal

func DefaultMarshal(v interface{}) ([]byte, error)

DefaultMarshal 基于struc包的序列化方案

func DefaultUnmarshal

func DefaultUnmarshal(data []byte, v interface{}) error

DefaultUnmarshal 基于struc包的反序列化方案

func NewFinanceInfo

func NewFinanceInfo(market proto.Market, code string) (*FinanceInfoRequest, *FinanceInfoResponse, error)

func NewGetSecurityList

func NewGetSecurityList(market proto.Market, start int) (*GetSecurityListRequest, *GetSecurityListResponse, error)

func NewSetupCmd1

func NewSetupCmd1() (*SetupCmd1Request, *SetupCmd1Response, error)

func NewSetupCmd2

func NewSetupCmd2() (*SetupCmd2Request, *SetupCmd2Response, error)

func NewSetupCmd3

func NewSetupCmd3() (*SetupCmd3Request, *SetupCmd3Response, error)

Types

type Factory

type Factory func() (Marshaler, Unmarshaler, error)

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 FinanceInfoRequest

type FinanceInfoRequest struct {
	// struc不允许slice解析,只允许包含长度的array,该长度可根据hex字符串计算
	Unknown1 []byte `struc:"[14]byte"`
	// pytdx中使用struct.Pack进行反序列化
	// 其中<H等价于这里的struc:"uint16,little"
	// <I等价于struc:"uint32,little"
	Market proto.Market `struc:"uint8,little" json:"market"`
	Code   string       `struc:"[6]byte,little" json:"code"`
}

请求包结构

func NewFinanceInfoRequest

func NewFinanceInfoRequest(market proto.Market, code string) (*FinanceInfoRequest, error)

todo: 检测market是否为合法值

func (*FinanceInfoRequest) Marshal

func (req *FinanceInfoRequest) Marshal() ([]byte, error)

请求包序列化输出

type FinanceInfoResponse

type FinanceInfoResponse struct {
	FinanceInfo
}

响应包结构

func (*FinanceInfoResponse) Unmarshal

func (resp *FinanceInfoResponse) Unmarshal(data []byte) error

内部套用原始结构解析,外部为经过解析之后的响应信息

type FinanceInfoResponseRaw

type FinanceInfoResponseRaw struct {
	Unknown1 []byte `struc:"[2]byte,little" json:"unknown1"`
	Market   int    `struc:"uint8,little" json:"market"`
	Code     string `struc:"[6]byte,little" json:"code"`
	//Info     FinanceInfo `struc:"[136]byte,little" json:"info"`
	LiuTongGuBen       float32 `struc:"float32,little" json:"liuTongGuBen"`
	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          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"`
}

响应包结构

func (*FinanceInfoResponseRaw) Unmarshal

func (resp *FinanceInfoResponseRaw) Unmarshal(data []byte) error

type GetSecurityListRequest

type GetSecurityListRequest struct {
	// struc不允许slice解析,只允许包含长度的array,该长度可根据hex字符串计算
	Unknown1 []byte `struc:"[12]byte"`
	// pytdx中使用struct.Pack进行反序列化
	// 其中<H等价于这里的struc:"uint16,little"
	// <I等价于struc:"uint32,little"
	Market proto.Market `struc:"uint16,little" json:"market"`
	Start  int          `struc:"uint16,little" json:"start"`
}

请求包结构

func NewGetSecurityListRequest

func NewGetSecurityListRequest(market proto.Market, start int) (*GetSecurityListRequest, error)

todo: 检测market是否为合法值

func (*GetSecurityListRequest) Marshal

func (req *GetSecurityListRequest) Marshal() ([]byte, error)

请求包序列化输出

type GetSecurityListResponse

type GetSecurityListResponse struct {
	Count  int     `struc:"uint16,little,sizeof=Stocks" json:"count"`
	Stocks []Stock `struc:"[29]byte, little" json:"stocks"`
}

GetSecurityListResponse 响应包结构

func (*GetSecurityListResponse) Unmarshal

func (resp *GetSecurityListResponse) Unmarshal(data []byte) error

Unmarshal 内部套用原始结构解析,外部为经过解析之后的响应信息

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
}

type PacketHeader

type PacketHeader struct {
	Unknown1 uint `struc:"uint32,little" json:"unknown_1"`

	// B will be encoded/decoded as a 16-bit int (a "short")
	// but is stored as a native int in the struct
	Unknown2 uint `struc:"uint32,little" json:"unknown_2"`

	// the sizeof key links a buffer's size to any int field
	Unknown3 uint `struc:"uint32,little" json:"unknown_3"`
	ZipSize  int  `struc:"uint16,little" json:"zip_size"`

	// you can get freaky if you want
	UnzipSize int `struc:"uint16,little" json:"unzip_size"`
	// contains filtered or unexported fields
}

PacketHeader 行情服务器发送第一条指令的返回数据

func (*PacketHeader) Bytes

func (h *PacketHeader) Bytes() []byte

func (*PacketHeader) Compressed

func (h *PacketHeader) Compressed() bool

func (*PacketHeader) Size

func (h *PacketHeader) Size() int

func (*PacketHeader) Unmarshal

func (h *PacketHeader) Unmarshal(data []byte) error

type SecurityCountRequest

type SecurityCountRequest struct {
	Unknown1 []byte       `struc:"[12]byte"`
	Market   proto.Market `struc:"uint16,little" json:"market"`
	Unknown2 []byte       `struc:"[4]byte"`
}

SecurityCountRequest 请求包结构

func NewSecurityCountRequest

func NewSecurityCountRequest(market proto.Market) (*SecurityCountRequest, error)

todo: 检测market是否为合法值

func (*SecurityCountRequest) Marshal

func (req *SecurityCountRequest) Marshal() ([]byte, error)

Marshal 请求包序列化输出

type SecurityCountResponse

type SecurityCountResponse struct {
	Count uint `struc:"uint16,little" json:"count"`
}

SecurityCountResponse 响应包结构

func (*SecurityCountResponse) Unmarshal

func (resp *SecurityCountResponse) Unmarshal(data []byte) error

type SetupCmd1Request

type SetupCmd1Request struct {
	Cmd []byte `struc:"[13]byte" json:"cmd"`
}

SetupCmd1Request 请求包结构

func NewSetupCmd1Request

func NewSetupCmd1Request() (*SetupCmd1Request, error)

创建SetupCmd1请求包

func (*SetupCmd1Request) Marshal

func (req *SetupCmd1Request) Marshal() ([]byte, error)

Marshal 请求包序列化输出

type SetupCmd1Response

type SetupCmd1Response struct {
	Unknown []byte `json:"unknown"`
	Reply   string `json:"reply"`
}

SetupCmd1Response 响应包结构 serverInfo := Utf8ToGbk(data[68:])

func (*SetupCmd1Response) Unmarshal

func (resp *SetupCmd1Response) Unmarshal(data []byte) error

type SetupCmd2Request

type SetupCmd2Request struct {
	Cmd []byte `struc:"[13]byte" json:"cmd"`
}

SetupCmd2Request 请求包结构

func NewSetupCmd2Request

func NewSetupCmd2Request() (*SetupCmd2Request, error)

NewSetupCmd2Request 创建SetupCmd2请求包

func (*SetupCmd2Request) Marshal

func (req *SetupCmd2Request) Marshal() ([]byte, error)

Marshal 请求包序列化输出

type SetupCmd2Response

type SetupCmd2Response struct {
	Unknown []byte `json:"unknown"`
}

SetupCmd2Response 响应包结构

func (*SetupCmd2Response) Unmarshal

func (resp *SetupCmd2Response) Unmarshal(data []byte) error

type SetupCmd3Request

type SetupCmd3Request struct {
	Cmd []byte `struc:"[42]byte" json:"cmd"`
}

SetupCmd3Request 请求包结构

func NewSetupCmd3Request

func NewSetupCmd3Request() (*SetupCmd3Request, error)

NewSetupCmd3Request 创建SetupCmd3请求包

func (*SetupCmd3Request) Marshal

func (req *SetupCmd3Request) Marshal() ([]byte, error)

Marshal 请求包序列化输出

type SetupCmd3Response

type SetupCmd3Response struct {
	Unknown []byte `json:"unknown"`
}

SetupCmd3Response 响应包结构

func (*SetupCmd3Response) Unmarshal

func (resp *SetupCmd3Response) Unmarshal(data []byte) error

type Stock

type Stock struct {
	Code         string  `json:"code"`
	VolUnit      int     `json:"vol_unit"`
	DecimalPoint int     `json:"decimal_point"`
	Name         string  `json:"name"`
	PreClose     float64 `json:"pre_close"`
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte) error
}

Jump to

Keyboard shortcuts

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