extend

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Minute   = "minute"
	Minute5  = "5minute"
	Minute15 = "15minute"
	Minute30 = "30minute"
	Hour     = "hour"
	Day      = "day"
	Week     = "week"
	Month    = "month"
	Quarter  = "quarter"
	Year     = "year"
)
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 (
	AllKlineType  = []string{Minute, Minute5, Minute15, Minute30, Hour, Day, Week, Month, Quarter, Year}
	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 }),
		Hour:     NewKlineTable(tableHour, func(c *tdx.Client) KlineHandler { return c.GetKlineHourUntil }),
		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 GetTHSDayKlineFull

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

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

func KlinesToCsv

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

func ListenCodesHTTP

func ListenCodesHTTP(port int, op ...tdx.Codes2Option) 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 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 Klines, startAt time.Time, days ...int) Incomes

type Kline

type Kline struct {
	Code   string         `json:"code"`                  //代码
	Date   int64          `json:"date"`                  //时间节点 2006-01-02 15:00
	Open   protocol.Price `json:"open"`                  //开盘价
	High   protocol.Price `json:"high"`                  //最高价
	Low    protocol.Price `json:"low"`                   //最低价
	Close  protocol.Price `json:"close"`                 //收盘价
	Volume int64          `json:"volume"`                //成交量
	Amount protocol.Price `json:"amount"`                //成交额
	InDate int64          `json:"inDate" xorm:"created"` //创建时间
}

func GetTHSDayKline

func GetTHSDayKline(code string, _type uint8) ([]*Kline, error)

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

type KlineHandler

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

type KlineTable

type KlineTable struct {
	Kline `xorm:"extends"`

	Handler func(c *tdx.Client) KlineHandler `xorm:"-"`
	// 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) Kline

func (this Klines) Kline() *Kline

Kline 计算多个K线,成一个K线

func (Klines) Len

func (this Klines) Len() int

func (Klines) Less

func (this Klines) Less(i, j int) bool

func (Klines) Merge

func (this Klines) Merge(n int) Klines

Merge 合并K线

func (Klines) Sort

func (this Klines) Sort()

func (Klines) Swap

func (this Klines) Swap(i, j int)

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) Name

func (this *PullKline) Name() string

func (*PullKline) Run

func (this *PullKline) Run(ctx context.Context, m *tdx.Manage) error

type PullKlineConfig

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

type PullKlineMysql

type PullKlineMysql struct {
	Config PullKlineConfig
	DB     *xorms.Engine
	// contains filtered or unexported fields
}

func NewPullKlineMysql

func NewPullKlineMysql(cfg PullKlineConfig) (*PullKlineMysql, error)

func (*PullKlineMysql) Name

func (this *PullKlineMysql) Name() string

func (*PullKlineMysql) Run

func (this *PullKlineMysql) Run(ctx context.Context, m *tdx.Manage) error

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)

type THSFactor

type THSFactor 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][]*Kline, []*THSFactor, error)

GetTHSDayKlineFactorFull 增加计算复权因子

Jump to

Keyboard shortcuts

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