gotdx

package module
v0.0.0-...-489507d Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 16 Imported by: 0

README

gotdx

通达信行情协议的 Go 客户端,覆盖主行情、扩展市场、MAC 板块/统一行情、F10/文件接口,以及一个可直接运行的 Web Viewer。

快速开始 · 能力概览 · 示例 · Web Viewer · API 速览 · 测试 · 协议文档

Markets MAC Web Viewer

gotdx 把通达信协议里常用的查询能力整理成更偏 Go 的调用方式。你可以直接查主行情和扩展市场的快照、K 线、分时、逐笔,也可以继续往下钻到 F10、财务、板块文件、扩展表格和 MAC 板块协议;如果只是想先看接口返回长什么样,仓库里还带了一个可以直接打开的网页查看器。

为什么用 gotdx

  • 一个 Client 同时管理主站和扩展市场,适合做统一监控和跨市场抓取。
  • 提供两套入口:高阶统一接口 Stock* / Ex* / MAC*,以及面向协议细节的底层 Get* / ExGet*
  • 地址池、超时、重试都可配,适合对接不稳定的真实行情站点。
  • 内置主站、扩展、MAC、券商 host/IP 列表,并支持 TCP 测速选最快节点。
  • 自带 30+ 个示例,覆盖从列表、快照、K 线、分时到 F10、板块、扩展表格。
  • 自带 cmd/webviewer,不写代码也能直接调方法、填参数、看返回字段。
  • 协议实现、示例和 Web Viewer 已整理为统一风格,便于继续补协议、核字段和排查差异。

快速开始

安装
go get github.com/bensema/gotdx
最小示例
package main

import (
	"log"

	"github.com/bensema/gotdx"
)

func main() {
	mainHosts := gotdx.MainHostAddresses()
	exHosts := gotdx.ExHostAddresses()

	client := gotdx.New(
		gotdx.WithTCPAddress(mainHosts[0]),
		gotdx.WithTCPAddressPool(mainHosts[1:]...),
		gotdx.WithExTCPAddress(exHosts[0]),
		gotdx.WithExTCPAddressPool(exHosts[1:]...),
		gotdx.WithAutoSelectFastest(true),
		gotdx.WithTimeoutSec(6),
	)
	defer client.Disconnect()

	stocks, err := client.StockQuotesDetail(
		[]uint8{gotdx.MarketSZ, gotdx.MarketSH},
		[]string{"000001", "600519"},
	)
	if err != nil {
		log.Fatal(err)
	}
	for _, item := range stocks {
		log.Printf("stock code=%s price=%.2f turnover=%.2f%%", item.Code, item.Price, item.Turnover)
	}

	exQuotes, err := client.ExQuotes(
		[]uint8{gotdx.ExCategoryUSStock},
		[]string{"TSLA"},
	)
	if err != nil {
		log.Fatal(err)
	}
	for _, item := range exQuotes {
		log.Printf("ex: %+v", item)
	}
}
从哪套 API 开始
  • 想尽快拿到业务数据:优先用 Stock* / Ex* / MAC* 统一高阶入口。
  • 想逐个协议排查字段:用 Get* / ExGet* / GetMAC* 底层接口。
  • 想先确认请求参数和返回格式:直接运行 go run ./cmd/webviewer
内置 Host 列表与测速
results := gotdx.ProbeHosts(gotdx.MainHosts(), time.Second)
for _, item := range results[:3] {
	log.Printf("main host=%s addr=%s reachable=%v latency=%s",
		item.Name, item.Address, item.Reachable, item.Latency)
}

fastest, err := gotdx.FastestHost(gotdx.ExHosts(), time.Second)
if err != nil {
	log.Fatal(err)
}
log.Printf("fastest ex host: %s %s", fastest.Name, fastest.Address)

client := gotdx.New(
	gotdx.WithAutoSelectFastest(true),
	gotdx.WithTimeoutSec(6),
)

可用列表包括:MainHostsBrokerHostsExHostsMACHostsMACExHosts,以及对应的 *HostAddresses 便捷函数。

能力概览

模块 典型能力 代表接口
主行情 股票/指数列表、快照、K 线、分时、逐笔、指数工具、异动、集合竞价 StockQuotesDetail, StockKLine, StockIndexInfo, StockUnusual, StockAuction
扩展市场 美股/港股/期货等扩展标的列表、报价、K 线、历史成交、表格 ExQuotes, ExKLine, ExHistoryTransaction, ExTable
F10 与文件 公司信息分类、正文、财务、除权除息、文件下载、板块文件 GetCompanyInfo, GetFinanceInfo, GetXDXRInfo, DownloadFullFile
MAC 协议 板块列表、成分股、成分报价、动态成分报价、单只快照、所属板块、统一 K 线 MACBoardList, MACBoardMembers, MACBoardMembersWithSort, MACBoardMembersQuotes, MACBoardMembersQuotesWithSort, MACBoardMembersQuotesDynamic, MACQuotes, MACSymbolBars
协议调试 原始协议响应、扩展实验接口、网页查看器 MainTodoB, MainClient26AD, ExExperiment2487, cmd/webviewer

项目结构

  • proto/: 各协议的请求/响应序列化与反序列化实现。
  • client_quote.go: 主行情底层接口。
  • client_exquote.go: 扩展市场底层接口。
  • client_mac.go: MAC 协议接口。
  • client_unified.go: Stock* / Ex* / MAC* 高阶统一入口。
  • cmd/webviewer/: 浏览器调试界面。
  • examples/: 可直接运行的示例。

示例

下面这些命令可以直接运行:

场景 命令
主行情快照 go run ./examples/stock_quotes
批量主行情 go run ./examples/stock_batch_quotes
列表与分页遍历 go run ./examples/stock_list / go run ./examples/stock_paged_list
K 线与指数工具 go run ./examples/stock_kline / go run ./examples/stock_index_tools
分时、历史分时、逐笔 go run ./examples/stock_tick / go run ./examples/stock_history / go run ./examples/stock_transaction
F10、公司资料、板块文件 go run ./examples/stock_f10_block / go run ./examples/stock_company_raw / go run ./examples/stock_block_raw
市场监控 go run ./examples/stock_market_watch
主机测速与地址池 go run ./examples/host_probe
主站服务与试验协议 go run ./examples/stock_server_info / go run ./examples/main_experimental
主行情兼容协议 go run ./examples/stock_list_old / go run ./examples/stock_feature_452 / go run ./examples/stock_quotes_encrypt / go run ./examples/stock_kline_offset / go run ./examples/stock_history_transaction_with_trans
扩展市场单只/批量报价 go run ./examples/ex_quote / go run ./examples/ex_quotes / go run ./examples/ex_quotes2
扩展市场列表与分类 go run ./examples/ex_count / go run ./examples/ex_list / go run ./examples/ex_paged_list / go run ./examples/ex_category_list
扩展市场 K 线、分时、历史成交 go run ./examples/ex_kline / go run ./examples/ex_tick / go run ./examples/ex_history
扩展试验与补充协议 go run ./examples/ex_list_extra / go run ./examples/ex_board_list / go run ./examples/ex_experiment_2487 / go run ./examples/ex_experiment_2488 / go run ./examples/ex_kline2 / go run ./examples/ex_mapping_2562
扩展市场表格 go run ./examples/ex_table / go run ./examples/ex_table_detail
MAC 协议 go run ./examples/mac_board_list / go run ./examples/mac_board_members / go run ./examples/mac_board_members_quotes / go run ./examples/mac_board_members_quotes_dynamic / go run ./examples/mac_quotes / go run ./examples/mac_symbol_belong_board / go run ./examples/mac_symbol_bars
统一监控示例 go run ./examples/unified_watchlist
查看完整示例目录
  • examples/stock_count
  • examples/stock_server_info
  • examples/stock_list
  • examples/stock_list_old
  • examples/stock_paged_list
  • examples/stock_batch_quotes
  • examples/stock_quotes
  • examples/stock_quotes_encrypt
  • examples/stock_lowlevel_quote
  • examples/stock_quotes_list
  • examples/stock_kline
  • examples/stock_kline_offset
  • examples/stock_feature_452
  • examples/stock_index_tools
  • examples/stock_tick
  • examples/stock_history
  • examples/stock_history_transaction_with_trans
  • examples/stock_market_watch
  • examples/host_probe
  • examples/stock_transaction
  • examples/stock_f10_block
  • examples/stock_company_raw
  • examples/stock_block_raw
  • examples/main_experimental
  • examples/ex_count
  • examples/ex_quote
  • examples/ex_list
  • examples/ex_list_extra
  • examples/ex_paged_list
  • examples/ex_quotes
  • examples/ex_quotes2
  • examples/ex_quotes_list
  • examples/ex_kline
  • examples/ex_kline2
  • examples/ex_board_list
  • examples/ex_experiment_2487
  • examples/ex_experiment_2488
  • examples/ex_mapping_2562
  • examples/ex_history
  • examples/ex_tick
  • examples/ex_server_info
  • examples/ex_sampling
  • examples/ex_category_list
  • examples/ex_table
  • examples/ex_table_detail
  • examples/mac_board_list
  • examples/mac_board_members
  • examples/mac_board_members_quotes
  • examples/mac_board_members_quotes_dynamic
  • examples/mac_quotes
  • examples/mac_symbol_belong_board
  • examples/mac_symbol_bars
  • examples/unified_watchlist

