-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindow.py
115 lines (92 loc) · 3.39 KB
/
window.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# coding: utf8
from Tkinter import *
import tkMessageBox
from tkFileDialog import *
from gridStrategy import MakeGrid
class Window:
def __init__(self):
self.max = 1.2
self.initalStep = 2
self.rate = 0.15
self.initialBuyNum = 1000
self.large = 0.3
self.middle = 0.15
self.small = 0.05
window = Tk()
window.title("网格策略 - wuxi")
window.geometry('800x600')
x1 = 10
x2 = 120
y = 10
Label(window, text="目标价格").place(x=x1, y=y)
self.targetEn = Entry(window)
self.targetEn.insert(0, str(self.max))
self.targetEn.place(x=x2, y=y)
y += 40
Label(window, text="递增起点(0开始)").place(x=x1, y=y)
self.startEn = Entry(window)
self.startEn.place(x=x2, y=y)
self.startEn.insert(0, str(self.initalStep))
y += 40
Label(window, text="递增比率(小数)").place(x=x1, y=y)
self.stepEn = Entry(window)
self.stepEn.insert(0, str(self.rate))
self.stepEn.place(x=x2, y=y)
y += 40
Label(window, text="单笔购买数").place(x=x1, y=y)
self.singleBuyEn = Entry(window)
self.singleBuyEn.place(x=x2, y=y)
self.singleBuyEn.insert(0, str(self.initialBuyNum))
y += 40
Label(window, text="大网百分比(小数)").place(x=x1, y=y)
self.largeEn = Entry(window)
self.largeEn.place(x=x2, y=y)
self.largeEn.insert(0, str(self.large))
y += 40
Label(window, text="中网百分比(小数)").place(x=x1, y=y)
self.middleEn = Entry(window)
self.middleEn.place(x=x2, y=y)
self.middleEn.insert(0, str(self.middle))
y += 40
Label(window, text="小网百分比(小数)").place(x=x1, y=y)
self.smallEn = Entry(window)
self.smallEn.place(x=x2, y=y)
self.smallEn.insert(0, str(self.small))
y += 40
Button(window, text="请选择输出文件夹", command=self.selectOutputPath).place(x=x1, y=y)
self.dirName = StringVar()
self.dirName.set('/Users/wuxi/Desktop')
self.dirLabel = Label(window, textvariable=self.dirName)
self.dirLabel.place(x=x1 + 150, y=y)
y += 40
Button(window, text="开始", command=self.start).place(x=x1, y=y)
window.mainloop()
self.window = window
# 选择输出文件路径
def selectOutputPath(self):
path = askdirectory()
print '路径: ', path
self.dirName.set(path)
# 开始生成表格
def start(self):
self.max = float(self.targetEn.get())
self.initalStep = int(self.startEn.get())
self.initalStep = float(self.stepEn.get())
self.initialBuyNum = int(self.singleBuyEn.get())
self.large = float(self.largeEn.get())
self.middle = float(self.middleEn.get())
self.small = float(self.smallEn.get())
dir = self.dirName.get()
build = MakeGrid(dir=dir)
build.max = self.max
build.min = self.max*0.4
build.initalStep = self.initalStep
build.stepRate = self.rate
build.large = self.large
build.middle = self.middle
build.small = self.small
build.minBuyNum = self.initialBuyNum
build.makeGrids()
build.generateExcel()
tkMessageBox.showinfo(title="提示", message="成功!")
win = Window()