extend

package
v0.0.77 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Minute   = "minute"
	Minute5  = "5minute"
	Minute15 = "15minute"
	Minute30 = "30minute"
	Minute60 = "60minute"
	Day      = "day"
	Week     = "week"
	Month    = "month"
	Quarter  = "quarter"
	Year     = "year"

	TableMinute   = "MinuteKline"
	Table5Minute  = "Minute5Kline"
	Table15Minute = "Minute15Kline"
	Table30Minute = "Minute30Kline"
	Table60Minute = "Minute60Kline"
	TableDay      = "DayKline"
	TableWeek     = "WeekKline"
	TableMonth    = "MonthKline"
	TableQuarter  = "QuarterKline"
	TableYear     = "YearKline"
)
View Source
const (
	UrlSinaFactorHfq = "https://finance.sina.com.cn/realstock/company/%s/hfq.js"
	UrlSinaFactorQfq = "https://finance.sina.com.cn/realstock/company/%s/qfq.js"
	Sina_QFQ         = "qfq"
	Sina_HFQ         = "hfq"
)
View Source
const (
	UrlTHSDayKline       = "http://d.10jqka.com.cn/v6/line/hs_%s/0%d/all.js"
	THS_BFQ        uint8 = 0 //不复权
	THS_QFQ        uint8 = 1 //前复权
	THS_HFQ        uint8 = 2 //后复权
)

Variables

View Source
var (
	DefaultMinuteKlineExportTitle = []any{"日期", "代码", "开盘", "最高", "最低", "收盘", "成交量(股)", "成交额(元)", "涨跌(元)", "涨跌幅(%)", "换手率(%)", "流通股本(股)", "总股本(股)"}
	DefaultDayKlineExportTitle    = []any{"日期", "代码", "名称", "昨收", "开盘", "最高", "最低", "收盘", "成交量(股)", "成交额(元)", "涨跌(元)", "涨跌幅(%)", "换手率(%)", "流通股本(股)", "总股本(股)", "前复权因子", "后复权因子", "分红(元/股)", "配股价", "送转股", "配股"}
)
View Source
var (
	AllTable      = []string{Minute, Minute5, Minute15, Minute30, Minute60, Day, Week, Month, Quarter, Year}
	AllKlineType  = AllTable //向下兼容
	KlineTableMap = map[string]*KlineTable{
		Minute:   NewKlineTable(TableMinute, func(c *tdx.Client) KlineHandler { return c.GetKlineMinuteUntil }),
		Minute5:  NewKlineTable(Table5Minute, func(c *tdx.Client) KlineHandler { return c.GetKline5MinuteUntil }),
		Minute15: NewKlineTable(Table15Minute, func(c *tdx.Client) KlineHandler { return c.GetKline15MinuteUntil }),
		Minute30: NewKlineTable(Table30Minute, func(c *tdx.Client) KlineHandler { return c.GetKline30MinuteUntil }),
		Minute60: NewKlineTable(Table60Minute, func(c *tdx.Client) KlineHandler { return c.GetKline60MinuteUntil }),
		Day:      NewKlineTable(TableDay, func(c *tdx.Client) KlineHandler { return c.GetKlineDayUntil }),
		Week:     NewKlineTable(TableWeek, func(c *tdx.Client) KlineHandler { return c.GetKlineWeekUntil }),
		Month:    NewKlineTable(TableMonth, func(c *tdx.Client) KlineHandler { return c.GetKlineMonthUntil }),
		Quarter:  NewKlineTable(TableQuarter, func(c *tdx.Client) KlineHandler { return c.GetKlineQuarterUntil }),
		Year:     NewKlineTable(TableYear, func(c *tdx.Client) KlineHandler { return c.GetKlineYearUntil }),
	}
)

Functions

func GetBjCodes

func GetBjCodes() ([]string, error)

func GetTHSDayKline

func GetTHSDayKline(code string, _type uint8) (protocol.Klines, error)