Web Viewer

仓库内置了一个轻量的网页查看器,适合在这些场景下使用:

  • 先确认某个方法应该填哪些参数。
  • 快速查看返回字段,而不是先写一段测试代码。
  • 对照 MAC 动态位图字段,直接看 bit/name/format/description
  • 直接检查主站文件、表格文件和 CSV 文件的结构化结果。
  • 对比不同主机返回的数据差异。
  • 调试实验协议或原始接口。

gotdx Web Viewer 截图

启动:

go run ./cmd/webviewer

默认地址:

http://127.0.0.1:8080

API 速览

高阶统一入口
  • StockQuotesDetailStockQuotesListStockQuotesStockKLineStockKLineOffsetStockVolumeProfile 会在可获取到流通股本时尽力补齐 Turnover
  • 主行情:StockCount, StockList, StockQuotesDetail, StockKLine, StockTickChart, StockIndexInfo, StockIndexMomentum, StockChartSampling, StockAuction, StockTopBoard, StockUnusual, StockVolumeProfile, StockHistoryOrders, StockHistoryTransaction, StockF10
  • 扩展市场:ExCount, ExList, ExQuote, ExQuotes, ExKLine, ExTickChart, ExHistoryTransaction, ExTable
  • MAC:MACBoardList, MACBoardMembers, MACBoardMembersWithSort, MACBoardMembersQuotes, MACBoardMembersQuotesWithSort, MACBoardMembersQuotesDynamic, MACQuotes, MACSymbolBelongBoard, MACSymbolBars
常用底层接口
  • 主行情:GetSecurityCount, GetSecurityListRange, GetQuotesDetail, GetIndexInfo, GetIndexMomentum, GetVolumeProfile, GetMinuteTimeData, GetAuction, GetTopBoard, GetUnusual, GetTransactionData, GetHistoryOrders
  • F10/文件:GetCompanyCategories, GetCompanyContent, GetFinanceInfo, GetXDXRInfo, DownloadFile, GetBlockFile
  • 扩展市场:ExGetCategoryList, ExGetQuotesList, ExGetQuote, ExGetChartSampling, ExGetFileMeta, ExDownloadFile
地址池与测速
  • 内置列表:MainHosts, BrokerHosts, ExHosts, MACHosts, MACExHosts
  • 地址便捷函数:MainHostAddresses, BrokerHostAddresses, ExHostAddresses, MACHostAddresses, MACExHostAddresses
  • 测速函数:ProbeHosts, ProbeAddresses, FastestHost, FastestAddress
  • 客户端能力:Client.ProbeHosts, Client.FastestHost, WithAutoSelectFastest
试验与兼容协议
  • 主站试验:MainTodoB, MainTodoFDE, MainClient264B, MainClient26AC, MainClient26AD, MainClient26AE, MainClient26B1
  • 主站兼容:StockListOld, StockFeature452, StockQuotesEncrypt, StockKLineOffset, StockHistoryTransactionWithTrans
  • 扩展试验:ExListExtra, ExExperiment2487, ExExperiment2488, ExKLine2, ExMapping2562
查看更完整的接口分组
主行情与通用接口
  • Connect, Disconnect
  • GetExchangeAnnouncement, GetServerHeartbeat, GetAnnouncement, GetServerInfo
  • GetSecurityCount, GetSecurityQuotes, GetQuotesDetail, GetQuotesEncrypt
  • GetSecurityList, GetSecurityListOld, GetSecurityListRange
  • GetKLine, GetSecurityBars, GetSecurityBarsOffset, GetIndexBars
  • GetIndexMomentum, GetIndexInfo, GetMinuteTimeData, GetTickChart, GetHistoryMinuteTimeData, GetHistoryTickChart
  • GetChartSampling, GetAuction, GetTopBoard, GetUnusual
  • GetTransactionData, GetHistoryOrders, GetHistoryTransactionData, GetHistoryTransactionDataWithTrans
F10、公司资料与文件
  • GetCompanyCategories, GetCompanyContent, GetFinanceInfo, GetXDXRInfo, GetCompanyInfo
  • GetFileMeta, DownloadFile, DownloadFullFile
  • GetBlockFile, GetTableFile, GetCSVFile, GetParsedBlockFile, GetGroupedBlockFile
扩展市场
  • ConnectEx, GetExServerInfo
  • ExGetCount, ExGetCategoryList, ExGetList, ExGetListExtra
  • ExGetQuotesList, ExGetQuote, ExGetQuotes, ExGetQuotes2
  • ExGetKLine, ExGetKLine2
  • ExGetHistoryTransaction, ExGetTickChart, ExGetHistoryTickChart, ExGetChartSampling
  • ExGetBoardList, ExGetMapping2562
  • ExGetFileMeta, ExDownloadFile, ExDownloadFullFile
  • ExGetTable, ExGetTableDetail
MAC 协议
  • NewMAC, NewMACEx, ConnectMAC
  • GetMACBoardCount, GetMACBoardList, GetMACBoardMembers, GetMACBoardMembersQuotes, GetMACBoardMembersQuotesDynamic, GetMACQuotes
  • GetMACSymbolBelongBoard, GetMACSymbolBars
  • MACBoardCount, MACBoardList, MACBoardMembers, MACBoardMembersWithSort, MACBoardMembersQuotes, MACBoardMembersQuotesWithSort, MACBoardMembersQuotesDynamic, MACQuotes
  • MACSymbolBelongBoard, MACSymbolBars
  • 位图辅助:DefaultMACBoardMembersQuotesFieldBitmap, FullMACBoardMembersQuotesFieldBitmap, MACBoardMembersQuotesFieldBitmapFromBits

测试

