Help us shape the future of Go! Take the 2026 Go Developer Survey

tickflow

package module
v0.0.0-...-a8cabcf Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 9 Imported by: 0

README

TickFlow Golang SDK

GoDoc License

Go wrapper of tickflow

参考

Documentation

Overview

Package tickflow is a Go client library for the TickFlow financial data API (https://api.tickflow.org), providing access to stocks, ETFs, indices, bonds, funds, and options across US, CN, and HK markets.

All API endpoints are authenticated via the x-api-key header.

Quick start:

client, err := tickflow.NewTickFlow(&tickflow.Config{
    ApiKey: "your-api-key",
})
if err != nil {
    log.Fatal(err)
}

quotes, err := client.GetQuote(ctx, &tickflow.GetQuoteReq{
    Symbols: "AAPL.US,600000.SH",
})

Index

Constants

View Source
const (

	// MaxBatchSymbols is the maximum number of symbols allowed in a single batch request.
	MaxBatchSymbols = 1000
)

Variables

View Source
var (
	// ErrNilReq is returned when a nil request struct is passed to an API method.
	ErrNilReq = errors.New("nil req")
	// ErrNilConfig is returned when a nil config struct is passed to an API method.
	ErrNilConfig = errors.New("nil config")
	// ErrEmptyKey is returned when an empty API key is provided to NewTickFlow.
	ErrEmptyKey = errors.New("empty key")
	// ErrInvalidExchange is returned when an exchange code is not one of the supported values.
	ErrInvalidExchange = errors.New("invalid exchange, must be one of: US, SH, SZ, BJ, HK")
	// ErrEmptyID is returned when an empty ID is passed to an API method that requires one.
	ErrEmptyID = errors.New("id must not be empty")
	// ErrEmptySymbol is returned when an empty symbol is passed to an API method that requires one.
	ErrEmptySymbol = errors.New("symbol must not be empty")
	// ErrEmptySymbols is returned when an empty symbols list is passed to an API method that requires at least one.
	ErrEmptySymbols = errors.New("symbols must not be empty")
	// ErrTooManySymbols is returned when the number of symbols exceeds MaxBatchSymbols.
	ErrTooManySymbols = errors.New("symbols must not exceed 1000")
)
View Source
var ErrKlineDataLengthMismatch = errors.New("kline data length mismatch")

ErrKlineDataLengthMismatch 表示 CompactKlineData 中各字段切片长度不一致。

Functions

This section is empty.

Types

type AdjustType

type AdjustType string

AdjustType represents the price adjustment type used for K-line data.

const (
	AdjustTypeForward          AdjustType = "forward"
	AdjustTypeBackward         AdjustType = "backward"
	AdjustTypeForwardAdditive  AdjustType = "forward_additive"
	AdjustTypeBackwardAdditive AdjustType = "backward_additive"
	AdjustTypeNone             AdjustType = "none"
)

type ApiError

type ApiError struct {
	Code    string `json:"code"`    // 错误码
	Message string `json:"message"` // 错误描述
	Details string `json:"details"` // 可选调试信息
}

ApiError represents an error returned by the TickFlow API.

func (*ApiError) Error

func (e *ApiError) Error() string

Error implements the error interface.

type BalanceSheetRecord

type BalanceSheetRecord struct {
	PeriodEnd                  string  `json:"period_end"`                    // 报告期末日期 (YYYY-MM-DD)
	AnnounceDate               string  `json:"announce_date"`                 // 公告日期 (YYYY-MM-DD)
	TotalAssets                float64 `json:"total_assets"`                  // 资产总计
	TotalCurrentAssets         float64 `json:"total_current_assets"`          // 流动资产合计
	TotalNonCurrentAssets      float64 `json:"total_non_current_assets"`      // 非流动资产合计
	CashAndEquivalents         float64 `json:"cash_and_equivalents"`          // 货币资金
	AccountsReceivable         float64 `json:"accounts_receivable"`           // 应收账款
	Inventory                  float64 `json:"inventory"`                     // 存货
	FixedAssets                float64 `json:"fixed_assets"`                  // 固定资产
	IntangibleAssets           float64 `json:"intangible_assets"`             // 无形资产
	Goodwill                   float64 `json:"goodwill"`                      // 商誉
	TotalLiabilities           float64 `json:"total_liabilities"`             // 负债合计
	TotalCurrentLiabilities    float64 `json:"total_current_liabilities"`     // 流动负债合计
	TotalNonCurrentLiabilities float64 `json:"total_non_current_liabilities"` // 非流动负债合计
	AccountsPayable            float64 `json:"accounts_payable"`              // 应付账款
	ShortTermBorrowing         float64 `json:"short_term_borrowing"`          // 短期借款
	LongTermBorrowing          float64 `json:"long_term_borrowing"`           // 长期借款
	TotalEquity                float64 `json:"total_equity"`                  // 所有者权益合计
	EquityAttributable         float64 `json:"equity_attributable"`           // 归属于母公司股东权益
	MinorityInterest           float64 `json:"minority_interest"`             // 少数股东权益
	RetainedEarnings           float64 `json:"retained_earnings"`             // 未分配利润
}

BalanceSheetRecord represents a single-period balance sheet record.

type BatchGetDepthReq

type BatchGetDepthReq struct {
	Symbols string `json:"symbols"` // 逗号分隔的标的代码,例如 "600000.SH,000001.SZ"
	Free    bool   `json:"-"`       // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

BatchGetDepthReq is the request parameters for BatchGetDepth.

type BatchGetDepthResp

type BatchGetDepthResp struct {
	Data map[string]*MarketDepth `json:"data"` // key 为标的代码
}

BatchGetDepthResp is the response from BatchGetDepth.

type BatchGetInstrumentMetaDataReq

type BatchGetInstrumentMetaDataReq struct {
	Symbols []string `json:"symbols"` // 标的代码列表,最多 1000 个
	Free    bool     `json:"-"`       // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

BatchGetInstrumentMetaDataReq is the request parameters for BatchGetInstrumentMetaData.

type BatchGetInstrumentMetaDataResp

type BatchGetInstrumentMetaDataResp struct {
	Data []Instrument `json:"data"` // 标的元数据列表
}

BatchGetInstrumentMetaDataResp is the response from BatchGetInstrumentMetaData.

type BatchGetKlineReq

type BatchGetKlineReq struct {
	Symbols   string     `json:"symbols"`              // 标的代码,逗号分隔, 例如 "600000.SH,000001.SZ"
	Period    Period     `json:"period,omitempty"`     // K线周期
	Count     int        `json:"count,omitempty"`      // 返回的K线数量 (默认100, 最大10000)
	StartTime int64      `json:"start_time,omitempty"` // 开始时间(毫秒时间戳)
	EndTime   int64      `json:"end_time,omitempty"`   // 结束时间(毫秒时间戳)
	Adjust    AdjustType `json:"adjust,omitempty"`     // 复权类型
	Free      bool       `json:"-"`                    // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

BatchGetKlineReq is the request parameters for BatchGetKline.

type BatchGetKlineResp

type BatchGetKlineResp struct {
	Data map[string]*CompactKlineData `json:"data"` // key 为标的代码,value 为紧凑列式K线数据
}

BatchGetKlineResp is the response from BatchGetKline.

func (*BatchGetKlineResp) ToKlines

func (r *BatchGetKlineResp) ToKlines() ([]*SymbolKline, error)

ToKlines 将 BatchGetKlineResp 中的列式数据转换为平铺的 SymbolKline 指针切片。 每个 SymbolKline 内的 Klines 按时间戳升序排列。 若接收者为 nil 或数据为空,返回 nil, nil。 若某个 symbol 的字段切片长度不一致,返回 ErrKlineDataLengthMismatch 错误。

type BatchGetQuoteReq

type BatchGetQuoteReq struct {
	Symbols   []string `json:"symbols"`   // 标的代码列表,例如 ["600000.SH", "000001.SZ", "AAPL.US"]
	Universes []string `json:"universes"` // 标的池 ID 列表,例如 ["CN_Equity_A", "CN_ETF"]
	Free      bool     `json:"-"`         // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

BatchGetQuoteReq is the request parameters for BatchGetQuote.

type BatchGetQuoteResp

type BatchGetQuoteResp struct {
	Data []Quote `json:"data"` // 行情数据列表
}

BatchGetQuoteResp is the response from BatchGetQuote.

type BatchGetUniverseReq

type BatchGetUniverseReq struct {
	IDs  []string `json:"ids"` // 标的池 ID 列表,例如 ["CN_Equity_A", "CN_ETF"]
	Free bool     `json:"-"`   // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

BatchGetUniverseReq is the request parameters for BatchGetUniverse.

type BatchGetUniverseResp

type BatchGetUniverseResp struct {
	Data map[string]*UniverseDetail `json:"data"` // key 为标的池 ID
}

BatchGetUniverseResp is the response from BatchGetUniverse.

type CashFlowRecord

type CashFlowRecord struct {
	PeriodEnd            string  `json:"period_end"`              // 报告期末日期 (YYYY-MM-DD)
	AnnounceDate         string  `json:"announce_date"`           // 公告日期 (YYYY-MM-DD)
	NetOperatingCashFlow float64 `json:"net_operating_cash_flow"` // 经营活动现金流量净额
	NetInvestingCashFlow float64 `json:"net_investing_cash_flow"` // 投资活动现金流量净额
	NetFinancingCashFlow float64 `json:"net_financing_cash_flow"` // 筹资活动现金流量净额
	Capex                float64 `json:"capex"`                   // 资本支出
	NetCashChange        float64 `json:"net_cash_change"`         // 现金及现金等价物净增加额
}

CashFlowRecord represents a single-period cash flow record.

type CompactKlineData

type CompactKlineData struct {
	Timestamp       []int64   `json:"timestamp"`        // 时间戳 (毫秒)
	Open            []float64 `json:"open"`             // 开盘价
	High            []float64 `json:"high"`             // 最高价
	Low             []float64 `json:"low"`              // 最低价
	Close           []float64 `json:"close"`            // 收盘价
	Volume          []int64   `json:"volume"`           // 成交量
	Amount          []float64 `json:"amount"`           // 成交额
	PrevClose       []float64 `json:"prev_close"`       // 前收盘价 (可选)
	OpenInterest    []float64 `json:"open_interest"`    // 持仓量 (可选)
	SettlementPrice []float64 `json:"settlement_price"` // 结算价 (可选)
}

CompactKlineData is a columnar (parallel-slice) representation of K-line data for efficient transfer. Each field is a slice where index i corresponds to bar i.

func (*CompactKlineData) ToKlines

func (c *CompactKlineData) ToKlines() ([]*Kline, error)

ToKlines 将紧凑列式 K 线数据转换为按时间戳升序排列的 Kline 指针切片。 若接收者为 nil 或数据为空,返回 nil, nil。 可选字段 (PrevClose / OpenInterest / SettlementPrice) 若存在则填充,否则为零值。 若必填字段的切片长度不一致,返回 ErrKlineDataLengthMismatch 错误。

type Config

type Config struct {
	ApiKey string // http 鉴权key
}

Config NewTickFlow 相关配置

type ExFactorEntry

type ExFactorEntry struct {
	Timestamp int64   `json:"timestamp"` // 除权日时间戳 (毫秒)
	ExFactor  float64 `json:"ex_factor"` // 除权因子
}

ExFactorEntry represents a single ex-factor (dividend/split adjustment) record.

type ExchangeInfo

type ExchangeInfo struct {
	Exchange string `json:"exchange"` // 交易所代码
	Region   string `json:"region"`   // 所属地区
	Count    int    `json:"count"`    // 标的数量
}

ExchangeInfo is a summary of an exchange.

type FinancialReq

type FinancialReq struct {
	Symbols   string `json:"symbols"`              // 逗号分隔的标的代码,如 "600519.SH,000001.SZ"
	StartDate string `json:"start_date,omitempty"` // 起始日期(可选,YYYY-MM-DD),筛选 period_end >= start_date
	EndDate   string `json:"end_date,omitempty"`   // 截止日期(可选,YYYY-MM-DD),筛选 period_end <= end_date
	Latest    bool   `json:"latest,omitempty"`     // 仅返回最新一期(默认 false)
	Free      bool   `json:"-"`                    // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

FinancialReq contains the common request parameters for financial statement queries.

type GetBalanceSheetResp

type GetBalanceSheetResp struct {
	Data map[string][]BalanceSheetRecord `json:"data"` // key 为标的代码
}

GetBalanceSheetResp is the response from GetBalanceSheet.

type GetCashFlowResp

type GetCashFlowResp struct {
	Data map[string][]CashFlowRecord `json:"data"` // key 为标的代码
}

GetCashFlowResp is the response from GetCashFlow.

type GetDepthReq

type GetDepthReq struct {
	Symbol string `json:"symbol"` // 标的代码,例如 "600000.SH"
	Free   bool   `json:"-"`      // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetDepthReq is the request parameters for GetDepth.

type GetDepthResp

type GetDepthResp struct {
	Data *MarketDepth `json:"data"` // 市场深度
}

GetDepthResp is the response from GetDepth.

type GetExFactorReq

type GetExFactorReq struct {
	Symbols   string `json:"symbols"`              // 逗号分隔的标的代码, 例如 "600519.SH,000001.SZ"
	StartTime int64  `json:"start_time,omitempty"` // 开始时间(毫秒时间戳)
	EndTime   int64  `json:"end_time,omitempty"`   // 结束时间(毫秒时间戳)
	Free      bool   `json:"-"`                    // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetExFactorReq is the request parameters for GetExFactor.

type GetExFactorResp

type GetExFactorResp struct {
	Data map[string][]ExFactorEntry `json:"data"` // key 为标的代码,value 为除权因子列表
}

GetExFactorResp is the response from GetExFactor.

type GetExchangeInstrumentReq

type GetExchangeInstrumentReq struct {
	Exchange string `json:"Exchange"` // 交易所名称
	Type     string `json:"type"`     // 标的类型
	Free     bool   `json:"-"`        // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetExchangeInstrumentReq is the request parameters for GetExchangeInstrument.

type GetExchangeInstrumentResp

type GetExchangeInstrumentResp struct {
	Exchange string        `json:"exchange"` // 交易所代码
	Count    int           `json:"count"`    // 标的数量
	Data     []*Instrument `json:"data"`     // 标的列表
}

GetExchangeInstrumentResp is the response from GetExchangeInstrument.

type GetExchangeReq

type GetExchangeReq struct {
	Free bool `json:"-"` // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetExchangeReq is the request parameters for GetExchange.

type GetExchangeResp

type GetExchangeResp struct {
	Data []ExchangeInfo `json:"data"` // 交易所列表
}

GetExchangeResp is the response from GetExchange.

type GetIncomeResp

type GetIncomeResp struct {
	Data map[string][]IncomeRecord `json:"data"` // key 为标的代码
}

GetIncomeResp is the response from GetIncome.

type GetInstrumentMetaDataReq

type GetInstrumentMetaDataReq struct {
	Symbols string `json:"symbols"` // 标的代码 "TSLA.US,600036.SH"
	Free    bool   `json:"-"`       // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetInstrumentMetaDataReq is the request parameters for GetInstrumentMetaData.

type GetInstrumentMetaDataResp

type GetInstrumentMetaDataResp struct {
	Exchange string       `json:"exchange"` // 交易所代码
	Count    int          `json:"count"`    // 标的数量
	Data     []Instrument `json:"data"`     // 标的列表
}

GetInstrumentMetaDataResp is the response from GetInstrumentMetaData.

type GetKlineReq

type GetKlineReq struct {
	Symbol    string     `json:"symbol"`               // 标的代码, 例如 "600000.SH"`
	Period    Period     `json:"period,omitempty"`     // K线周期
	Count     int        `json:"count,omitempty"`      // 返回的K线数量 (默认100, 最大10000)
	StartTime int64      `json:"start_time,omitempty"` // 开始时间(毫秒时间戳)
	EndTime   int64      `json:"end_time,omitempty"`   // 结束时间(毫秒时间戳)
	Adjust    AdjustType `json:"adjust,omitempty"`     // 复权类型
	Free      bool       `json:"-"`                    // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetKlineReq is the request parameters for GetKline.

type GetKlineResp

type GetKlineResp struct {
	Data *CompactKlineData `json:"data"` // 紧凑列式K线数据
}

GetKlineResp is the response from GetKline.

type GetMetricsResp

type GetMetricsResp struct {
	Data map[string][]MetricsRecord `json:"data"` // key 为标的代码
}

GetMetricsResp is the response from GetMetrics.

type GetQuoteReq

type GetQuoteReq struct {
	Symbols   string `json:"symbols"`   // 标的代码,逗号分隔,例如 "600000.SH,000001.SZ"
	Universes string `json:"universes"` // 标的池 ID,逗号分隔,例如 "CN_Equity_A,CN_ETF"
	Free      bool   `json:"-"`         // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetQuoteReq is the request parameters for GetQuote.

type GetQuoteResp

type GetQuoteResp struct {
	Data []Quote `json:"data"` // 行情数据列表
}

GetQuoteResp is the response from GetQuote.

type GetShareResp

type GetShareResp struct {
	Data map[string][]SharesRecord `json:"data"` // key 为标的代码
}

GetShareResp is the response from GetShare.

type GetUniverseDetailReq

type GetUniverseDetailReq struct {
	ID   string `json:"-"` // 标的池 ID,例如 "CN_Equity_A"
	Free bool   `json:"-"` // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetUniverseDetailReq is the request parameters for GetUniverseDetail.

type GetUniverseDetailResp

type GetUniverseDetailResp struct {
	Data *UniverseDetail `json:"data"` // 标的池详情
}

GetUniverseDetailResp is the response from GetUniverseDetail.

type GetUniverseReq

type GetUniverseReq struct {
	Free bool `json:"-"` // 是否使用免费接口,true 时使用 free-api.tickflow.org
}

GetUniverseReq is the request parameters for GetUniverse.

type GetUniverseResp

type GetUniverseResp struct {
	Data []UniverseSummary `json:"data"` // 标的池摘要列表
}

GetUniverseResp is the response from GetUniverse.

type IncomeRecord

type IncomeRecord struct {
	PeriodEnd             string  `json:"period_end"`              // 报告期末日期 (YYYY-MM-DD)
	AnnounceDate          string  `json:"announce_date"`           // 公告日期 (YYYY-MM-DD)
	Revenue               float64 `json:"revenue"`                 // 营业总收入
	OperatingCost         float64 `json:"operating_cost"`          // 营业总成本
	OperatingProfit       float64 `json:"operating_profit"`        // 营业利润
	TotalProfit           float64 `json:"total_profit"`            // 利润总额
	NetIncome             float64 `json:"net_income"`              // 净利润
	NetIncomeAttributable float64 `json:"net_income_attributable"` // 归属于母公司股东的净利润
	NetIncomeDeducted     float64 `json:"net_income_deducted"`     // 扣除非经常性损益后的净利润
	BasicEPS              float64 `json:"basic_eps"`               // 基本每股收益
	DilutedEPS            float64 `json:"diluted_eps"`             // 稀释每股收益
	SellingExpense        float64 `json:"selling_expense"`         // 销售费用
	AdminExpense          float64 `json:"admin_expense"`           // 管理费用
	FinancialExpense      float64 `json:"financial_expense"`       // 财务费用
	RDExpense             float64 `json:"rd_expense"`              // 研发费用
	IncomeTax             float64 `json:"income_tax"`              // 所得税费用
	NonOperatingIncome    float64 `json:"non_operating_income"`    // 营业外收入
	NonOperatingExpense   float64 `json:"non_operating_expense"`   // 营业外支出
}

IncomeRecord represents a single-period income statement record.

type Instrument

type Instrument struct {
	Symbol   string         `json:"symbol"`   // e.g. "600000.SH", "AAPL.US"
	Exchange string         `json:"exchange"` // e.g. "SH", "US"
	Code     string         `json:"code"`     // 交易所原生代码 e.g. "600000", "AAPL"
	Region   string         `json:"region"`   // 地区: CN, US, HK
	Name     string         `json:"name"`     // 可读名称
	Type     InstrumentType `json:"type"`     // 标的类型
	Ext      *InstrumentExt `json:"ext"`      // 市场特定扩展字段
}

Instrument represents a financial instrument listed on an exchange.

type InstrumentExt

type InstrumentExt struct {
	Type        string  `json:"type,omitempty"`         // cn_equity / us_equity / hk_equity
	ListingDate string  `json:"listing_date,omitempty"` // 上市日期 (cn_equity)
	FloatShares float64 `json:"float_shares,omitempty"` // 流通股本
	TotalShares float64 `json:"total_shares,omitempty"` // 总股本
	TickSize    float64 `json:"tick_size,omitempty"`    // 最小变动价位 (cn_equity)
	LimitUp     float64 `json:"limit_up,omitempty"`     // 涨停价 (cn_equity)
	LimitDown   float64 `json:"limit_down,omitempty"`   // 跌停价 (cn_equity)
	NameEn      string  `json:"name_en,omitempty"`      // 英文名 (cn_equity)
	LotSize     int     `json:"lot_size,omitempty"`     // 每手股数 (hk_equity)
}

InstrumentExt contains market-specific extension fields for an instrument.

type InstrumentType

type InstrumentType string

InstrumentType represents the type of a financial instrument.

const (
	// InstrumentTypeStock represents a stock (equity).
	InstrumentTypeStock InstrumentType = "stock"
	// InstrumentTypeETF represents an exchange-traded fund.
	InstrumentTypeETF InstrumentType = "etf"
	// InstrumentTypeIndex represents a market index.
	InstrumentTypeIndex InstrumentType = "index"
	// InstrumentTypeBond represents a bond.
	InstrumentTypeBond InstrumentType = "bond"
	// InstrumentTypeFund represents a mutual fund.
	InstrumentTypeFund InstrumentType = "fund"
	// InstrumentTypeOptions represents options contracts.
	InstrumentTypeOptions InstrumentType = "options"
	// InstrumentTypeOther represents an instrument that does not fit the other categories.
	InstrumentTypeOther InstrumentType = "other"
)

type Kline

type Kline struct {
	Timestamp       int64   `json:"timestamp"`        // 时间戳 (毫秒)
	Open            float64 `json:"open"`             // 开盘价
	High            float64 `json:"high"`             // 最高价
	Low             float64 `json:"low"`              // 最低价
	Close           float64 `json:"close"`            // 收盘价
	Volume          int64   `json:"volume"`           // 成交量
	Amount          float64 `json:"amount"`           // 成交额
	PrevClose       float64 `json:"prev_close"`       // 前收盘价 (可选)
	OpenInterest    float64 `json:"open_interest"`    // 持仓量 (可选)
	SettlementPrice float64 `json:"settlement_price"` // 结算价 (可选)
}

Kline represents a single K-line (candlestick) data point with OHLCV and optional fields.

type MarketDepth

type MarketDepth struct {
	Symbol     string    `json:"symbol"`      // 标的代码
	Timestamp  int64     `json:"timestamp"`   // 时间戳 (毫秒)
	BidPrices  []float64 `json:"bid_prices"`  // 买入价 (买1-买5,降序)
	BidVolumes []int64   `json:"bid_volumes"` // 买入量
	AskPrices  []float64 `json:"ask_prices"`  // 卖出价 (卖1-卖5,升序)
	AskVolumes []int64   `json:"ask_volumes"` // 卖出量
	Region     Region    `json:"region"`      // 地区
}

MarketDepth represents market depth (level 1, five-level bid/ask) data.

type MetricsRecord

type MetricsRecord struct {
	PeriodEnd              string  `json:"period_end"`                // 报告期末日期 (YYYY-MM-DD)
	AnnounceDate           string  `json:"announce_date"`             // 公告日期 (YYYY-MM-DD)
	BPS                    float64 `json:"bps"`                       // 每股净资产
	EPSBasic               float64 `json:"eps_basic"`                 // 基本每股收益
	EPSDiluted             float64 `json:"eps_diluted"`               // 稀释每股收益
	OCFPS                  float64 `json:"ocfps"`                     // 每股经营现金流
	ROE                    float64 `json:"roe"`                       // 净资产收益率
	ROEDiluted             float64 `json:"roe_diluted"`               // 摊薄净资产收益率
	ROA                    float64 `json:"roa"`                       // 总资产收益率
	GrossMargin            float64 `json:"gross_margin"`              // 毛利率
	NetMargin              float64 `json:"net_margin"`                // 净利率
	RevenueYoY             float64 `json:"revenue_yoy"`               // 营收同比增长率
	NetIncomeYoY           float64 `json:"net_income_yoy"`            // 净利润同比增长率
	DebtToAssetRatio       float64 `json:"debt_to_asset_ratio"`       // 资产负债率
	InventoryTurnover      float64 `json:"inventory_turnover"`        // 存货周转率
	OperatingCashToRevenue float64 `json:"operating_cash_to_revenue"` // 销售现金比率
}

MetricsRecord represents a single-period metrics record covering per-share data, profitability, growth, and solvency.

type Period

type Period string

Period represents the time interval of a K-line (candlestick) bar.

const (
	Period1m  Period = "1m"
	Period5m  Period = "5m"
	Period10m Period = "10m"
	Period15m Period = "15m"
	Period30m Period = "30m"
	Period60m Period = "60m"
	Period1d  Period = "1d"
	Period1w  Period = "1w"
	Period1M  Period = "1M"
	Period1Q  Period = "1Q"
	Period1Y  Period = "1Y"
)

type Quote

type Quote struct {
	Symbol    string          `json:"symbol"`     // 标的代码
	Timestamp int64           `json:"timestamp"`  // 时间戳 (毫秒)
	LastPrice float64         `json:"last_price"` // 最新价
	Open      float64         `json:"open"`       // 开盘价
	High      float64         `json:"high"`       // 最高价
	Low       float64         `json:"low"`        // 最低价
	PrevClose float64         `json:"prev_close"` // 昨收价
	Volume    int64           `json:"volume"`     // 成交量
	Amount    float64         `json:"amount"`     // 成交额
	Region    Region          `json:"region"`     // 地区
	Session   SessionStatus   `json:"session"`    // 交易时段
	Ext       *QuoteExtension `json:"ext"`        // 扩展数据
}

Quote represents a real-time market quote for an instrument.

type QuoteExtension

type QuoteExtension struct {
	Type string `json:"type"` // 市场类型标签
}

QuoteExtension contains region-specific extension data for a quote.

type Region

type Region string

Region represents a supported geographic market.

const (
	RegionCN Region = "CN"
	RegionUS Region = "US"
	RegionHK Region = "HK"
)

type SessionStatus

type SessionStatus string

SessionStatus represents the current trading session status of a market.

const (
	SessionPreMarket  SessionStatus = "pre_market"
	SessionRegular    SessionStatus = "regular"
	SessionAfterHours SessionStatus = "after_hours"
	SessionClosed     SessionStatus = "closed"
	SessionHalted     SessionStatus = "halted"
	SessionLunchBreak SessionStatus = "lunch_break"
)

type SharesRecord

type SharesRecord struct {
	PeriodEnd    string  `json:"period_end"`    // 报告期末日期 (YYYY-MM-DD)
	AnnounceDate string  `json:"announce_date"` // 公告日期 (YYYY-MM-DD)
	TotalShares  float64 `json:"total_shares"`  // 总股本
	FloatShares  float64 `json:"float_shares"`  // 流通股本
}

SharesRecord represents a single-period share structure record.

type SymbolKline

type SymbolKline struct {
	Symbol string   // 标的代码,例如 "600000.SH"
	Klines []*Kline // 按时间戳升序排列的 K 线数据
}

SymbolKline 携带标的代码及其对应的 K 线数据。

type TickFlow

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

TickFlow is a client for the TickFlow financial data API.

func NewTickFlow

func NewTickFlow(cfg *Config) (*TickFlow, error)

NewTickFlow creates a new TickFlow client with the given API key. The key is used to authenticate requests via the x-api-key header.

func (*TickFlow) BatchGetDepth

func (tf *TickFlow) BatchGetDepth(ctx context.Context, req *BatchGetDepthReq) (resp *BatchGetDepthResp, err error)

BatchGetDepth returns market depth (five-level bid/ask) for multiple symbols.

symbols is required, comma-separated, e.g. "600000.SH,000001.SZ".

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%EF%BC%88%E4%BA%94%E6%A1%A3%E8%A1%8C%E6%83%85%EF%BC%89

func (*TickFlow) BatchGetInstrumentMetaData

func (tf *TickFlow) BatchGetInstrumentMetaData(ctx context.Context, req *BatchGetInstrumentMetaDataReq) (resp *BatchGetInstrumentMetaDataResp, err error)

BatchGetInstrumentMetaData returns metadata for a batch of instrument symbols. The symbols slice must contain at least one symbol and at most MaxBatchSymbols.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E6%A0%87%E7%9A%84/%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E6%A0%87%E7%9A%84%E5%85%83%E6%95%B0%E6%8D%AE

func (*TickFlow) BatchGetKline

func (tf *TickFlow) BatchGetKline(ctx context.Context, req *BatchGetKlineReq) (resp *BatchGetKlineResp, err error)

BatchGetKline returns K-line data for multiple symbols in a single request.

symbols is required, comma-separated, e.g. "600000.SH,000001.SZ". period is optional; valid values: 1m, 5m, 10m, 15m, 30m, 60m, 1d, 1w, 1M, 1Q, 1Y. count is optional; default 100, maximum 10000. start_time / end_time are optional millisecond timestamps. adjust is optional: forward, backward, forward_additive, backward_additive, none.

api-url: https://docs.tickflow.org/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2-k%E7%BA%BF%E6%95%B0%E6%8D%AE

func (*TickFlow) BatchGetQuote

func (tf *TickFlow) BatchGetQuote(ctx context.Context, req *BatchGetQuoteReq) (resp *BatchGetQuoteResp, err error)

BatchGetQuote returns real-time quotes for a batch of symbols or universes.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85

func (*TickFlow) BatchGetUniverse

func (tf *TickFlow) BatchGetUniverse(ctx context.Context, req *BatchGetUniverseReq) (resp *BatchGetUniverseResp, err error)

BatchGetUniverse returns detailed information for a batch of universes.

ids is the list of universe IDs, e.g. ["CN_Equity_A", "CN_ETF"].

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E6%A0%87%E7%9A%84%E6%B1%A0/%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E6%A0%87%E7%9A%84%E6%B1%A0%E8%AF%A6%E6%83%85

func (*TickFlow) GetBalanceSheet

func (tf *TickFlow) GetBalanceSheet(ctx context.Context, req *FinancialReq) (resp *GetBalanceSheetResp, err error)

GetBalanceSheet returns balance sheet data for one or more symbols.

symbols is required, comma-separated, e.g. "600519.SH,000001.SZ". start_date / end_date are optional, YYYY-MM-DD. latest is optional; when true, only the most recent period is returned.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E8%B4%A2%E5%8A%A1%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%E8%B5%84%E4%BA%A7%E8%B4%9F%E5%80%BA%E8%A1%A8

func (*TickFlow) GetCashFlow

func (tf *TickFlow) GetCashFlow(ctx context.Context, req *FinancialReq) (resp *GetCashFlowResp, err error)

GetCashFlow returns cash flow statement data for one or more symbols.

symbols is required, comma-separated, e.g. "600519.SH,000001.SZ". start_date / end_date are optional, YYYY-MM-DD. latest is optional; when true, only the most recent period is returned.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E8%B4%A2%E5%8A%A1%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%E7%8E%B0%E9%87%91%E6%B5%81%E9%87%8F%E8%A1%A8

func (*TickFlow) GetDepth

func (tf *TickFlow) GetDepth(ctx context.Context, req *GetDepthReq) (resp *GetDepthResp, err error)

GetDepth returns market depth (five-level bid/ask) for a single symbol.

symbol is required, e.g. "600000.SH".

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%9F%A5%E8%AF%A2%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%EF%BC%88%E4%BA%94%E6%A1%A3%E8%A1%8C%E6%83%85%EF%BC%89

func (*TickFlow) GetExFactor

func (tf *TickFlow) GetExFactor(ctx context.Context, req *GetExFactorReq) (resp *GetExFactorResp, err error)

GetExFactor returns ex-factor (dividend/split adjustment) data for one or more symbols.

symbols is required, comma-separated, e.g. "600519.SH,000001.SZ". start_time / end_time are optional millisecond timestamps.

api-url: https://docs.tickflow.org/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%E9%99%A4%E6%9D%83%E5%9B%A0%E5%AD%90

func (*TickFlow) GetExchangeInstrument

func (tf *TickFlow) GetExchangeInstrument(ctx context.Context, req *GetExchangeInstrumentReq) (resp *GetExchangeInstrumentResp, err error)

GetExchangeInstrument returns the list of instruments for a given exchange.

exchange must be one of: US, SH, SZ, BJ, HK. instrumentType is optional; pass an empty string to return all types.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E4%BA%A4%E6%98%93%E6%89%80/%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E6%89%80%E7%9A%84%E6%A0%87%E7%9A%84%E5%88%97%E8%A1%A8

func (*TickFlow) GetIncome

func (tf *TickFlow) GetIncome(ctx context.Context, req *FinancialReq) (resp *GetIncomeResp, err error)

GetIncome returns income statement data for one or more symbols.

symbols is required, comma-separated, e.g. "600519.SH,000001.SZ". start_date / end_date are optional, YYYY-MM-DD. latest is optional; when true, only the most recent period is returned.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E8%B4%A2%E5%8A%A1%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%E5%88%A9%E6%B6%A6%E8%A1%A8

func (*TickFlow) GetInstrumentMetaData

func (tf *TickFlow) GetInstrumentMetaData(ctx context.Context, req *GetInstrumentMetaDataReq) (resp *GetInstrumentMetaDataResp, err error)

GetInstrumentMetaData returns metadata for one or more instruments specified by symbol.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E6%A0%87%E7%9A%84/%E6%9F%A5%E8%AF%A2%E6%A0%87%E7%9A%84%E5%85%83%E6%95%B0%E6%8D%AE

func (*TickFlow) GetKline

func (tf *TickFlow) GetKline(ctx context.Context, req *GetKlineReq) (resp *GetKlineResp, err error)

GetKline returns K-line (candlestick) data for a single symbol.

symbol is required, e.g. "600000.SH", "AAPL.US". period is optional; valid values: 1m, 5m, 10m, 15m, 30m, 60m, 1d, 1w, 1M, 1Q, 1Y. count is optional; default 100, maximum 10000. start_time / end_time are optional millisecond timestamps. adjust is optional: forward, backward, forward_additive, backward_additive, none.

api-url: https://docs.tickflow.org/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2-k%E7%BA%BF%E6%95%B0%E6%8D%AE

func (*TickFlow) GetMetrics

func (tf *TickFlow) GetMetrics(ctx context.Context, req *FinancialReq) (resp *GetMetricsResp, err error)

GetMetrics returns core financial metrics for one or more symbols.

symbols is required, comma-separated, e.g. "600519.SH,000001.SZ". start_date / end_date are optional, YYYY-MM-DD. latest is optional; when true, only the most recent period is returned.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E8%B4%A2%E5%8A%A1%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%E6%A0%B8%E5%BF%83%E8%B4%A2%E5%8A%A1%E6%8C%87%E6%A0%87

func (*TickFlow) GetQuote

func (tf *TickFlow) GetQuote(ctx context.Context, req *GetQuoteReq) (resp *GetQuoteResp, err error)

GetQuote returns real-time quotes. Either symbols or universes may be provided.

symbols is optional, comma-separated, e.g. "600000.SH,000001.SZ". universes is optional, comma-separated, e.g. "CN_Equity_A,CN_ETF".

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%9F%A5%E8%AF%A2%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85

func (*TickFlow) GetShare

func (tf *TickFlow) GetShare(ctx context.Context, req *FinancialReq) (resp *GetShareResp, err error)

GetShare returns share structure data for one or more symbols.

symbols is required, comma-separated, e.g. "600519.SH,000001.SZ". start_date / end_date are optional, YYYY-MM-DD. latest is optional; when true, only the most recent period is returned.

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E8%B4%A2%E5%8A%A1%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%E8%82%A1%E6%9C%AC%E8%A1%A8

func (*TickFlow) GetUniverse

func (tf *TickFlow) GetUniverse(ctx context.Context, req *GetUniverseReq) (resp *GetUniverseResp, err error)

GetUniverse returns the list of available universes (symbol groups).

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E6%A0%87%E7%9A%84%E6%B1%A0/%E8%8E%B7%E5%8F%96%E6%A0%87%E7%9A%84%E6%B1%A0%E5%88%97%E8%A1%A8

func (*TickFlow) GetUniverseDetail

func (tf *TickFlow) GetUniverseDetail(ctx context.Context, req *GetUniverseDetailReq) (resp *GetUniverseDetailResp, err error)

GetUniverseDetail returns detailed information for a single universe.

id is the universe ID, e.g. "CN_Equity_A".

api-url: https://docs.tickflow.org/zh-hans/api-reference/%E6%A0%87%E7%9A%84%E6%B1%A0/%E8%8E%B7%E5%8F%96%E6%A0%87%E7%9A%84%E6%B1%A0%E8%AF%A6%E6%83%85

type UniverseDetail

type UniverseDetail struct {
	UniverseSummary
	Symbols []string `json:"symbols"` // 标的列表
}

UniverseDetail is the full detail of a universe, including its symbol list.

type UniverseSummary

type UniverseSummary struct {
	ID          string `json:"id"`           // 唯一标识符
	Name        string `json:"name"`         // 显示名称
	Category    string `json:"category"`     // 分类
	Region      string `json:"region"`       // 地区代码
	SymbolCount int    `json:"symbol_count"` // 标的数量
	Description string `json:"description"`  // 描述
}

UniverseSummary is a summary of a universe (symbol group) used for list views.

Jump to

Keyboard shortcuts

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