util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TradeTimes = TradeTime{Range: map[time.Weekday]TimeRangeList{
		time.Monday: TimeRangeList{
			{Start: DayMinute(8, 50), End: DayMinute(11, 35)},
			{Start: DayMinute(13, 30), End: DayMinute(15, 5)},
			{Start: DayMinute(20, 50), End: DayMinute(24, 0)},
		},
		time.Tuesday: TimeRangeList{
			{Start: DayMinute(0, 0), End: DayMinute(03, 5)},
			{Start: DayMinute(8, 50), End: DayMinute(11, 35)},
			{Start: DayMinute(13, 30), End: DayMinute(15, 5)},
			{Start: DayMinute(20, 50), End: DayMinute(24, 0)},
		},
		time.Wednesday: TimeRangeList{
			{Start: DayMinute(0, 0), End: DayMinute(03, 5)},
			{Start: DayMinute(8, 50), End: DayMinute(11, 35)},
			{Start: DayMinute(13, 30), End: DayMinute(15, 5)},
			{Start: DayMinute(20, 50), End: DayMinute(24, 0)},
		},
		time.Thursday: TimeRangeList{
			{Start: DayMinute(0, 0), End: DayMinute(03, 5)},
			{Start: DayMinute(8, 50), End: DayMinute(11, 35)},
			{Start: DayMinute(13, 30), End: DayMinute(15, 5)},
			{Start: DayMinute(20, 50), End: DayMinute(24, 0)},
		},
		time.Friday: TimeRangeList{
			{Start: DayMinute(0, 0), End: DayMinute(03, 5)},
			{Start: DayMinute(8, 50), End: DayMinute(11, 35)},
			{Start: DayMinute(13, 30), End: DayMinute(15, 5)},
		},
	}}
)

Functions

func GetReqID

func GetReqID() int

func OnRsp

func OnRsp[T any](resp *T, pRspInfo *ctp.CThostFtdcRspInfoField, nRequestID int, bIsLast bool)

func Req

func Req[T any](ctx context.Context, req func(id int) error) (result *T, err error)

func ReqWithResps

func ReqWithResps[T any](ctx context.Context, req func(id int) error) (result []*T, err error)

func WaitTradeTime

func WaitTradeTime()

Types

type CTPKline

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

func NewCTPKline

func NewCTPKline() *CTPKline

func (*CTPKline) SetCb

func (k *CTPKline) SetCb(cb func(*trademodel.Candle))

func (*CTPKline) Update

func (k *CTPKline) Update(data *ctp.CThostFtdcDepthMarketDataField) (candle *trademodel.Candle)

type MinuteOfDay

type MinuteOfDay int

func DayMinute

func DayMinute(hour, minute int) MinuteOfDay

type MinuteOfDayRange

type MinuteOfDayRange struct {
	Start MinuteOfDay
	End   MinuteOfDay
}

type SafeWait

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

func (*SafeWait) Done

func (w *SafeWait) Done(err error)

func (*SafeWait) Wait

func (w *SafeWait) Wait(ctx context.Context) error

type SyncReq

type SyncReq[T any] struct {
	ID     int
	Result []*T
	// contains filtered or unexported fields
}

func NewSyncReq

func NewSyncReq[T any](id int) *SyncReq[T]

func (*SyncReq[T]) Wait

func (r *SyncReq[T]) Wait(ctx context.Context) error

type TimeRangeList

type TimeRangeList []MinuteOfDayRange

func (TimeRangeList) NeedWait

func (tl TimeRangeList) NeedWait(tm time.Time) time.Duration

type TradeTime

type TradeTime struct {
	Range map[time.Weekday]TimeRangeList
}

func (*TradeTime) Wait

func (t *TradeTime) Wait()

type TradeTimeRange

type TradeTimeRange struct {
	Weekdays []time.Weekday
	Ranges   []MinuteOfDayRange
}

Jump to

Keyboard shortcuts

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