单元测试:

go test ./...

连接真实站点的集成测试默认跳过;如需开启:

GOTDX_INTEGRATION=1 go test ./...

相关文档

License

本项目使用 MIT License 开源,详见 LICENSE

Documentation

Index

Constants

View Source
const (
	DefaultMACBoardListCount         = 10000
	DefaultMACBoardPageSize   uint16 = 150
	DefaultMACBoardStockCount uint32 = 10000
	DefaultMACBoardStockPage  uint8  = 80
	DefaultMACSymbolBarsCount uint32 = 800
	DefaultMACSymbolBarsPage  uint16 = 700
)
View Source
const (
	MarketSZ uint8 = 0 // 深圳
	MarketSH uint8 = 1 // 上海
	MarketBJ uint8 = 2 // 北京

	// Backward-compatible aliases.
	MarketSz = MarketSZ
	MarketSh = MarketSH
	MarketBj = MarketBJ
)
View Source
const (
	ExMarketStock        uint8 = 1  // 股票
	ExMarketHK           uint8 = 2  // 香港
	ExMarketFutures      uint8 = 3  // 期货
	ExMarketFX           uint8 = 4  // 汇率
	ExMarketIndex        uint8 = 5  // 指数
	ExMarketValuation    uint8 = 6  // 估值
	ExMarketMoney        uint8 = 7  // 资金
	ExMarketFund         uint8 = 8  // 基金
	ExMarketMonetaryFund uint8 = 9  // 货币基金
	ExMarketIndicator    uint8 = 10 // 指标
	ExMarketMirror       uint8 = 11 // 镜像
	ExMarketOption       uint8 = 12 // 期权
	ExMarketUS           uint8 = 13 // 美国
	ExMarketDE           uint8 = 14 // 德国
	ExMarketSG           uint8 = 15 // 新加坡
)
View Source
const (
	ExCategoryTempStock           uint8 = 1
	ExCategoryZZFuturesOption     uint8 = 4
	ExCategoryDLFuturesOption     uint8 = 5
	ExCategorySHFuturesOption     uint8 = 6
	ExCategoryCFFEXOption         uint8 = 7
	ExCategorySHStockOption       uint8 = 8
	ExCategorySZStockOption       uint8 = 9
	ExCategoryBasicFX             uint8 = 10
	ExCategoryCrossFX             uint8 = 11
	ExCategoryIntlIndex           uint8 = 12
	ExCategoryCOMEXFutures        uint8 = 16
	ExCategoryNYMEXFutures        uint8 = 17
	ExCategoryCBOTFutures         uint8 = 18
	ExCategoryHKFinancialFutures  uint8 = 23
	ExCategoryHKFinancialOptions  uint8 = 24
	ExCategoryHKStockFutures      uint8 = 25
	ExCategoryHKStockOptions      uint8 = 26
	ExCategoryHKIndex             uint8 = 27
	ExCategoryZZFutures           uint8 = 28
	ExCategoryDLFutures           uint8 = 29
	ExCategorySHFutures           uint8 = 30
	ExCategoryHKMainBoard         uint8 = 31
	ExCategoryOpenEndFund         uint8 = 33
	ExCategoryMonetaryFund        uint8 = 34
	ExCategoryMacroIndicator      uint8 = 38
	ExCategoryFuturesIndex        uint8 = 42
	ExCategoryBToH                uint8 = 43
	ExCategoryNEEQ                uint8 = 44
	ExCategorySHGold              uint8 = 46
	ExCategoryCFFEXFutures        uint8 = 47
	ExCategoryHKGEM               uint8 = 48
	ExCategoryHKFund              uint8 = 49
	ExCategoryTreasuryValuation   uint8 = 54
	ExCategorySunshinePrivateFund uint8 = 56
	ExCategoryBrokerCollective    uint8 = 57
	ExCategoryBrokerMonetary      uint8 = 58
	ExCategoryMainFuturesContract uint8 = 60
	ExCategoryCSIIndex            uint8 = 62
	ExCategoryGZArbitrageFutures  uint8 = 65
	ExCategoryGZFutures           uint8 = 66
	ExCategoryGZOptions           uint8 = 67
	ExCategoryRiskControlIndex    uint8 = 68
	ExCategoryHuazhengIndex       uint8 = 69
	ExCategoryExtendedSectorIndex uint8 = 70
	ExCategoryHKStock             uint8 = 71
	ExCategoryGEStock             uint8 = 73
	ExCategoryUSStock             uint8 = 74
	ExCategorySGStock             uint8 = 78
	ExCategoryMoneyMarket         uint8 = 91
	ExCategoryFundValuation       uint8 = 93
	ExCategoryHKDarkPool          uint8 = 98
	ExCategoryCodeMirror          uint8 = 100
	ExCategorySZSEIndex           uint8 = 102
)
View Source
const (
	DefaultSecurityListCount = 1600
	DefaultTickChartCount    = 0xba00
	DefaultAuctionCount      = 500
	DefaultUnusualCount      = 600
	DefaultTopBoardSize      = 20
	DefaultQuotesListCount   = 80
	DefaultExListCount       = 2000
	DefaultExQuotesCount     = 100
	DefaultDownloadSize      = 0x7530
)
View Source
const (
	AdjustNone uint16 = 0
	AdjustQFQ  uint16 = 1
	AdjustHFQ  uint16 = 2
)
View Source
const (
	CategorySH  uint8 = 0  // 上证A
	CategorySZ  uint8 = 2  // 深证A
	CategoryA   uint8 = 6  // A股
	CategoryB   uint8 = 7  // B股
	CategoryKCB uint8 = 8  // 科创板
	CategoryBJ  uint8 = 12 // 北证A
	CategoryCYB uint8 = 14 // 创业板
)
View Source
const (
	FilterNew uint16 = 1
	FilterKC  uint16 = 2
	FilterST  uint16 = 4
	FilterCY  uint16 = 8
	FilterBJ  uint16 = 16
)
View Source
const (
	SortCode             uint16 = 0x0
	SortName             uint16 = 0x1
	SortPreClose         uint16 = 0x2
	SortOpen             uint16 = 0x3
	SortHigh             uint16 = 0x4
	SortLow              uint16 = 0x5
	SortPrice            uint16 = 0x6
	SortBid              uint16 = 0x7
	SortAsk              uint16 = 0x8
	SortVolume           uint16 = 0x9
	SortTotalAmount      uint16 = 0x0a
	SortLastVolume       uint16 = 0x0b
	SortChange           uint16 = 0x0c
	SortChangePct        uint16 = 0x0e
	SortAmplitudePct     uint16 = 0x0f
	SortAvg              uint16 = 0x10
	SortPEDynamic        uint16 = 0x11
	SortEntrustRatio     uint16 = 0x12
	SortInsideVolume     uint16 = 0x13
	SortOutsideVolume    uint16 = 0x14
	SortInOutRatio       uint16 = 0x15
	SortBidVolume        uint16 = 0x17
	SortAskVolume        uint16 = 0x18
	SortLockedRatio      uint16 = 0x1b
	SortLockedAmount     uint16 = 0x1c
	SortOpenAmount       uint16 = 0x1d
	SortOpenTurnoverPct  uint16 = 0x1e
	SortVolRatio         uint16 = 0x23
	SortTurnoverRate     uint16 = 0x24
	SortFloatShares      uint16 = 0x25
	SortFloatMarketCap   uint16 = 0x26
	SortTotalMarketCapAB uint16 = 0x27
	SortUnmatchedVolume  uint16 = 0x2a
	SortStrengthPct      uint16 = 0x2d
	SortSpeedPct         uint16 = 0x2e
	SortActivity         uint16 = 0x2f
	SortShortTurnoverPct uint16 = 0xcc
	SortVolSpeedPct      uint16 = 0xd0
	SortMainNetAmount    uint16 = 0xd4
	SortMainNetRatio     uint16 = 0xd7
	SortAuctionLimitBuy  uint16 = 0x102
	SortOpenSnatchPct    uint16 = 0x10a
	SortAmount2M         uint16 = 0x10c
	SortOpenPct          uint16 = 0x119
	SortHighPct          uint16 = 0x11a
	SortLowPct           uint16 = 0x11b
	SortAvgChangePct     uint16 = 0x11c
	SortDrawdownPct      uint16 = 0x11e
	SortAttackPct        uint16 = 0x11f
)
View Source
const (
	SortOrderNone uint16 = 0
	SortOrderDesc uint16 = 1
	SortOrderAsc  uint16 = 2
)
View Source
const (
	BlockFileDefault = "block.dat"
	BlockFileZS      = "block_zs.dat"
	BlockFileFG      = "block_fg.dat"
	BlockFileGN      = "block_gn.dat"
)
View Source
const (
	BoardTypeHY      uint16 = 0
	BoardTypeHY2     uint16 = 1
	BoardTypeGN      uint16 = 3
	BoardTypeFG      uint16 = 4
	BoardTypeDQ      uint16 = 5
	BoardTypeUnknown uint16 = 6
	BoardTypeHYOther uint16 = 7
	BoardTypeOther11 uint16 = 8
	BoardTypeOther12 uint16 = 9
	BoardTypeAll     uint16 = 255
)
View Source
const (
	ExBoardTypeHKAll uint16 = 0
	ExBoardTypeHKGN  uint16 = 1
	ExBoardTypeHKHY  uint16 = 2
	ExBoardTypeUSAll uint16 = 3
	ExBoardTypeUSGN  uint16 = 4
	ExBoardTypeUSHY  uint16 = 5
)
View Source
const (
	KLINE_TYPE_5MIN      = 0  // 5 分钟K 线
	KLINE_TYPE_15MIN     = 1  // 15 分钟K 线
	KLINE_TYPE_30MIN     = 2  // 30 分钟K 线
	KLINE_TYPE_1HOUR     = 3  // 1 小时K 线
	KLINE_TYPE_DAILY     = 4  // 日K 线
	KLINE_TYPE_WEEKLY    = 5  // 周K 线
	KLINE_TYPE_MONTHLY   = 6  // 月K 线
	KLINE_TYPE_EXHQ_1MIN = 7  //  1 分钟
	KLINE_TYPE_1MIN      = 8  // 1 分钟K 线
	KLINE_TYPE_RI_K      = 9  // 日K 线
	KLINE_TYPE_3MONTH    = 10 // 季K 线
	KLINE_TYPE_YEARLY    = 11 // 年K 线
	KLINE_TYPE_SECONDS   = 13 // 多秒K 线
)

