-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (35 loc) · 1.12 KB
/
main.go
File metadata and controls
39 lines (35 loc) · 1.12 KB
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
// Package main generated by 'freedom new-project spider'
package main
import (
"deeptrade/conf"
"deeptrade/task"
tradeflow "deeptrade/task/trade_flow"
"log"
"time"
)
func main() {
// 启动日志
log.Println("==========================================")
log.Printf("启动ETH期货量化交易系统, 当前环境: %s\n", conf.Get().Binance.CurrentEnvironment)
log.Printf("定时器: 每%d秒执行一次\n", conf.Get().Trading.TriggerTime*60)
log.Println("==========================================")
task.InitOffSystem()
log.Println("[系统] 分析和准备趋势数据-大约8-10分钟")
tradeflow.RunFetch(task.IsWork) //拉取数据
for {
working := task.IsWork()
if !working {
time.Sleep(15 * time.Minute)
continue
}
log.Println("开始新的交易周期...")
// 直接执行量化交易
if err := task.RunQuantitativeTrading(); err != nil {
log.Printf("量化交易执行失败: %v, 30秒后重试", err)
time.Sleep(30 * time.Second)
continue
}
log.Printf("本轮交易周期结束,等待%d秒...\n", task.GetSleepSec())
time.Sleep(time.Duration(task.GetSleepSec()) * time.Second)
}
}