Documentation
¶
Index ¶
- Constants
- Variables
- func IntegerDay(t time.Time) time.Time
- func NewExRangeDial(hosts []string) ios.DialFunc
- func NewHostDial(hosts []string) ios.DialFunc
- func NewRandomDial(hosts []string) ios.DialFunc
- func NewRangeDial(hosts []string) ios.DialFunc
- func NewTCPDial(addr string) ios.DialFunc
- func NewTimer(spec string, retry int, up Updater) error
- func SortExHosts(timeout ...time.Duration) []string
- func SortHosts(timeout ...time.Duration) []string
- func WithDebug(b ...bool) client.Option
- func WithLevel(level int) client.Option
- func WithRedial(b ...bool) client.Option
- type Client
- func Dial(addr string, op ...client.Option) (cli *Client, err error)
- func DialDefault(op ...client.Option) (cli *Client, err error)
- func DialExHq(addr string, op ...client.Option) (*Client, error)
- func DialExHqDefault(op ...client.Option) (*Client, error)
- func DialExHqHosts(hosts []string, op ...client.Option) (*Client, error)
- func DialHosts(hosts []string, op ...client.Option) (cli *Client, err error)
- func DialHostsRandom(hosts []string, op ...client.Option) (cli *Client, err error)
- func DialHostsRange(hosts []string, op ...client.Option) (cli *Client, err error)
- func DialWith(dial ios.DialFunc, op ...client.Option) (cli *Client, err error)
- func (this *Client) ExBars(category, market uint8, code string, start, count uint16) ([]protocol.ExKline, error)
- func (this *Client) ExBarsRange(market uint8, code string, date, date2 uint32) ([]protocol.ExRangeKline, error)
- func (this *Client) ExCount() (int, error)
- func (this *Client) ExHistMinute(market uint8, code string, date uint32) ([]protocol.ExMinuteTick, error)
- func (this *Client) ExHistTrade(market uint8, code string, date uint32, start, count uint16) ([]protocol.ExTradeTick, error)
- func (this *Client) ExInstruments(start uint32, count uint16) ([]protocol.ExInstrument, error)
- func (this *Client) ExMarkets() ([]protocol.ExMarket, error)
- func (this *Client) ExMinute(market uint8, code string) ([]protocol.ExMinuteTick, error)
- func (this *Client) ExQuote(market uint8, code string) (*protocol.ExQuote, error)
- func (this *Client) ExQuoteList(market, category uint8, start, count uint16) ([]protocol.ExQuoteListItem, error)
- func (this *Client) ExTrade(market uint8, code string, start, count uint16) ([]protocol.ExTradeTick, error)
- func (this *Client) GetBlockData(file string) ([]*protocol.Block, error)
- func (this *Client) GetBlockDataWithIndex(file string) ([]*protocol.Block, error)
- func (this *Client) GetBlockFileRaw(file string) ([]byte, error)
- func (this *Client) GetCallAuction(code string) (*protocol.CallAuctionResp, error)
- func (this *Client) GetCode(exchange protocol.Exchange, start uint16) (*protocol.CodeResp, error)
- func (this *Client) GetCodeAll(exchange protocol.Exchange) (*protocol.CodeResp, error)
- func (this *Client) GetCompanyCategory(exchange protocol.Exchange, code string) ([]protocol.CompanyCategory, error)
- func (this *Client) GetCompanyContent(exchange protocol.Exchange, code, filename string, start, length uint32) (string, error)
- func (this *Client) GetCount(exchange protocol.Exchange) (*protocol.CountResp, error)
- func (this *Client) GetETFCodeAll() ([]string, error)
- func (this *Client) GetFinanceInfo(exchange protocol.Exchange, code string) (*protocol.FinanceInfo, error)
- func (this *Client) GetGbbq(code string) (*protocol.GbbqResp, error)
- func (this *Client) GetGbbqAll() (map[string][]*protocol.Gbbq, error)
- func (this *Client) GetHistoryMinute(date, code string) (*protocol.MinuteResp, error)
- func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16) (*protocol.TradeResp, error)
- func (this *Client) GetHistoryMinuteTradeDay(date, code string) (*protocol.TradeResp, error)
- func (this *Client) GetHistoryTrade(date, code string, start, count uint16) (*protocol.TradeResp, error)
- func (this *Client) GetHistoryTradeBefore(code string, w *Workday, before time.Time) (protocol.Trades, error)
- func (this *Client) GetHistoryTradeDay(date, code string) (*protocol.TradeResp, error)
- func (this *Client) GetHistoryTradeFull(code string, w *Workday) (protocol.Trades, error)
- func (this *Client) GetIndex(Type uint8, code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndex5Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndex15Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndex30Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndex60Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndexAll(Type uint8, code string) (*protocol.KlineResp, error)
- func (this *Client) GetIndexCodeAll() ([]string, error)
- func (this *Client) GetIndexDay(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndexDayAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetIndexDayUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetIndexMinute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetIndexMonthAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetIndexQuarterAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetIndexUntil(Type uint8, code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetIndexWeekAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetIndexYearAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKline(Type uint8, code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKline5Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKline5MinuteAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKline5MinuteUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKline15Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKline15MinuteAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKline15MinuteUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKline30Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKline30MinuteAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKline30MinuteUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKline60Minute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKline60MinuteAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKline60MinuteUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineAll(Type uint8, code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineDay(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineDayAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineDayUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineHour(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineHourAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineHourUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMinute(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMinute241Until(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMinuteAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMinuteUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMonth(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMonthAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineMonthUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineQuarter(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineQuarterAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineQuarterUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineUntil(Type uint8, code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineWeek(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineWeekAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineWeekUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetKlineYear(code string, start, count uint16) (*protocol.KlineResp, error)
- func (this *Client) GetKlineYearAll(code string) (*protocol.KlineResp, error)
- func (this *Client) GetKlineYearUntil(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
- func (this *Client) GetMinute(code string) (*protocol.MinuteResp, error)
- func (this *Client) GetMinuteTrade(code string, start, count uint16) (*protocol.TradeResp, error)
- func (this *Client) GetMinuteTradeAll(code string) (*protocol.TradeResp, error)
- func (this *Client) GetQuote(codes ...string) (protocol.QuotesResp, error)
- func (this *Client) GetReportFile(file string) ([]byte, error)
- func (this *Client) GetSpBlock() ([]*protocol.SpBlock, error)
- func (this *Client) GetStockCodeAll() ([]string, error)
- func (this *Client) GetTdxBk() ([]*protocol.TdxBk, error)
- func (this *Client) GetTdxHy() ([]*protocol.TdxHy, error)
- func (this *Client) GetTdxStat() ([]*protocol.TdxStat, error)
- func (this *Client) GetTdxStat2() ([]*protocol.TdxStat2, error)
- func (this *Client) GetTdxZs() ([]*protocol.TdxZs, error)
- func (this *Client) GetTrade(code string, start, count uint16) (*protocol.TradeResp, error)
- func (this *Client) GetTradeAll(code string) (*protocol.TradeResp, error)
- func (this *Client) GetXgsg() ([]*protocol.TdxXgsg, error)
- func (this *Client) GetZHBFiles() (map[string][]byte, error)
- func (this *Client) SendFrame(f *protocol.Frame, cache ...any) (any, error)
- func (this *Client) SetTimeout(t time.Duration)
- type CodeModel
- type CodeModels
- type Codes
- type CodesBase
- func (this *CodesBase) Get(code string) *CodeModel
- func (this *CodesBase) GetETFCodes(limits ...int) []string
- func (this *CodesBase) GetETFs(limits ...int) CodeModels
- func (this *CodesBase) GetIndexCodes(limits ...int) []string
- func (this *CodesBase) GetIndexes(limits ...int) CodeModels
- func (this *CodesBase) GetName(code string) string
- func (this *CodesBase) GetStockCodes(limits ...int) []string
- func (this *CodesBase) GetStocks(limits ...int) CodeModels
- func (this *CodesBase) Iter() iter.Seq2[string, *CodeModel]
- func (this *CodesBase) Update(ls []*CodeModel)
- type CodesOption
- func WithCodesClient(c *Client) CodesOption
- func WithCodesDB(db *xorms.Engine) CodesOption
- func WithCodesDialClient(dial DialClientFunc) CodesOption
- func WithCodesDialDB(dial DialDBFunc) CodesOption
- func WithCodesOption(op ...CodesOption) CodesOption
- func WithCodesRetry(retry int) CodesOption
- func WithCodesSpec(spec string) CodesOption
- type DialClientFunc
- type DialCodesFunc
- type DialDBFunc
- type DialGbbqFunc
- type DialPoolFunc
- type DialWorkdayFunc
- type Gbbq
- func (this *Gbbq) All() map[string][]*protocol.Gbbq
- func (this *Gbbq) GetEquity(code string, t time.Time) *protocol.Equity
- func (this *Gbbq) GetFactors(code string, ks protocol.Klines) []*protocol.Factor
- func (this *Gbbq) GetTurnover(code string, t time.Time, volume int64) float64
- func (this *Gbbq) GetXRXDMap(code string) map[string]*protocol.XRXD
- func (this *Gbbq) GetXRXDs(code string) protocol.XRXDs
- func (this *Gbbq) HFQ(code string, ks protocol.Klines) protocol.Klines
- func (this *Gbbq) HFQKlineDay(code string) (protocol.Klines, error)
- func (this *Gbbq) QFQ(code string, ks protocol.Klines) protocol.Klines
- func (this *Gbbq) QFQKlineDay(code string) (protocol.Klines, error)
- func (this *Gbbq) Update() error
- type GbbqOption
- func WithGbbqClient(c *Client) GbbqOption
- func WithGbbqDB(db *xorms.Engine) GbbqOption
- func WithGbbqDialClient(dial DialClientFunc) GbbqOption
- func WithGbbqDialDB(dial func() (*xorms.Engine, error)) GbbqOption
- func WithGbbqOption(op ...GbbqOption) GbbqOption
- func WithGbbqRetry(retry int) GbbqOption
- func WithGbbqSpec(spec string) GbbqOption
- type ICodes
- type IGbbq
- type IPool
- type Manage
- type Option
- func WithClients(clients int) Option
- func WithCodes(codes ICodes) Option
- func WithDialCodes(dial DialCodesFunc) Option
- func WithDialGbbq(dial DialGbbqFunc) Option
- func WithDialGbbqDefault() Option
- func WithDialPool(dial DialPoolFunc) Option
- func WithDialWorkday(dial DialWorkdayFunc) Option
- func WithGbbq(gbbq IGbbq) Option
- func WithOption(op ...Option) Option
- func WithPool(pool IPool) Option
- func WithWorkday(w *Workday) Option
- type Pool
- type UpdateModel
- type Updated
- type Updater
- type Workday
- func (this *Workday) Is(t time.Time) bool
- func (this *Workday) Iter(start, end time.Time, desc ...bool) iter.Seq[time.Time]
- func (this *Workday) IterYear(year int, desc ...bool) iter.Seq[time.Time]
- func (this *Workday) Range(start, end time.Time, f func(t time.Time) bool)
- func (this *Workday) RangeYear(year int, f func(t time.Time) bool)
- func (this *Workday) TodayIs() bool
- func (this *Workday) Update() error
- type WorkdayModel
- type WorkdayOption
- func WithWorkdayClient(c *Client) WorkdayOption
- func WithWorkdayDB(db *xorms.Engine) WorkdayOption
- func WithWorkdayDialClient(dial DialClientFunc) WorkdayOption
- func WithWorkdayDialDB(dial DialDBFunc) WorkdayOption
- func WithWorkdayOption(op ...WorkdayOption) WorkdayOption
- func WithWorkdayRetry(retry int) WorkdayOption
- func WithWorkdaySpec(spec string) WorkdayOption
Constants ¶
const ( LevelNone = common.LevelNone LevelDebug = common.LevelDebug LevelWrite = common.LevelWrite LevelRead = common.LevelRead LevelInfo = common.LevelInfo LevelError = common.LevelError LevelAll = common.LevelAll )
const ( DefaultClients = 1 DefaultRetry = 3 DefaultDataDir = "./data" DefaultDatabaseDir = "./data/database" DefaultCodesSpec = "0 1 9 * * *" DefaultWorkdaySpec = "0 3 9 * * *" DefaultGbbqSpec = "0 5 9 * * *" )
const ExPort = "7727"
扩展行情(TdxExHq)服务器,端口 7727,地址取自通达信 connect.cfg [DSHOST] 段。 编写方式参考主行情 hosts.go:按地域拆分子表,IP 不含端口(连接时补 :7727)。
Variables ¶
var ( // Hosts 所有服务器地址(2024-11-30测试通过) Hosts = func() []string { lenSH := len(SHHosts) lenBJ := len(BJHosts) lenGZ := len(GZHosts) lenWH := len(WHHosts) ls := make([]string, lenSH+lenBJ+lenGZ+lenWH) copy(ls[:lenSH], SHHosts) copy(ls[lenSH:lenSH+lenBJ], BJHosts) copy(ls[lenSH+lenBJ:lenSH+lenBJ+lenGZ], GZHosts) copy(ls[lenSH+lenBJ+lenGZ:lenSH+lenBJ+lenGZ+lenWH], WHHosts) return ls }() // SHHosts 上海服务器地址 SHHosts = []string{ "124.71.187.122", "122.51.120.217", "111.229.247.189", "122.51.232.182", "118.25.98.114", "124.70.199.56", "121.36.225.169", "123.60.70.228", "123.60.73.44", "124.70.133.119", "124.71.187.72", "123.60.84.66", "124.223.163.242", "150.158.160.2", "101.35.121.35", "111.231.113.208", } // BJHosts 北京服务器地址 BJHosts = []string{ "62.234.50.143", "81.70.151.186", "101.42.240.54", "101.43.159.194", "120.53.8.251", "152.136.191.169", "49.232.15.141", "82.156.174.84", "101.42.164.241", } // GZHosts 广州服务器地址,客户端上可能显示深圳 GZHosts = []string{ "124.71.9.153", "116.205.163.254", "116.205.171.132", "116.205.183.150", "111.230.186.52", "110.41.2.72", "110.41.147.114", "101.33.225.16", "175.178.112.197", "175.178.128.227", "43.139.95.83", "159.75.29.111", "43.139.18.171", "81.71.32.47", "129.204.230.128", } // WHHosts 武汉服务器地址 WHHosts = []string{ "119.97.185.59", } )
var ( // ExHosts 扩展行情所有服务器地址(connect.cfg [DSHOST]) // 广州段在前:2026-06 实测仅 116.205.143.214(广州双线1)完全可用,置首位使 // range-dial 默认优先命中;其余多为连接超时/受限节点,可用 SortExHosts 重排。 ExHosts = func() []string { lenGZ := len(ExGZHosts) lenSH := len(ExSHHosts) lenBJ := len(ExBJHosts) ls := make([]string, lenGZ+lenSH+lenBJ) copy(ls[:lenGZ], ExGZHosts) copy(ls[lenGZ:lenGZ+lenSH], ExSHHosts) copy(ls[lenGZ+lenSH:lenGZ+lenSH+lenBJ], ExBJHosts) return ls }() // ExSHHosts 扩展行情上海服务器地址 ExSHHosts = []string{ "175.24.47.69", "150.158.9.199", "150.158.20.127", "49.235.119.116", "49.234.13.160", "123.60.173.210", "118.89.69.202", } // ExBJHosts 扩展行情北京服务器地址 ExBJHosts = []string{ "112.74.214.43", "120.25.218.6", "43.139.173.246", "159.75.90.107", "106.52.170.195", "139.9.191.175", } // ExGZHosts 扩展行情广州服务器地址 ExGZHosts = []string{ "116.205.143.214", "124.71.223.19", "113.45.175.47", } )
Functions ¶
func NewExRangeDial ¶ added in v0.0.79
NewExRangeDial 遍历扩展行情(TdxExHq)服务地址进行连接,成功则结束遍历(端口 7727)
func NewHostDial ¶
func NewRandomDial ¶
func NewRangeDial ¶
func NewTCPDial ¶
func SortExHosts ¶ added in v0.0.79
SortExHosts 通过tcp连接速度筛选排序可用的扩展行情地址(同 SortHosts,端口 7727)
Types ¶
type Client ¶
type Client struct {
*client.Client //客户端实例
Wait *wait.Entity //异步回调,设置超时时间,超时则返回错误
// contains filtered or unexported fields
}
func DialDefault ¶
DialDefault 默认连接方式
func DialExHqDefault ¶ added in v0.0.79
DialExHqDefault 连接默认扩展行情服务器(轮询 ExHosts)。
func DialExHqHosts ¶ added in v0.0.79
DialExHqHosts 连接扩展行情服务器,多服务器轮询。
func DialHostsRandom ¶
DialHostsRandom 与服务器建立连接,多个服务器随机连接
func DialHostsRange ¶
DialHostsRange 遍历设置的服务地址进行连接,成功则结束遍历
func (*Client) ExBars ¶ added in v0.0.79
func (this *Client) ExBars(category, market uint8, code string, start, count uint16) ([]protocol.ExKline, error)
ExBars K线(category 同标准 KLINE 类型)。
func (*Client) ExBarsRange ¶ added in v0.0.79
func (this *Client) ExBarsRange(market uint8, code string, date, date2 uint32) ([]protocol.ExRangeKline, error)
ExBarsRange 历史K线区间(date/date2=YYYYMMDD)。
func (*Client) ExHistMinute ¶ added in v0.0.79
func (this *Client) ExHistMinute(market uint8, code string, date uint32) ([]protocol.ExMinuteTick, error)
ExHistMinute 历史分时(date=YYYYMMDD)。
func (*Client) ExHistTrade ¶ added in v0.0.79
func (this *Client) ExHistTrade(market uint8, code string, date uint32, start, count uint16) ([]protocol.ExTradeTick, error)
ExHistTrade 历史分笔成交(date=YYYYMMDD)。
func (*Client) ExInstruments ¶ added in v0.0.79
ExInstruments 品种(代码)列表,分页。
func (*Client) ExQuoteList ¶ added in v0.0.79
func (this *Client) ExQuoteList(market, category uint8, start, count uint16) ([]protocol.ExQuoteListItem, error)
ExQuoteList 批量行情列表(category 2=港股 3=期货)。
func (*Client) ExTrade ¶ added in v0.0.79
func (this *Client) ExTrade(market uint8, code string, start, count uint16) ([]protocol.ExTradeTick, error)
ExTrade 当日分笔成交。
func (*Client) GetBlockData ¶ added in v0.0.79
GetBlockData 下载并解析通达信板块文件(如 protocol.BlockFileGN 概念)→ 板块列表。
func (*Client) GetBlockDataWithIndex ¶ added in v0.0.79
GetBlockDataWithIndex 下载板块文件(block_*.dat)并按名称回填板块指数代码(id)。 block 文件本身无 id,关联链: 板块名 →(tdxzs.cfg)→ id;直接未命中再经 简称 →(tdxbk.cfg)→ 全称 →(tdxzs.cfg)→ id 二次匹配。三个文件均来自 zhb.zip(仅下载一次)。
func (*Client) GetBlockFileRaw ¶ added in v0.0.79
GetBlockFileRaw 下载通达信服务器文件(板块/配置)原始字节,分块拉取后拼接。 适用于二进制板块文件(block*.dat)与文本配置(tdxhy.cfg 等)。
func (*Client) GetCallAuction ¶ added in v0.0.56
func (this *Client) GetCallAuction(code string) (*protocol.CallAuctionResp, error)
func (*Client) GetCode ¶
GetCode 获取市场内指定范围内的所有证券代码,一次固定返回1000只,上证股票有效范围370-1480 上证前370只是395/399开头的(中证500/总交易等辅助类),在后面的话是一些100开头的国债 600开头的股票是上证A股,属于大盘股,其中6006开头的股票是最早上市的股票, 6016开头的股票为大盘蓝筹股;900开头的股票是上证B股; 000开头的股票是深证A股,001、002开头的股票也都属于深证A股, 其中002开头的股票是深证A股中小企业股票;200开头的股票是深证B股; 300开头的股票是创业板股票;400开头的股票是三板市场股票。
func (*Client) GetCodeAll ¶
GetCodeAll 通过多次请求的方式获取全部证券代码
func (*Client) GetCompanyCategory ¶ added in v0.0.79
func (this *Client) GetCompanyCategory(exchange protocol.Exchange, code string) ([]protocol.CompanyCategory, error)
GetCompanyCategory 获取 F10 公司信息分类目录。
func (*Client) GetCompanyContent ¶ added in v0.0.79
func (this *Client) GetCompanyContent(exchange protocol.Exchange, code, filename string, start, length uint32) (string, error)
GetCompanyContent 获取 F10 某分类的文本内容。
func (*Client) GetETFCodeAll ¶ added in v0.0.57
GetETFCodeAll 获取所有ETF代码,带前缀例sz159399
func (*Client) GetFinanceInfo ¶ added in v0.0.79
func (this *Client) GetFinanceInfo(exchange protocol.Exchange, code string) (*protocol.FinanceInfo, error)
GetFinanceInfo 获取标的财务/基本面信息(流通股本/总股本/行业/地域/股东户数/财务)。
func (*Client) GetGbbqAll ¶ added in v0.0.61
func (*Client) GetHistoryMinute ¶
func (this *Client) GetHistoryMinute(date, code string) (*protocol.MinuteResp, error)
GetHistoryMinute 获取历史分时数据
func (*Client) GetHistoryMinuteTrade ¶
func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16) (*protocol.TradeResp, error)
GetHistoryMinuteTrade 获取历史分时交易 只能获取昨天及之前的数据,服务器最多返回2000条,count-start<=2000,如果日期输入错误,则返回0 历史数据只能查到20000609
func (*Client) GetHistoryMinuteTradeDay ¶
GetHistoryMinuteTradeDay 获取历史某天分时全部交易,通过多次请求来拼接,只能获取昨天及之前的数据 历史数据只能查到20000609
func (*Client) GetHistoryTrade ¶
func (*Client) GetHistoryTradeBefore ¶
func (this *Client) GetHistoryTradeBefore(code string, w *Workday, before time.Time) (protocol.Trades, error)
GetHistoryTradeBefore 获取上市至今的分时成交
func (*Client) GetHistoryTradeDay ¶
GetHistoryTradeDay 获取历史某天分时全部交易,通过多次请求来拼接,只能获取昨天及之前的数据
func (*Client) GetHistoryTradeFull ¶
GetHistoryTradeFull 获取上市至今的分时成交
func (*Client) GetIndex ¶
func (this *Client) GetIndex(Type uint8, code string, start, count uint16) (*protocol.KlineResp, error)
GetIndex 获取指数,接口是和k线一样的,但是解析不知道怎么区分(解析方式不一致),所以加一个方法
func (*Client) GetIndex5Minute ¶
func (*Client) GetIndex15Minute ¶
func (*Client) GetIndex30Minute ¶
func (*Client) GetIndex60Minute ¶
func (*Client) GetIndexAll ¶
GetIndexAll 获取全部k线数据
func (*Client) GetIndexCodeAll ¶ added in v0.0.57
GetIndexCodeAll 获取所有指数代码,带前缀例sz399001
func (*Client) GetIndexDay ¶
func (*Client) GetIndexDayAll ¶
func (*Client) GetIndexDayUntil ¶
func (*Client) GetIndexMinute ¶
func (*Client) GetIndexMonthAll ¶
func (*Client) GetIndexQuarterAll ¶
func (*Client) GetIndexUntil ¶
func (this *Client) GetIndexUntil(Type uint8, code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
GetIndexUntil 获取指数k线数据,通过多次请求来拼接,直到满足func返回true
func (*Client) GetIndexWeekAll ¶
func (*Client) GetIndexYearAll ¶
func (*Client) GetKline ¶
func (this *Client) GetKline(Type uint8, code string, start, count uint16) (*protocol.KlineResp, error)
GetKline 获取k线数据,推荐收盘之后获取,否则会获取到当天的数据
func (*Client) GetKline5Minute ¶
GetKline5Minute 获取五分钟k线数据
func (*Client) GetKline5MinuteAll ¶
GetKline5MinuteAll 获取5分钟k线全部数据
func (*Client) GetKline5MinuteUntil ¶
func (*Client) GetKline15Minute ¶
GetKline15Minute 获取十五分钟k线数据
func (*Client) GetKline15MinuteAll ¶
GetKline15MinuteAll 获取十五分钟k线全部数据
func (*Client) GetKline15MinuteUntil ¶
func (*Client) GetKline30Minute ¶
GetKline30Minute 获取三十分钟k线数据
func (*Client) GetKline30MinuteAll ¶
GetKline30MinuteAll 获取三十分钟k线全部数据
func (*Client) GetKline30MinuteUntil ¶
func (*Client) GetKline60Minute ¶
GetKline60Minute 获取60分钟k线数据
func (*Client) GetKline60MinuteAll ¶
GetKline60MinuteAll 获取60分钟k线全部数据
func (*Client) GetKline60MinuteUntil ¶
func (*Client) GetKlineAll ¶
GetKlineAll 获取全部k线数据
func (*Client) GetKlineDay ¶
GetKlineDay 获取日k线数据
func (*Client) GetKlineDayAll ¶
GetKlineDayAll 获取日k线全部数据
func (*Client) GetKlineDayUntil ¶
func (*Client) GetKlineHour ¶
GetKlineHour 获取小时k线数据
func (*Client) GetKlineHourAll ¶
GetKlineHourAll 获取小时k线全部数据
func (*Client) GetKlineHourUntil ¶
func (*Client) GetKlineMinute ¶
GetKlineMinute 获取一分钟k线数据,每次最多800条,最多只能获取24000条数据
func (*Client) GetKlineMinute241Until ¶ added in v0.0.66
func (*Client) GetKlineMinuteAll ¶
GetKlineMinuteAll 获取一分钟k线全部数据,最多只能获取24000条数据
func (*Client) GetKlineMinuteUntil ¶
func (*Client) GetKlineMonth ¶
GetKlineMonth 获取月k线数据
func (*Client) GetKlineMonthAll ¶
GetKlineMonthAll 获取月k线全部数据
func (*Client) GetKlineMonthUntil ¶
func (*Client) GetKlineQuarter ¶
GetKlineQuarter 获取季k线数据
func (*Client) GetKlineQuarterAll ¶
GetKlineQuarterAll 获取季k线全部数据
func (*Client) GetKlineQuarterUntil ¶
func (*Client) GetKlineUntil ¶
func (this *Client) GetKlineUntil(Type uint8, code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)
GetKlineUntil 获取k线数据,通过多次请求来拼接,直到满足func返回true
func (*Client) GetKlineWeek ¶
GetKlineWeek 获取周k线数据
func (*Client) GetKlineWeekAll ¶
GetKlineWeekAll 获取周k线全部数据
func (*Client) GetKlineWeekUntil ¶
func (*Client) GetKlineYear ¶
GetKlineYear 获取年k线数据
func (*Client) GetKlineYearAll ¶
GetKlineYearAll 获取年k线数据
func (*Client) GetKlineYearUntil ¶
func (*Client) GetMinute ¶
func (this *Client) GetMinute(code string) (*protocol.MinuteResp, error)
GetMinute 获取分时数据,todo 解析好像不对,先用历史数据
func (*Client) GetMinuteTrade ¶
GetMinuteTrade 获取分时交易详情,服务器最多返回1800条,count-start<=1800
func (*Client) GetMinuteTradeAll ¶
GetMinuteTradeAll 获取分时全部交易详情,只能盘后调用,因为交易实时在进行,然后又是分页读取的,所以会出现读取间隔内产生的交易会丢失
func (*Client) GetQuote ¶
func (this *Client) GetQuote(codes ...string) (protocol.QuotesResp, error)
GetQuote 获取盘口五档报价
func (*Client) GetReportFile ¶ added in v0.0.79
GetReportFile 下载通达信服务器任意报表/数据文件(report file,指令 0x06B9)原始字节。 与 GetBlockFileRaw 共用同一传输帧,区别在于报表文件无 0x02C5 元信息预查文件大小, 故按 0x7530 块大小循环递增 offset 拉取,直到返回块短于请求块(末块)或为空时终止。 对齐 pytdx GetReportFile / mitdx get_report_file。
func (*Client) GetSpBlock ¶ added in v0.0.83
GetSpBlock 下载并解析 spblock.dat(来自 zhb.zip) → 专业板块成分列表。
spblock.dat 承载 block_zs.dat 无法容纳的大型指数成分, 如 中证2000/中证1000/中证500/中证A500/国证2000/深证成指 等(block_*.dat 单板块成分上限 400)。 用 protocol.SpBlockByName 按名取单个板块。注意: 沪深300 不在此文件, 在 block_zs.dat(见 GetBlockData)。
func (*Client) GetStockCodeAll ¶ added in v0.0.57
GetStockCodeAll 获取所有股票代码,带前缀例sz000001
func (*Client) GetTdxStat ¶ added in v0.0.79
GetTdxStat 下载并解析 tdxstat.cfg(来自 zhb.zip) → 全市场个股综合统计指标。
func (*Client) GetTdxStat2 ¶ added in v0.0.79
GetTdxStat2 下载并解析 tdxstat2.cfg(来自 zhb.zip) → 全市场个股资金流向 + 板块归属。 其 BlockIndex 字段提供 股→板块指数代码(id) 的反向映射(见 protocol.StockBlockIndex)。
func (*Client) GetTdxZs ¶ added in v0.0.79
GetTdxZs 下载并解析板块指数配置 tdxzs.cfg(来自 zhb.zip) → 板块名↔指数代码(id) 列表。
func (*Client) GetTradeAll ¶
func (*Client) GetZHBFiles ¶ added in v0.0.79
GetZHBFiles 下载板块/配置数据总包 zhb.zip(report file 0x06B9)并解压,返回 文件名→原始字节。 zhb.zip 内含 tdxzs.cfg(板块指数代码)、tdxbk.cfg(概念板块)、incon.dat(行业分类)等配置文件。
type CodeModel ¶
type CodeModel struct {
ID int64 `json:"id"` //主键
Name string `json:"name"` //名称,有时候名称会变,例STxxx
Code string `json:"code" xorm:"index"` //代码
Exchange string `json:"exchange" xorm:"index"` //交易所
Multiple uint16 `json:"multiple"` //倍数
Decimal int8 `json:"decimal"` //小数位
LastPrice float64 `json:"lastPrice"` //昨收价格
EditDate int64 `json:"editDate" xorm:"updated"` //修改时间
InDate int64 `json:"inDate" xorm:"created"` //创建时间
}
type CodeModels ¶
type CodeModels []*CodeModel
func (CodeModels) Codes ¶
func (this CodeModels) Codes() []string
type Codes ¶
type Codes struct {
*CodesBase
// contains filtered or unexported fields
}
func NewCodes ¶
func NewCodes(op ...CodesOption) (*Codes, error)
func NewCodesMysql ¶
func NewCodesMysql(dsn string, op ...CodesOption) (*Codes, error)
func NewCodesSqlite ¶
func NewCodesSqlite(op ...CodesOption) (*Codes, error)
type CodesBase ¶
type CodesBase struct {
// contains filtered or unexported fields
}
func NewCodesBase ¶
func NewCodesBase() *CodesBase
func (*CodesBase) GetETFCodes ¶
GetETFCodes 获取基金代码,sz159xxx,sh510xxx,sh511xxx
func (*CodesBase) GetETFs ¶
func (this *CodesBase) GetETFs(limits ...int) CodeModels
GetETFs 获取基金代码,sz159xxx,sh510xxx,sh511xxx
func (*CodesBase) GetIndexCodes ¶
GetIndexCodes 获取基金代码,sz159xxx,sh510xxx,sh511xxx
func (*CodesBase) GetIndexes ¶
func (this *CodesBase) GetIndexes(limits ...int) CodeModels
GetIndexes 获取基金代码,sz159xxx,sh510xxx,sh511xxx
func (*CodesBase) GetStockCodes ¶
GetStockCodes 获取股票代码,sh6xxx sz0xx sz30xx
func (*CodesBase) GetStocks ¶
func (this *CodesBase) GetStocks(limits ...int) CodeModels
GetStocks 获取股票代码,sh6xxx sz0xx sz30xx
type CodesOption ¶ added in v0.0.58
type CodesOption func(*Codes)
func WithCodesClient ¶ added in v0.0.58
func WithCodesClient(c *Client) CodesOption
func WithCodesDB ¶ added in v0.0.58
func WithCodesDB(db *xorms.Engine) CodesOption
func WithCodesDialClient ¶ added in v0.0.58
func WithCodesDialClient(dial DialClientFunc) CodesOption
func WithCodesDialDB ¶ added in v0.0.58
func WithCodesDialDB(dial DialDBFunc) CodesOption
func WithCodesOption ¶ added in v0.0.58
func WithCodesOption(op ...CodesOption) CodesOption
func WithCodesRetry ¶ added in v0.0.58
func WithCodesRetry(retry int) CodesOption
func WithCodesSpec ¶ added in v0.0.58
func WithCodesSpec(spec string) CodesOption
type DialClientFunc ¶ added in v0.0.58
type DialCodesFunc ¶
type DialDBFunc ¶ added in v0.0.58
type DialGbbqFunc ¶ added in v0.0.61
type DialPoolFunc ¶ added in v0.0.58
type DialWorkdayFunc ¶
type Gbbq ¶ added in v0.0.61
type Gbbq struct {
// contains filtered or unexported fields
}
func NewGbbq ¶ added in v0.0.61
func NewGbbq(op ...GbbqOption) (*Gbbq, error)
func (*Gbbq) GetFactors ¶ added in v0.0.61
func (*Gbbq) GetTurnover ¶ added in v0.0.62
func (*Gbbq) GetXRXDMap ¶ added in v0.0.67
func (*Gbbq) HFQKlineDay ¶ added in v0.0.79
HFQKlineDay 一站式获取后复权日线(全量历史)。见 QFQKlineDay。
func (*Gbbq) QFQ ¶ added in v0.0.79
QFQ 把已获取的不复权日线 ks 转为前复权日线(对齐通达信桌面端, 四舍五入到分)。 已有 K 线时用此方法; 若要一步到位拉取+复权用 QFQKlineDay。
func (*Gbbq) QFQKlineDay ¶ added in v0.0.79
QFQKlineDay 一站式获取前复权日线(全量历史): 拉取不复权日K + 前复权(对齐通达信)。
type GbbqOption ¶ added in v0.0.61
type GbbqOption func(e *Gbbq)
func WithGbbqClient ¶ added in v0.0.61
func WithGbbqClient(c *Client) GbbqOption
func WithGbbqDB ¶ added in v0.0.61
func WithGbbqDB(db *xorms.Engine) GbbqOption
func WithGbbqDialClient ¶ added in v0.0.61
func WithGbbqDialClient(dial DialClientFunc) GbbqOption
func WithGbbqDialDB ¶ added in v0.0.61
func WithGbbqDialDB(dial func() (*xorms.Engine, error)) GbbqOption
func WithGbbqOption ¶ added in v0.0.61
func WithGbbqOption(op ...GbbqOption) GbbqOption
func WithGbbqRetry ¶ added in v0.0.61
func WithGbbqRetry(retry int) GbbqOption
func WithGbbqSpec ¶ added in v0.0.61
func WithGbbqSpec(spec string) GbbqOption
type ICodes ¶
type ICodes interface {
Iter() iter.Seq2[string, *CodeModel]
Get(code string) *CodeModel
GetName(code string) string
GetStocks(limit ...int) CodeModels
GetStockCodes(limit ...int) []string
GetETFs(limit ...int) CodeModels
GetETFCodes(limit ...int) []string
GetIndexes(limit ...int) CodeModels
GetIndexCodes(limit ...int) []string
}
var DefaultCodes ICodes
DefaultCodes 增加单例,部分数据需要通过Codes里面的信息计算
type Manage ¶
type Manage struct {
IPool
Codes ICodes
Workday *Workday
Gbbq IGbbq
// contains filtered or unexported fields
}
func (*Manage) AddWorkdayTask ¶
AddWorkdayTask 添加工作日任务
func (*Manage) RangeIndexes ¶
RangeIndexes 遍历所有指数
func (*Manage) RangeStocks ¶
RangeStocks 遍历所有股票
type Option ¶
type Option func(m *Manage)
func WithClients ¶
func WithDialCodes ¶
func WithDialCodes(dial DialCodesFunc) Option
func WithDialGbbq ¶ added in v0.0.61
func WithDialGbbq(dial DialGbbqFunc) Option
func WithDialGbbqDefault ¶ added in v0.0.61
func WithDialGbbqDefault() Option
func WithDialPool ¶ added in v0.0.58
func WithDialPool(dial DialPoolFunc) Option
func WithDialWorkday ¶
func WithDialWorkday(dial DialWorkdayFunc) Option
func WithOption ¶ added in v0.0.60
func WithWorkday ¶
type UpdateModel ¶
func (*UpdateModel) TableName ¶
func (*UpdateModel) TableName() string
type Updated ¶ added in v0.0.58
type Updated struct {
// contains filtered or unexported fields
}
func NewUpdated ¶ added in v0.0.58
NewUpdated 更新 hour=[9|15] minute=0
type Workday ¶
type Workday struct {
// contains filtered or unexported fields
}
func NewWorkday ¶
func NewWorkday(op ...WorkdayOption) (*Workday, error)
func NewWorkdayMysql ¶
func NewWorkdayMysql(dsn string, op ...WorkdayOption) (*Workday, error)
func NewWorkdaySqlite ¶
func NewWorkdaySqlite(op ...WorkdayOption) (*Workday, error)
type WorkdayModel ¶
type WorkdayModel struct {
ID int64 `json:"id"` //主键
Unix int64 `json:"unix"` //时间戳
Date string `json:"date"` //日期
}
WorkdayModel 工作日
func (*WorkdayModel) TableName ¶
func (this *WorkdayModel) TableName() string
type WorkdayOption ¶ added in v0.0.58
type WorkdayOption func(w *Workday)
func WithWorkdayClient ¶ added in v0.0.58
func WithWorkdayClient(c *Client) WorkdayOption
func WithWorkdayDB ¶ added in v0.0.58
func WithWorkdayDB(db *xorms.Engine) WorkdayOption
func WithWorkdayDialClient ¶ added in v0.0.58
func WithWorkdayDialClient(dial DialClientFunc) WorkdayOption
func WithWorkdayDialDB ¶ added in v0.0.58
func WithWorkdayDialDB(dial DialDBFunc) WorkdayOption
func WithWorkdayOption ¶ added in v0.0.58
func WithWorkdayOption(op ...WorkdayOption) WorkdayOption
func WithWorkdayRetry ¶ added in v0.0.58
func WithWorkdayRetry(retry int) WorkdayOption
func WithWorkdaySpec ¶ added in v0.0.58
func WithWorkdaySpec(spec string) WorkdayOption