Variables

View Source
var (
	ErrBadData = errors.New("more than 8M data")
)
View Source
var ErrMarketCodeCount = errors.New("market code count error")
View Source
var ErrNoReachableHosts = errors.New("no reachable hosts")

ErrNoReachableHosts indicates that every probed host failed the TCP dial.

Functions

func BrokerHostAddresses

func BrokerHostAddresses() []string

BrokerHostAddresses returns the built-in broker host:port list.

func DefaultMACBoardMembersQuotesFieldBitmap

func DefaultMACBoardMembersQuotesFieldBitmap() [20]byte

DefaultMACBoardMembersQuotesFieldBitmap 返回与当前稳定成分报价接口一致的默认字段位图。

func ExHostAddresses

func ExHostAddresses() []string

ExHostAddresses returns the built-in extended-market host:port list.

func FullMACBoardMembersQuotesFieldBitmap

func FullMACBoardMembersQuotesFieldBitmap() [20]byte

FullMACBoardMembersQuotesFieldBitmap 返回 20 字节全 1 位图,适合实验性全字段请求。

func MACBoardMembersQuotesFieldBitmapFromBits

func MACBoardMembersQuotesFieldBitmapFromBits(bits ...int) [20]byte

MACBoardMembersQuotesFieldBitmapFromBits 根据 bit 列表组装 20 字节字段位图。

func MACExHostAddresses

func MACExHostAddresses() []string

MACExHostAddresses returns the built-in MAC extended-market host:port list.

func MACHostAddresses

func MACHostAddresses() []string

MACHostAddresses returns the built-in MAC quote host:port list.

func MainHostAddresses

func MainHostAddresses() []string

MainHostAddresses returns the built-in main quote host:port list.

Types

type BlockFlatItem

type BlockFlatItem struct {
	BlockName string
	BlockType uint16
	CodeIndex int
	Code      string
}

func ParseBlockFlat

func ParseBlockFlat(data []byte) ([]BlockFlatItem, error)

type BlockGroup

type BlockGroup struct {
	BlockName  string
	BlockType  uint16
	StockCount int
	Codes      []string
}

func ParseBlockGroups

func ParseBlockGroups(data []byte) ([]BlockGroup, error)

type Client

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

func New

func New(opts ...Option) *Client

func NewEx

func NewEx(opts ...Option) *Client

func NewMAC

func NewMAC(opts ...Option) *Client

func NewMACEx

func NewMACEx(opts ...Option) *Client

func (*Client) Connect

func (client *Client) Connect() (*proto.Hello1Reply, error)

Connect 连接券商行情服务器

func (*Client) ConnectEx

func (client *Client) ConnectEx() (*proto.ExLoginReply, error)

ConnectEx 连接扩展市场服务器并完成登录

func (*Client) ConnectMAC

func (client *Client) ConnectMAC() error

func (*Client) CurrentAddress

func (client *Client) CurrentAddress() string

func (*Client) Disconnect

func (client *Client) Disconnect() error

Disconnect 断开服务器

func (*Client) DownloadFile

func (client *Client) DownloadFile(filename string, start uint32, size uint32) (*proto.DownloadFileReply, error)

DownloadFile 下载文件片段

func (*Client) DownloadFullFile

func (client *Client) DownloadFullFile(filename string, size uint32) ([]byte, error)

DownloadFullFile 下载完整文件

func (*Client) ExBoardList

func (client *Client) ExBoardList(boardType uint16, start uint16, pageSize uint16) ([]proto.ExBoardListItem, error)

func (*Client) ExCategoryList

func (client *Client) ExCategoryList() ([]proto.ExCategoryItem, error)

func (*Client) ExChartSampling

func (client *Client) ExChartSampling(category uint8, code string) ([]float64, error)

func (*Client) ExCount

func (client *Client) ExCount() (uint32, error)

func (*Client) ExDownloadFile

func (client *Client) ExDownloadFile(filename string, start uint32, size uint32) (*proto.DownloadFileReply, error)

ExDownloadFile 下载扩展市场文件片段

func (*Client) ExDownloadFullFile

func (client *Client) ExDownloadFullFile(filename string, size uint32) ([]byte, error)

ExDownloadFullFile 下载完整扩展市场文件

func (*Client) ExExperiment2487

func (client *Client) ExExperiment2487(category uint8, code string) (*proto.ExExperiment2487Reply, error)

func (*Client) ExExperiment2488

func (client *Client) ExExperiment2488(category uint8, code string, mode uint16) ([]proto.ExExperiment2488Item, error)

