Documentation
¶
Overview ¶
Package trading 包含交易中的日历和时段相关的功能函数
Index ¶
- Constants
- Variables
- func CanInitialize(lastModified ...time.Time) (toInit bool)
- func CanUpdate(lastModified ...time.Time) (updated bool)
- func CanUpdateInRealtime(lastModified ...time.Time) (updateInRealTime bool, status int)
- func CheckCallAuctionClose(timestamp time.Time) (canUpdate bool)
- func CheckCallAuctionCloseFinished(timestamp time.Time) (finished bool)
- func CheckCallAuctionOpen(timestamp time.Time) (canUpdate bool)
- func CheckCallAuctionOpenFinished(timestamp time.Time) (finished bool)
- func CheckCallAuctionTail(timestamp time.Time) (finished bool)
- func CheckCallAuctionTime(timestamp time.Time) (canUpdate bool)
- func CurrentlyTrading(date ...string) bool
- func DateIsTradingDay(date ...string) bool
- func FixTradeDate(datetime string, format ...string) string
- func GetCurrentDate(date ...string) (currentDate string)
- func GetCurrentlyDay() (currentlyDay string)
- func GetFrontTradeDay() string
- func GetLastDayForUpdate() string
- func GetTodayTimeByString(timeStr string) (time.Time, error)
- func IndexToday() string
- func IsHoliday(date string) bool
- func IsTimeInRange(timeStr, startStr, endStr string) (bool, error)
- func IsTrading(date ...string) bool
- func LastNDate(date string, n ...int) []string
- func LastTradeDate() string
- func Minutes(date ...string) int
- func NextTradeDate(date string) string
- func Today() string
- func TradeRange(start, end string, threadSafe ...bool) []string
- type DateTimeRange
- type FinancialHoliday
- type TimeStatus
Constants ¶
View Source
const ( CN_TransactionTimeFormat = "15:04" // 分笔成交时间格式 CN_SERVERTIME_FORMAT = "15:04:05.000" // 服务器时间格式 CN_SERVERTIME_SHORT_FORMAT = "15:04:05" // 服务器时间格式 TimeStampMilli = "2006-01-02 15:04:05.000" TimeStampMicro = "2006-01-02 15:04:05.000000" TimeStampNano = "2006-01-02 15:04:05.000000000" )
View Source
const ( CN_MarketInitTime = "09:00:00.000" // A股数据初始化时间 CN_TradingStartTime = "09:15:00.000" // A股数据开始时间 CN_TradingSuspendBeginTime = "11:30:00.000" // A股午间休市开始时间 CN_TradingSuspendEndTime = "12:59:59.999" // A股午间休市结束时间 CN_TradingStopTime = "15:00:59.999" // A股数据结束时间 CN_CallAuctionAmBegin = "09:15:00.000" // 集合竞价-早盘-开始时间 CN_CallAuctionAmEnd = "09:27:59.999" // 集合竞价-早盘-结束时间 CN_CallAuctionAmFinished = "09:27:00.000" // 集合竞价-早盘-数据结束时间 CN_CallAuctionTailBegin = "14:30:00.000" // 尾盘时段-开始 CN_CallAuctionTailEnd = "15:01:59.999" // 尾盘时段-结束 CN_CallAuctionPmBegin = "14:57:00.000" // 集合竞价-尾盘-开始时间 CN_CallAuctionPmEnd = "15:01:59.999" // 集合竞价-尾盘-结束时间 CN_CallAuctionPmFinished = "15:01:00.000" // 集合竞价-尾盘-数据结束时间 )
交易日时间相关常量
View Source
const ( BEGIN_A_AUCTION = "09:15:00" // A股上午集合竞价开始时间 END_A_AUCTION = "09:25:00" // A股上午集合竞价结束时间 END_A_AUCTION_SPE = "09:26:00" // A股上午集合竞价结束时间过一分钟 BEGIN_P_AUCTION = "14:57:00" // A股下午集合竞价开始时间 END_P_AUCTION = "15:01:00" // A股下午集合竞价结束时间 END_P_AUCTION_SPE = "15:02:00" // A股下午集合竞价结束时间过一分钟 )
集合竞价时间相关常量
View Source
const ( CN_DEFAULT_TOTALFZNUM = 240 // A股默认全天交易240分钟 BEGIN_A_AM_HOUR = 9 // A股开市-时 BEGIN_A_AM_MINUTE = 30 // A股开市-分 END_A_AM_HOUR = 11 // A股休市-时 END_A_AM_MINUTE = 30 // A股休市-分 BEGIN_A_PM_HOUR = 13 // A股开市-时 BEGIN_A_PM_MINUTE = 0 // A股开市-分 END_A_PM_HOUR = 15 // A股休市-时 END_A_PM_MINUTE = 0 // A股休市-分 )
分时数据相关常量
View Source
const (
TimeOnly = time.TimeOnly // 时分秒的格式
)
View Source
const (
TradingDayDateFormat = "2006-01-02" // 交易日历日期格式
)
Variables ¶
View Source
var (
CN_TOTALFZNUM = 0 // A股全天交易的分钟数
)
View Source
var (
ErrNoUpdateRequired = errors.New("no update required")
)
Functions ¶
func CanInitialize ¶
CanInitialize 数据是否初始化(One-time update)
func CanUpdateInRealtime ¶ added in v1.9.0
CanUpdateInRealtime 能否实时更新
func CheckCallAuctionClose ¶ added in v1.10.2
CheckCallAuctionClose 检查当前时间是否集合竞价阶段
func CheckCallAuctionCloseFinished ¶ added in v1.13.0
CheckCallAuctionCloseFinished 检查当前时间是否集合竞价阶段-结束
func CheckCallAuctionOpen ¶ added in v1.10.2
CheckCallAuctionOpen 检查当前时间是否集合竞价阶段-进行中
func CheckCallAuctionOpenFinished ¶ added in v1.13.0
CheckCallAuctionOpenFinished 检查当前时间是否集合竞价阶段-结束
func CheckCallAuctionTail ¶ added in v1.15.2
CheckCallAuctionTail 检查当前时间是否集合竞价阶段-结束
func CheckCallAuctionTime ¶ added in v1.10.1
CheckCallAuctionTime 检查当前时间是否集合竞价阶段
func GetCurrentDate ¶ added in v1.11.7
GetCurrentDate 获取数据有效的最后一个交易日, 以9点整划分
func GetCurrentlyDay ¶
func GetCurrentlyDay() (currentlyDay string)
GetCurrentlyDay 获取数据有效的最后一个交易日, 以9点15分划分
func GetTodayTimeByString ¶
GetTodayTimeByString 返回当天指定时刻的时间
func IsTimeInRange ¶
Types ¶
type DateTimeRange ¶ added in v1.17.0
func (*DateTimeRange) Minutes ¶ added in v1.17.0
func (tr *DateTimeRange) Minutes() int
type FinancialHoliday ¶ added in v1.18.3
type FinancialHoliday struct { Date string `name:"日期" array:"0"` Holiday string `name:"节日" array:"1"` Country string `name:"地区" array:"2"` Exchange string `name:"交易所" array:"3"` }
FinancialHoliday 金融假日
type TimeStatus ¶ added in v1.9.9
type TimeStatus = int
const ( ExchangePreMarket TimeStatus = -1 // 盘前 ExchangeSuspend TimeStatus = 0 // 休市中, 交易暂停 ExchangeTrading TimeStatus = 1 // 交易中 ExchangeCallAuction TimeStatus = 2 // 交易中, 集合竞价 ExchangeClosing TimeStatus = 3 // 当日收盘, 交易停止 )
Click to show internal directories.
Click to hide internal directories.