mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d1487f0b6 | ||
|
|
bd3863d3c5 | ||
|
|
5fb1a212c6 | ||
|
|
f381d72ec4 | ||
|
|
5fa572f298 |
@@ -295,12 +295,6 @@ func (this Klines) Merge(n int) Klines {
|
||||
}
|
||||
|
||||
ks := Klines(nil)
|
||||
|
||||
if this[0].Time.Hour() == 9 && this[0].Time.Minute() == 30 {
|
||||
ks = append(ks, this[0])
|
||||
this = this[1:]
|
||||
}
|
||||
|
||||
ls := Klines(nil)
|
||||
for i := 0; ; i++ {
|
||||
if len(this) <= i*n {
|
||||
|
||||
@@ -183,7 +183,6 @@ func (this Trades) Kline(t time.Time, last Price) *Kline {
|
||||
|
||||
// kline1 生成一分钟k线,一天
|
||||
func (this Trades) klinesForDay(date time.Time) Klines {
|
||||
_929 := 569 //9:29 的分钟,为了兼容性强,把9:25算9:29
|
||||
_930 := 570 //9:30 的分钟
|
||||
_1130 := 690 //11:30 的分钟
|
||||
_1300 := 780 //13:00 的分钟
|
||||
@@ -191,7 +190,7 @@ func (this Trades) klinesForDay(date time.Time) Klines {
|
||||
keys := []int(nil)
|
||||
//早上
|
||||
m := map[int]Trades{}
|
||||
for i := 0; i <= 120; i++ {
|
||||
for i := 1; i <= 120; i++ {
|
||||
keys = append(keys, _930+i)
|
||||
m[_930+i] = []*Trade{}
|
||||
}
|
||||
@@ -211,7 +210,7 @@ func (this Trades) klinesForDay(date time.Time) Klines {
|
||||
//分组,按
|
||||
for _, v := range this {
|
||||
ms := minutes(v.Time)
|
||||
t := conv.Select(ms < _929, _929, ms)
|
||||
t := conv.Select(ms < _930, _930, ms)
|
||||
t++
|
||||
t = conv.Select(t > _1130 && t <= _1300, _1130, t)
|
||||
t = conv.Select(t > _1500, _1500, t)
|
||||
|
||||
@@ -281,11 +281,11 @@ func IsETF(code string) bool {
|
||||
code = strings.ToLower(code)
|
||||
switch {
|
||||
case code[0:2] == ExchangeSH.String() &&
|
||||
(code[2:5] == "510" || code[2:5] == "511" || code[2:5] == "512" || code[2:5] == "513" || code[2:5] == "515"):
|
||||
(code[2:4] == "51" || code[2:4] == "56" || code[2:4] == "58"):
|
||||
return true
|
||||
|
||||
case code[0:2] == ExchangeSZ.String() &&
|
||||
(code[2:5] == "159"):
|
||||
(code[2:4] == "15" || code[2:4] == "16"):
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
15
workday.go
15
workday.go
@@ -6,6 +6,7 @@ import (
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/injoyai/base/maps"
|
||||
"github.com/injoyai/conv"
|
||||
"github.com/injoyai/ios/client"
|
||||
"github.com/injoyai/logs"
|
||||
"github.com/injoyai/tdx/protocol"
|
||||
"github.com/robfig/cron/v3"
|
||||
@@ -16,6 +17,14 @@ import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func DialWorkday(op ...client.Option) (*Workday, error) {
|
||||
c, err := DialDefault(op...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewWorkdaySqlite(c)
|
||||
}
|
||||
|
||||
func NewWorkdayMysql(c *Client, dsn string) (*Workday, error) {
|
||||
|
||||
//连接数据库
|
||||
@@ -150,11 +159,11 @@ func (this *Workday) RangeYear(year int, f func(t time.Time) bool) {
|
||||
)
|
||||
}
|
||||
|
||||
// Range 遍历指定范围的工作日
|
||||
// Range 遍历指定范围的工作日,推荐start带上时间15:00,这样当天小于15点不会触发
|
||||
func (this *Workday) Range(start, end time.Time, f func(t time.Time) bool) {
|
||||
start = conv.Select(start.Before(protocol.ExchangeEstablish), protocol.ExchangeEstablish, start)
|
||||
now := IntegerDay(time.Now())
|
||||
end = conv.Select(end.After(now), now, end).Add(1)
|
||||
//now := IntegerDay(time.Now())
|
||||
//end = conv.Select(end.After(now), now, end).Add(1)
|
||||
for ; start.Before(end); start = start.Add(time.Hour * 24) {
|
||||
if this.Is(start) {
|
||||
if !f(start) {
|
||||
|
||||
Reference in New Issue
Block a user