func (*Client) ExGetBoardList

func (client *Client) ExGetBoardList(boardType uint16, start uint16, pageSize uint16) (*proto.ExGetBoardListReply, error)

ExGetBoardList 获取扩展市场板块榜单

func (*Client) ExGetCategoryList

func (client *Client) ExGetCategoryList() (*proto.ExGetCategoryListReply, error)

ExGetCategoryList 获取扩展市场分类列表

func (*Client) ExGetChartSampling

func (client *Client) ExGetChartSampling(category uint8, code string) (*proto.ExGetChartSamplingReply, error)

ExGetChartSampling 获取扩展市场抽样图

func (*Client) ExGetCount

func (client *Client) ExGetCount() (*proto.ExGetCountReply, error)

ExGetCount 获取扩展市场标的数量

func (*Client) ExGetExperiment2487

func (client *Client) ExGetExperiment2487(category uint8, code string) (*proto.ExExperiment2487Reply, error)

ExGetExperiment2487 获取扩展市场试验报价 0x2487

func (*Client) ExGetExperiment2488

func (client *Client) ExGetExperiment2488(category uint8, code string, mode uint16) (*proto.ExExperiment2488Reply, error)

ExGetExperiment2488 获取扩展市场试验报价 0x2488

func (*Client) ExGetFileMeta

func (client *Client) ExGetFileMeta(filename string) (*proto.GetFileMetaReply, error)

ExGetFileMeta 获取扩展市场文件元信息

func (*Client) ExGetHistoryTickChart

func (client *Client) ExGetHistoryTickChart(date uint32, category uint8, code string) (*proto.ExGetHistoryTickChartReply, error)

ExGetHistoryTickChart 获取扩展市场历史分时图

func (*Client) ExGetHistoryTransaction

func (client *Client) ExGetHistoryTransaction(date uint32, category uint8, code string) (*proto.ExGetHistoryTransactionReply, error)

ExGetHistoryTransaction 获取扩展市场历史成交

func (*Client) ExGetKLine

func (client *Client) ExGetKLine(category uint8, code string, period uint16, start uint32, count uint16, times uint16) (*proto.ExGetKLineReply, error)

ExGetKLine 获取扩展市场K线

func (*Client) ExGetKLine2

func (client *Client) ExGetKLine2(category uint8, code string, period uint16, start uint32, count uint32, times uint16) (*proto.ExGetKLine2Reply, error)

ExGetKLine2 获取扩展市场 K 线协议 0x2489

func (*Client) ExGetList

func (client *Client) ExGetList(start uint32, count uint16) (*proto.ExGetListReply, error)

ExGetList 获取扩展市场标的列表

func (*Client) ExGetListExtra

func (client *Client) ExGetListExtra(a uint16, b uint16, count uint16) (*proto.ExGetListExtraReply, error)

ExGetListExtra 获取扩展市场试验列表

func (*Client) ExGetMapping2562

func (client *Client) ExGetMapping2562(market uint16, start uint32, count uint32) (*proto.ExMapping2562Reply, error)

ExGetMapping2562 获取扩展市场映射信息

func (*Client) ExGetQuote

func (client *Client) ExGetQuote(category uint8, code string) (*proto.ExGetQuoteReply, error)

ExGetQuote 获取单个扩展市场行情

func (*Client) ExGetQuotes

func (client *Client) ExGetQuotes(categories []uint8, codes []string) (*proto.ExGetQuotesReply, error)

ExGetQuotes 获取批量扩展市场行情

func (*Client) ExGetQuotes2

func (client *Client) ExGetQuotes2(categories []uint8, codes []string) (*proto.ExGetQuotesReply, error)

ExGetQuotes2 获取批量扩展市场行情,兼容 pytdx2 的第二种批量接口

func (*Client) ExGetQuotesList

func (client *Client) ExGetQuotesList(category uint8, start uint16, count uint16, sortType uint16, reverse bool) (*proto.ExGetQuotesListReply, error)

ExGetQuotesList 获取扩展市场行情列表

func (*Client) ExGetTable

func (client *Client) ExGetTable() (string, error)

ExGetTable 获取扩展市场表格内容

func (*Client) ExGetTableDetail

func (client *Client) ExGetTableDetail() (string, error)

ExGetTableDetail 获取扩展市场详细表格内容

func (*Client) ExGetTickChart

func (client *Client) ExGetTickChart(category uint8, code string) (*proto.ExGetTickChartReply, error)

ExGetTickChart 获取扩展市场当日分时图

func (*Client) ExHistoryTransaction

func (client *Client) ExHistoryTransaction(date uint32, category uint8, code string) ([]proto.ExHistoryTransactionItem, error)

func (*Client) ExKLine

func (client *Client) ExKLine(category uint8, code string, period uint16, start uint32, count uint16, times uint16) ([]proto.ExKLineItem, error)

func (*Client) ExKLine2

func (client *Client) ExKLine2(category uint8, code string, period uint16, start uint32, count uint32, times uint16) ([]proto.ExKLineItem, error)

func (*Client) ExList

func (client *Client) ExList(start uint32, count uint16) ([]proto.ExListItem, error)

func (*Client) ExListExtra

func (client *Client) ExListExtra(a uint16, b uint16, count uint16) ([]proto.ExExtraListItem, error)

func (*Client) ExMapping2562

func (client *Client) ExMapping2562(market uint16, start uint32, count uint32) ([]proto.ExMapping2562Item, error)

func (*Client) ExQuote

func (client *Client) ExQuote(category uint8, code string) (*proto.ExQuoteItem, error)

func (*Client) ExQuotes

func (client *Client) ExQuotes(categories []uint8, codes []string) ([]proto.ExQuoteItem, error)

func (*Client) ExQuotes2

func (client *Client) ExQuotes2(categories []uint8, codes []string) ([]proto.ExQuoteItem, error)

func (*Client) ExQuotesList

func (client *Client) ExQuotesList(category uint8, start uint16, count uint16, sortType uint16, reverse bool) ([]proto.ExQuoteItem, error)

func (*Client) ExTable

func (client *Client) ExTable() (string, error)

func (*Client) ExTableDetail

func (client *Client) ExTableDetail() (string, error)

func (*Client) ExTickChart

func (client *Client) ExTickChart(category uint8, code string, date uint32) ([]proto.ExTickChartData, error)

func (*Client) FastestHost

func (client *Client) FastestHost() (HostProbeResult, error)

FastestHost returns the fastest reachable configured address.

func (*Client) GetAnnouncement

func (client *Client) GetAnnouncement() (*proto.AnnouncementReply, error)

GetAnnouncement 获取服务商公告

func (*Client) GetAuction

func (client *Client) GetAuction(market uint8, code string, start uint32, count uint32) (*proto.GetAuctionReply, error)

GetAuction 获取集合竞价

func (*Client) GetBlockFile

func (client *Client) GetBlockFile(filename string) ([]byte, error)

GetBlockFile 获取完整板块文件

func (*Client) GetCSVFile

func (client *Client) GetCSVFile(filename string) ([][]string, error)

GetCSVFile 获取 CSV 文件

func (*Client) GetChartSampling

func (client *Client) GetChartSampling(market uint8, code string) (*proto.GetChartSamplingReply, error)

GetChartSampling 获取抽样图数据

func (*Client) GetClient26AC

func (client *Client) GetClient26AC() (*proto.RawDataReply, error)

GetClient26AC 获取客户端信息协议 0x26ac 的原始响应

func (*Client) GetClient26AD

func (client *Client) GetClient26AD() (*proto.RawDataReply, error)

