-
Notifications
You must be signed in to change notification settings - Fork 1
/
plungeMySQL_go
88 lines (74 loc) · 2.65 KB
/
plungeMySQL_go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"database/sql"
"fmt"
"os"
"strings"
"time"
_ "github.com/go-sql-driver/mysql"
)
type Param struct {
db *sql.DB
rq string
}
func main() {
db, err := sql.Open("mysql", "root:123456@tcp(localhost:3307)/stock?charset=utf8mb4")
if err != nil {
fmt.Printf("open db err:%s\n", err.Error())
return
}
defer db.Close()
pdb, perr := sql.Open("mysql", "homestead:secret@tcp(localhost:33060)/plunge?charset=utf8mb4")
if perr != nil {
fmt.Printf("open db perr:%s\n", perr.Error())
return
}
defer pdb.Close()
start := time.Now().UnixNano()
rq := "2021-01-01"
tname := "dayline"
if len(os.Args) != 3 {
fmt.Println("命令行参数数量错误,应该是3, 日期,表名 ; 目前长度是:", len(os.Args))
os.Exit(1)
}
for k, v := range os.Args {
if k == 1 {
rq = v
} else if k == 2 {
tname = v
}
}
//---------break out with vol
cateName := "BreakWithVol" + strings.Replace(rq[5:10], "-", "", -1)
dataMapArray := breakwithvol(db, rq, 20, tname)
remark := "Head and shoulders or box pattern wrapped around MA20. Auto generated by Plunge "
SaveCategoyStock(pdb, cateName, cateName, remark, dataMapArray)
end := time.Now().UnixNano()
dataMapArray = breakwithvol(db, rq, 30, tname)
remark = "Head and shoulders or box pattern wrapped around MA30. Auto generated by Plunge "
SaveCategoyStock(pdb, cateName, cateName, remark, dataMapArray)
dataMapArray = breakwithvol(db, rq, 60, tname)
remark = "Head and shoulders or box pattern wrapped around MA60. Auto generated by Plunge"
SaveCategoyStock(pdb, cateName, cateName, remark, dataMapArray)
end = time.Now().UnixNano()
fmt.Printf("dltp3l cost is :%d \n", (end-start)/1000)
//---------getting chips
cateName = "GetChips" + strings.Replace(rq[5:10], "-", "", -1)
dataMapArray = getchips(db, rq, tname)
remark = "Getting chips.Auto generated by Plunge "
SaveCategoyStock(pdb, cateName, cateName, remark, dataMapArray)
end = time.Now().UnixNano()
fmt.Printf("xc cost is :%d \n", (end-start)/1000)
// //---------continuous stars
cateName = "Stars" + strings.Replace(rq[5:10], "-", "", -1)
dataMapArray = stars(db, rq, tname)
remark = "Continuous stars.Auto generated by Plunge "
SaveCategoyStock(pdb, cateName, cateName, remark, dataMapArray)
// //---------support at the gap
cateName = "SuportWithGap" + strings.Replace(rq[5:10], "-", "", -1)
dataMapArray = suportwithgap(db, rq, tname)
remark = "Support at the gap .Auto generated by Plunge "
SaveCategoyStock(pdb, cateName, cateName, remark, dataMapArray)
end = time.Now().UnixNano()
fmt.Printf(" cost is :%d \n", (end-start)/1000)
}