GetTHSDayKline 前复权,和通达信对的上,和东方财富对不上 后复权,和通达信,东方财富都对不上

func GetTHSDayKlineFull

func GetTHSDayKlineFull(code string, c *tdx.Client) ([3]protocol.Klines, error)

GetTHSDayKlineFull 获取[不复权,前复权,后复权]数据,并补充成交金额数据 前复权,和通达信对的上,和东方财富对不上 后复权,和通达信,东方财富都对不上

func KlinesToCsv

func KlinesToCsv(filename string, code, name string, ks protocol.Klines) error

func ListenCodesAndGbbqHTTP added in v0.0.61

func ListenCodesAndGbbqHTTP(port int, codesOption []tdx.CodesOption, equityOption []tdx.GbbqOption) error

func ListenCodesHTTP

func ListenCodesHTTP(port int, op ...tdx.CodesOption) error

func TradeToCsv

func TradeToCsv(filename string, ts protocol.Trades) error

Types

type CodesHTTP

type CodesHTTP struct {
	*tdx.CodesBase
	// contains filtered or unexported fields
}

func DialCodesHTTP

func DialCodesHTTP(address string, spec ...string) (c *CodesHTTP, err error)

func (*CodesHTTP) Update

func (this *CodesHTTP) Update() error

type Factor added in v0.0.55

type Factor struct {
	Date    int64   `json:"date"`     //时间
	QFactor float64 `json:"q_factor"` //前复权因子
	HFactor float64 `json:"h_factor"` //后复权因子
}

func GetTHSDayKlineFactorFull

func GetTHSDayKlineFactorFull(code string, c *tdx.Client) ([3]protocol.Klines, []*Factor, error)

GetTHSDayKlineFactorFull 增加计算复权因子

type Factors added in v0.0.55

type Factors []*Factor

func GetSinaFactor added in v0.0.55

func GetSinaFactor(code string, _type string) (Factors, error)

func GetSinaFactorFull added in v0.0.55

func GetSinaFactorFull(code string) (Factors, error)

func (Factors) Get added in v0.0.55

func (this Factors) Get(date int64) *Factor

type GbbqHTTP added in v0.0.61

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

func DialGbbqHTTP added in v0.0.61

func DialGbbqHTTP(address string, spec ...string) (e *GbbqHTTP, err error)

func (*GbbqHTTP) GetEquity added in v0.0.61

func (this *GbbqHTTP) GetEquity(code string, t time.Time) *protocol.Equity

func (*GbbqHTTP) GetFactors added in v0.0.61

func (this *GbbqHTTP) GetFactors(code string, ks protocol.Klines) []*protocol.Factor

func (*GbbqHTTP) GetTurnover added in v0.0.62

func (this *GbbqHTTP) GetTurnover(code string, t time.Time, volume int64) float64

func (*GbbqHTTP) GetXRXDs added in v0.0.61

func (this *GbbqHTTP) GetXRXDs(code string) protocol.XRXDs

func (*GbbqHTTP) Update added in v0.0.61

func (this *GbbqHTTP) Update() error

type Income

type Income struct {
	Offset  int        //偏移量
	Time    time.Time  //时间
	Source  protocol.K //源
	Current protocol.K //当前
}

func (*Income) Rise

func (this *Income) Rise() protocol.Price

func (*Income) RiseRate

func (this *Income) RiseRate() float64

func (*Income) String

func (this *Income) String() string

type Incomes

type Incomes []*Income

func DoIncomes

func DoIncomes(ks protocol.Klines, startAt time.Time, days ...int) Incomes

type Info added in v0.0.75

type Info struct {
	Code       string         `json:"code"`       //代码
	Name       string         `json:"name"`       //名称
	Price      protocol.Price `json:"price"`      //最新价
	Turnover   float64        `json:"turnover"`   //换手率
	FloatStock int64          `json:"floatStock"` //流通股本
	TotalStock int64          `json:"totalStock"` //总股本
	FloatValue protocol.Price `json:"floatValue"` //流通市值
	TotalValue protocol.Price `json:"totalValue"` //总市值
}