GetClient26AD 获取客户端信息协议 0x26ad 的原始响应

func (*Client) GetClient26AE

func (client *Client) GetClient26AE() (*proto.RawDataReply, error)

GetClient26AE 获取客户端信息协议 0x26ae 的原始响应

func (*Client) GetClient26B1

func (client *Client) GetClient26B1() (*proto.RawDataReply, error)

GetClient26B1 获取客户端信息协议 0x26b1 的原始响应

func (*Client) GetClient264B

func (client *Client) GetClient264B() (*proto.RawDataReply, error)

GetClient264B 获取客户端信息协议 0x264b 的原始响应

func (*Client) GetCompanyCategories

func (client *Client) GetCompanyCategories(market uint8, code string) (*proto.GetCompanyCategoryReply, error)

GetCompanyCategories 获取公司信息分类

func (*Client) GetCompanyContent

func (client *Client) GetCompanyContent(market uint8, code string, filename string, start uint32, length uint32) (*proto.GetCompanyContentReply, error)

GetCompanyContent 获取公司信息内容

func (*Client) GetCompanyInfo

func (client *Client) GetCompanyInfo(market uint8, code string) (*CompanyInfoBundle, error)

GetCompanyInfo 获取公司信息聚合结果

func (*Client) GetExServerInfo

func (client *Client) GetExServerInfo() (*proto.ExServerInfoReply, error)

GetExServerInfo 获取扩展市场服务信息

func (*Client) GetExchangeAnnouncement

func (client *Client) GetExchangeAnnouncement() (*proto.ExchangeAnnouncementReply, error)

GetExchangeAnnouncement 获取交易所公告

func (*Client) GetFileMeta

func (client *Client) GetFileMeta(filename string) (*proto.GetFileMetaReply, error)

GetFileMeta 获取文件元信息

func (*Client) GetFinanceInfo

func (client *Client) GetFinanceInfo(market uint8, code string) (*proto.GetFinanceInfoReply, error)

GetFinanceInfo 获取财务信息

func (*Client) GetGroupedBlockFile

func (client *Client) GetGroupedBlockFile(filename string) ([]BlockGroup, error)

GetGroupedBlockFile 获取并按板块分组解析板块文件

func (*Client) GetHistoryMinuteTimeData

func (client *Client) GetHistoryMinuteTimeData(date uint32, market uint8, code string) (*proto.GetHistoryMinuteTimeDataReply, error)

GetHistoryMinuteTimeData 获取历史分时图数据

func (*Client) GetHistoryOrders

func (client *Client) GetHistoryOrders(date uint32, market uint8, code string) (*proto.GetHistoryOrdersReply, error)

GetHistoryOrders 获取历史委托

func (*Client) GetHistoryTickChart

func (client *Client) GetHistoryTickChart(date uint32, market uint8, code string) (*proto.GetHistoryMinuteTimeDataReply, error)

GetHistoryTickChart 获取历史分时图数据

func (*Client) GetHistoryTransactionData

func (client *Client) GetHistoryTransactionData(date uint32, market uint8, code string, start uint16, count uint16) (*proto.GetHistoryTransactionDataReply, error)

GetHistoryTransactionData 获取历史分时成交

func (*Client) GetHistoryTransactionDataWithTrans

func (client *Client) GetHistoryTransactionDataWithTrans(date uint32, market uint8, code string, start uint16, count uint16) (*proto.GetHistoryTransactionDataWithTransReply, error)

GetHistoryTransactionDataWithTrans 获取带方向的历史分时成交

func (*Client) GetIndexBars

func (client *Client) GetIndexBars(category uint16, market uint8, code string, start uint16, count uint16) (*proto.GetIndexBarsReply, error)

GetIndexBars 获取指数K线

func (*Client) GetIndexInfo

func (client *Client) GetIndexInfo(market uint8, code string) (*proto.GetIndexInfoReply, error)

GetIndexInfo 获取指数概况

func (*Client) GetIndexMomentum

func (client *Client) GetIndexMomentum(market uint8, code string) (*proto.GetIndexMomentumReply, error)

GetIndexMomentum 获取指数动量

func (*Client) GetKLine

func (client *Client) GetKLine(category uint16, market uint8, code string, start uint16, count uint16, times uint16, adjust uint16) (*proto.GetSecurityBarsReply, error)

GetKLine 获取K线

func (*Client) GetMACBoardCount

func (client *Client) GetMACBoardCount(boardType uint16) (*proto.MACBoardCountReply, error)

func (*Client) GetMACBoardList

func (client *Client) GetMACBoardList(boardType uint16, start uint16, pageSize uint16) (*proto.MACBoardListReply, error)

func (*Client) GetMACBoardMembers

func (client *Client) GetMACBoardMembers(boardSymbol string, sortType uint16, start uint32, pageSize uint8, sortOrder uint16) (*proto.MACBoardMembersReply, error)

func (*Client) GetMACBoardMembersQuotes

func (client *Client) GetMACBoardMembersQuotes(boardSymbol string, sortType uint16, start uint32, pageSize uint8, sortOrder uint8) (*proto.MACBoardMembersQuotesReply, error)

func (*Client) GetMACBoardMembersQuotesDynamic

func (client *Client) GetMACBoardMembersQuotesDynamic(boardSymbol string, sortType uint16, start uint32, pageSize uint8, sortOrder uint8, fieldBitmap [20]byte) (*proto.MACBoardMembersQuotesDynamicReply, error)

GetMACBoardMembersQuotesDynamic 获取按位图动态解析的 MAC 板块成分报价。

func (*Client) GetMACQuotes

func (client *Client) GetMACQuotes(market uint8, code string) (*proto.MACQuotesReply, error)

GetMACQuotes 获取 MAC 单只标的快照与分时采样。

func (*Client) GetMACSymbolBars

func (client *Client) GetMACSymbolBars(market uint8, code string, period uint16, times uint16, start uint32, count uint16, adjust uint16) (*proto.MACSymbolBarsReply, error)

func (*Client) GetMACSymbolBelongBoard

func (client *Client) GetMACSymbolBelongBoard(market uint8, symbol string) (*proto.MACSymbolBelongBoardReply, error)

func (*Client) GetMinuteTimeData

func (client *Client) GetMinuteTimeData(market uint8, code string) (*proto.GetMinuteTimeDataReply, error)

GetMinuteTimeData 获取分时图数据

func (*Client) GetParsedBlockFile

func (client *Client) GetParsedBlockFile(filename string) ([]BlockFlatItem, error)

GetParsedBlockFile 获取并解析板块文件

func (*Client) GetQuotes

func (client *Client) GetQuotes(markets []uint8, codes []string) (*proto.GetQuotesReply, error)

GetQuotes 获取批量行情

func (*Client) GetQuotesDetail

func (client *Client) GetQuotesDetail(markets []uint8, codes []string) (*proto.GetSecurityQuotesReply, error)

GetQuotesDetail 获取详细行情报价

func (*Client) GetQuotesEncrypt

func (client *Client) GetQuotesEncrypt(markets []uint8, codes []string) (*proto.GetQuotesEncryptReply, error)

GetQuotesEncrypt 获取加密行情

func (*Client) GetQuotesList

func (client *Client) GetQuotesList(category uint8, start uint16, count uint16, sortType uint16, reverse bool, filter uint16) (*proto.GetQuotesListReply, error)

GetQuotesList 获取排序行情列表

func (*Client) GetSecurityBars

func (client *Client) GetSecurityBars(category uint16, market uint8, code string, start uint16, count uint16) (*proto.GetSecurityBarsReply, error)

GetSecurityBars 获取股票K线

func (*Client) GetSecurityBarsOffset

func (client *Client) GetSecurityBarsOffset(category uint16, market uint8, code string, start uint16, count uint16, times uint16, adjust uint16) (*proto.GetSecurityBarsOffsetReply, error)

GetSecurityBarsOffset 获取偏移K线

func (*Client) GetSecurityCount

func (client *Client) GetSecurityCount(market uint8) (*proto.GetSecurityCountReply, error)

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

func (*Client) GetSecurityFeature452

func (client *Client) GetSecurityFeature452(start uint32, count uint32) (*proto.GetSecurityFeature452Reply, error)

GetSecurityFeature452 获取证券扩展信息

func (*Client) GetSecurityList

func (client *Client) GetSecurityList(market uint8, start uint16) (*proto.GetSecurityListReply, error)

GetSecurityList 获取市场内指定范围内的所有证券代码

func (*Client) GetSecurityListOld

func (client *Client) GetSecurityListOld(market uint8, start uint16) (*proto.GetSecurityListOldReply, error)

GetSecurityListOld 获取旧版证券列表

func (*Client) GetSecurityListRange

func (client *Client) GetSecurityListRange(market uint8, start uint32, count uint32) (*proto.GetSecurityListReply, error)

GetSecurityListRange 获取市场内指定范围内的证券代码

func (*Client) GetSecurityQuotes

func (client *Client) GetSecurityQuotes(markets []uint8, codes []string) (*proto.GetSecurityQuotesReply, error)

GetSecurityQuotes 获取盘口五档报价

func (*Client) GetServerHeartbeat

func (client *Client) GetServerHeartbeat() (*proto.HeartBeatReply, error)

GetServerHeartbeat 获取服务端心跳返回

func (*Client) GetServerInfo

func (client *Client) GetServerInfo() (*proto.InfoReply, error)

GetServerInfo 获取主站服务信息

func (*Client) GetTableFile

func (client *Client) GetTableFile(filename string) ([][]string, error)

GetTableFile 获取以竖线分隔的表格文件

func (*Client) GetTickChart

func (client *Client) GetTickChart(market uint8, code string, start uint16, count uint16) (*proto.GetMinuteTimeDataReply, error)

GetTickChart 获取当日分时图数据

func (*Client) GetTodoB

func (client *Client) GetTodoB() (*proto.RawDataReply, error)

GetTodoB 获取主站试验协议 0x000b 的原始响应

func (*Client) GetTodoFDE

func (client *Client) GetTodoFDE() (*proto.RawDataReply, error)

GetTodoFDE 获取主站试验协议 0x0fde 的原始响应

func (*Client) GetTopBoard

func (client *Client) GetTopBoard(category uint8, size uint8) (*proto.GetTopBoardReply, error)

GetTopBoard 获取排行榜

func (*Client) GetTransactionData

func (client *Client) GetTransactionData(market uint8, code string, start uint16, count uint16) (*proto.GetTransactionDataReply, error)

GetTransactionData 获取分时成交

func (*Client) GetUnusual

func (client *Client) GetUnusual(market uint8, start uint32, count uint32) (*proto.GetUnusualReply, error)

GetUnusual 获取主力监控

func (*Client) GetVolumeProfile

func (client *Client) GetVolumeProfile(market uint8, code string) (*proto.GetVolumeProfileReply, error)

GetVolumeProfile 获取成交分布

func (*Client) GetXDXRInfo

func (client *Client) GetXDXRInfo(market uint8, code string) (*proto.GetXDXRInfoReply, error)

GetXDXRInfo 获取除权除息信息

func (*Client) MACBoardCount

func (client *Client) MACBoardCount(boardType uint16) (uint16, error)

func (*Client) MACBoardList

func (client *Client) MACBoardList(boardType uint16, count uint32) ([]proto.MACBoardListItem, error)

func (*Client) MACBoardMembers

func (client *Client) MACBoardMembers(boardSymbol string, count uint32) ([]proto.MACBoardMemberItem, error)

func (*Client) MACBoardMembersQuotes

func (client *Client) MACBoardMembersQuotes(boardSymbol string, count uint32) ([]proto.MACBoardMemberQuoteItem, error)

func (*Client) MACBoardMembersQuotesDynamic

func (client *Client) MACBoardMembersQuotesDynamic(boardSymbol string, count uint32, sortType uint16, sortOrder uint8, fieldBitmap [20]byte) (*proto.MACBoardMembersQuotesDynamicReply, error)

MACBoardMembersQuotesDynamic 获取按位图动态解析的 MAC 板块成分报价。

func (*Client) MACBoardMembersQuotesWithSort

func (client *Client) MACBoardMembersQuotesWithSort(boardSymbol string, count uint32, sortType uint16, sortOrder uint8) ([]proto.MACBoardMemberQuoteItem, error)

MACBoardMembersQuotesWithSort 获取 MAC 板块成分报价,并透传排序参数。

func (*Client) MACBoardMembersWithSort

func (client *Client) MACBoardMembersWithSort(boardSymbol string, count uint32, sortType uint16, sortOrder uint16) ([]proto.MACBoardMemberItem, error)

MACBoardMembersWithSort 获取 MAC 板块成员,并透传排序参数。

func (*Client) MACQuotes

func (client *Client) MACQuotes(market uint8, code string) (*proto.MACQuotesReply, error)

MACQuotes 获取 MAC 行情快照与分时采样。

func (*Client) MACSymbolBars

func (client *Client) MACSymbolBars(market uint8, code string, period uint16, times uint16, start uint32, count uint32, adjust uint16) ([]proto.MACSymbolBar, error)

func (*Client) MACSymbolBelongBoard

func (client *Client) MACSymbolBelongBoard(symbol string, market uint8) ([]proto.MACBelongBoardItem, error)

func (*Client) MainClient26AC

func (client *Client) MainClient26AC() (*proto.RawDataReply, error)

func (*Client) MainClient26AD

func (client *Client) MainClient26AD() (*proto.RawDataReply, error)

func (*Client) MainClient26AE

func (client *Client) MainClient26AE() (*proto.RawDataReply, error)

func (*Client) MainClient26B1

func (client *Client) MainClient26B1() (*proto.RawDataReply, error)

func (*Client) MainClient264B

func (client *Client) MainClient264B() (*proto.RawDataReply, error)

func (*Client) MainTodoB

func (client *Client) MainTodoB() (*proto.RawDataReply, error)

func (*Client) MainTodoFDE

func (client *Client) MainTodoFDE() (*proto.RawDataReply, error)

func (*Client) ProbeHosts

func (client *Client) ProbeHosts() []HostProbeResult

ProbeHosts probes the client's configured address list and returns the results sorted by reachability and latency.

func (*Client) StockAuction

func (client *Client) StockAuction(market uint8, code string, start uint32, count uint32) ([]proto.AuctionData, error)

StockAuction 获取集合竞价数据。

func (*Client) StockBlock

func (client *Client) StockBlock(filename string) ([]BlockFlatItem, error)

func (*Client) StockChartSampling

func (client *Client) StockChartSampling(market uint8, code string) ([]float64, error)

StockChartSampling 获取分时缩略采样价格。

func (*Client) StockCount

func (client *Client) StockCount(market uint8) (uint16, error)

func (*Client) StockF10

func (client *Client) StockF10(market uint8, code string) (*CompanyInfoBundle, error)

func (*Client) StockFeature452