type Kline

type Kline struct {
	Unix            int64 `xorm:"pk"`
	*protocol.Kline `xorm:"extends"`
	Turnover        float64
	FloatStock      int64
	TotalStock      int64
}

func (*Kline) FloatValue added in v0.0.73

func (this *Kline) FloatValue() protocol.Price

func (*Kline) TotalValue added in v0.0.73

func (this *Kline) TotalValue() protocol.Price

type KlineHandler

type KlineHandler func(code string, f func(k *protocol.Kline) bool) (*protocol.KlineResp, error)

type KlineTable

type KlineTable struct {
	*Kline `xorm:"extends"` //同步字段
	// contains filtered or unexported fields
}

func NewKlineTable

func NewKlineTable(tableName string, handler func(c *tdx.Client) KlineHandler) *KlineTable

func (*KlineTable) TableName

func (this *KlineTable) TableName() string

type Klines

type Klines []*Kline

func (Klines) ATR added in v0.0.74

func (ks Klines) ATR(n int) []protocol.Price

ATR 常用于判断是否该止损

func (Klines) BOLL added in v0.0.74

func (ks Klines) BOLL(n int) (upper, mid, lower []protocol.Price)

BOLL 布林带(洗盘神器)

func (Klines) EMA added in v0.0.74

func (ks Klines) EMA(n int) []protocol.Price

EMA MACD的基础

func (Klines) HHV added in v0.0.76

func (this Klines) HHV(n int) protocol.Price

HHV 近n天的最高价,同tdx公式命名

func (Klines) LLV added in v0.0.76

func (this Klines) LLV(n int) protocol.Price

LLV 近n天的最低价,同tdx公式命名

func (Klines) MA added in v0.0.74

func (ks Klines) MA(n int) []protocol.Price

MA 均线

func (Klines) MACD added in v0.0.74

func (ks Klines) MACD() (dif, dea, hist []protocol.Price)

MACD 常用于短线核心

func (Klines) REF added in v0.0.76

func (this Klines) REF(n int) *Kline

REF 前n天

func (Klines) RSI added in v0.0.74

func (ks Klines) RSI(n int) []int64

RSI 常用于超买超卖

func (Klines) VWAP added in v0.0.74

func (ks Klines) VWAP() []protocol.Price

type PullKline

type PullKline struct {
	Config PullKlineConfig
	// contains filtered or unexported fields
}

func NewPullKline

func NewPullKline(cfg PullKlineConfig) *PullKline

func (*PullKline) DayKlines

func (this *PullKline) DayKlines(code string) (Klines, error)

func (*PullKline) Klines added in v0.0.73

func (this *PullKline) Klines(table string, code string) (Klines, error)

func (*PullKline) MinKlines added in v0.0.75

func (this *PullKline) MinKlines(code string) (Klines, error)

func (*PullKline) Name

func (this *PullKline) Name() string

func (*PullKline) Update added in v0.0.73

func (this *PullKline) Update(m *tdx.Manage) error

type PullKlineConfig

type PullKlineConfig struct {
	Codes      []string  //操作代码
	Tables     []string  //数据类型
	Dir        string    //数据位置
	Goroutines int       //协程数量
	StartAt    time.Time //数据开始时间
}

type PullTrade

type PullTrade struct {
	Dir string
}

func NewPullTrade

func NewPullTrade(dir string) *PullTrade

func (*PullTrade) Pull

func (this *PullTrade) Pull(ctx context.Context, m *tdx.Manage, code string) error

func (*PullTrade) PullYear

func (this *PullTrade) PullYear(ctx context.Context, m *tdx.Manage, year int, code string) (err error)

Jump to

Keyboard shortcuts

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