func (client *Client) StockFeature452(start uint32, count uint32) ([]proto.SecurityFeature452Item, error)

func (*Client) StockHistoryOrders

func (client *Client) StockHistoryOrders(date uint32, market uint8, code string) ([]proto.HistoryOrderData, error)

StockHistoryOrders 获取历史委托分布。

func (*Client) StockHistoryTickChart

func (client *Client) StockHistoryTickChart(date uint32, market uint8, code string) ([]proto.HistoryMinuteTimeData, error)

func (*Client) StockHistoryTransaction

func (client *Client) StockHistoryTransaction(date uint32, market uint8, code string, start uint16, count uint16) ([]proto.HistoryTransactionData, error)

func (*Client) StockHistoryTransactionWithTrans

func (client *Client) StockHistoryTransactionWithTrans(date uint32, market uint8, code string, start uint16, count uint16) ([]proto.HistoryTransactionDataWithTrans, error)

func (*Client) StockIndexInfo

func (client *Client) StockIndexInfo(market uint8, code string) (*proto.GetIndexInfoReply, error)

StockIndexInfo 获取指数概况。

func (*Client) StockIndexMomentum

func (client *Client) StockIndexMomentum(market uint8, code string) ([]int, error)

StockIndexMomentum 获取指数动量序列。

func (*Client) StockKLine

func (client *Client) StockKLine(category uint16, market uint8, code string, start uint16, count uint16, times uint16, adjust uint16) ([]proto.SecurityBar, error)

func (*Client) StockKLineOffset

func (client *Client) StockKLineOffset(category uint16, market uint8, code string, start uint16, count uint16, times uint16, adjust uint16) ([]proto.SecurityBar, error)

func (*Client) StockList

func (client *Client) StockList(market uint8, start uint32, count uint32) ([]proto.Security, error)

func (*Client) StockListOld

func (client *Client) StockListOld(market uint8, start uint16) ([]proto.Security, error)

func (*Client) StockQuotes

func (client *Client) StockQuotes(markets []uint8, codes []string) ([]proto.QuoteListItem, error)

func (*Client) StockQuotesDetail

func (client *Client) StockQuotesDetail(markets []uint8, codes []string) ([]proto.SecurityQuote, error)

func (*Client) StockQuotesEncrypt

func (client *Client) StockQuotesEncrypt(markets []uint8, codes []string) ([]proto.EncryptedQuoteItem, error)

func (*Client) StockQuotesList

func (client *Client) StockQuotesList(category uint8, start uint16, count uint16, sortType uint16, reverse bool, filter uint16) ([]proto.QuoteListItem, error)

func (*Client) StockTickChart

func (client *Client) StockTickChart(market uint8, code string, start uint16, count uint16) ([]proto.MinuteTimeData, error)

func (*Client) StockTopBoard

func (client *Client) StockTopBoard(category uint8, size uint8) (*proto.GetTopBoardReply, error)

StockTopBoard 获取主行情排行榜。

func (*Client) StockTransaction

func (client *Client) StockTransaction(market uint8, code string, start uint16, count uint16) ([]proto.TransactionData, error)

func (*Client) StockUnusual

func (client *Client) StockUnusual(market uint8, start uint32, count uint32) ([]proto.UnusualData, error)

StockUnusual 获取主力监控异动数据。

func (*Client) StockVolumeProfile

func (client *Client) StockVolumeProfile(market uint8, code string) (*proto.GetVolumeProfileReply, error)

StockVolumeProfile 获取成交分布与盘口快照。

type CompanyInfoBundle

type CompanyInfoBundle struct {
	Sections []CompanyInfoSection
	XDXR     []proto.XDXRItem
	Finance  *proto.GetFinanceInfoReply
}

type CompanyInfoSection

type CompanyInfoSection struct {
	Name    string
	Content string
}

type HostInfo

type HostInfo struct {
	Name string `json:"name"`
	IP   string `json:"ip"`
	Port int    `json:"port"`
}

HostInfo describes a built-in TDX server entry.

func BrokerHosts

func BrokerHosts() []HostInfo

BrokerHosts returns the built-in broker quote servers.

func ExHosts

func ExHosts() []HostInfo

ExHosts returns the built-in extended-market servers.

func MACExHosts

func MACExHosts() []HostInfo

MACExHosts returns the built-in MAC extended-market servers.

func MACHosts

func MACHosts() []HostInfo

MACHosts returns the built-in MAC quote servers.

func MainHosts

func MainHosts() []HostInfo

MainHosts returns the built-in main quote servers.

func (HostInfo) Address

func (h HostInfo) Address() string

Address returns the host:port form used by the client connection layer.

type HostProbeResult

type HostProbeResult struct {
	Name      string        `json:"name"`
	IP        string        `json:"ip"`
	Port      int           `json:"port"`
	Address   string        `json:"address"`
	Latency   time.Duration `json:"latency"`
	Reachable bool          `json:"reachable"`
	Error     string        `json:"error,omitempty"`
}

HostProbeResult records a single TCP probe result.

func FastestAddress

func FastestAddress(addresses []string, timeout time.Duration) (HostProbeResult, error)

FastestAddress returns the fastest reachable address from the supplied list.

func FastestHost

func FastestHost(hosts []HostInfo, timeout time.Duration) (HostProbeResult, error)

FastestHost returns the fastest reachable built-in host entry.

func ProbeAddresses

func ProbeAddresses(addresses []string, timeout time.Duration) []HostProbeResult

ProbeAddresses concurrently dials the supplied host:port list and returns the results sorted by reachability and latency.

func ProbeHosts

func ProbeHosts(hosts []HostInfo, timeout time.Duration) []HostProbeResult

ProbeHosts concurrently dials the supplied built-in host entries and returns the results sorted by reachability and latency.

type Option

type Option func(options *Options)

func WithAutoSelectFastest

func WithAutoSelectFastest(enabled bool) Option

WithAutoSelectFastest enables TCP probe sorting before connection attempts.

func WithExTCPAddress

func WithExTCPAddress(tcpAddress string) Option

func WithExTCPAddressPool

func WithExTCPAddressPool(ips ...string) Option

func WithMacExTCPAddress

func WithMacExTCPAddress(tcpAddress string) Option

func WithMacExTCPAddressPool

func WithMacExTCPAddressPool(ips ...string) Option

func WithMacTCPAddress

func WithMacTCPAddress(tcpAddress string) Option

func WithMacTCPAddressPool

func WithMacTCPAddressPool(ips ...string) Option

func WithTCPAddress

func WithTCPAddress(tcpAddress string) Option

func WithTCPAddressPool

func WithTCPAddressPool(ips ...string) Option

func WithTimeoutSec

func WithTimeoutSec(timeoutSec int) Option

type Options

type Options struct {
	TCPAddress          string   // 主行情服务器地址
	TCPAddressPool      []string // 主行情服务器地址池
	ExTCPAddress        string   // 扩展行情服务器地址
	ExTCPAddressPool    []string // 扩展行情服务器地址池
	MacTCPAddress       string   // MAC 主行情服务器地址
	MacTCPAddressPool   []string // MAC 主行情服务器地址池
	MacExTCPAddress     string   // MAC 扩展行情服务器地址
	MacExTCPAddressPool []string // MAC 扩展行情服务器地址池
	AutoSelectFastest   bool     // 连接前先对地址池做 TCP 测速并优先尝试低延迟节点
	MaxRetryTimes       int      // 重试次数
	TimeoutSec          int      // 连接和读写超时时间,单位秒
}

Jump to

Keyboard shortcuts

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