-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathspreadBuilder.pyw
104 lines (70 loc) · 2.67 KB
/
spreadBuilder.pyw
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
# -*- coding: utf-8 -*-
"""
Spread builder. A gui tool used to identify and follow trading opportunities.
Copyright: Jev Kuznetsov
License: BSD
Project started on 08.02.2015
"""
import sys
from PyQt4 import QtGui
from PyQt4.QtCore import Qt
import widgets
__version__ = "0.0.1"
class MainWindow(QtGui.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.initUI()
def initUI(self):
#---flags
self.dirty = False # indicate unsaved changes
#----actions
act_exit = QtGui.QAction( '&Exit', self)
act_exit.setStatusTip('Exit application')
act_exit.triggered.connect(QtGui.qApp.quit)
act_open = QtGui.QAction( '&Open', self)
act_open.setStatusTip('Load spreads')
act_open.triggered.connect(self.test_fcn)
act_useSymbol = QtGui.QAction( 'use', self)
act_useSymbol.triggered.connect(self.useSymbol)
act_test = QtGui.QAction( 'test', self)
act_test.triggered.connect(self.test_fcn)
#---- menu
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(act_open)
fileMenu.addAction(act_exit)
#---- toolbar
toolbar = self.addToolBar('tools')
toolbar.addAction(act_test)
#---- statusbar
self.statusBar().showMessage('Ready')
# symbols dock
self.dock_symbols = widgets.Dock('symbols', self, widgets.SymbolsList)
lst = self.dock_symbols.widget()
lst.setSymbols(['SPY','VXX','AAPL'])
lst.addAction(act_useSymbol)
# spread dock
self.dock_spread = widgets.Dock('spread',self,widgets.SpreadWidget,area=Qt.RightDockWidgetArea)
#-----prepare window
self.setGeometry(100, 100, 800, 600) # init position and size
self.setWindowTitle('SpreadBuilder v.' + __version__)
def useSymbol(self):
""" adds symbol to a spread """
lst = self.dock_symbols.widget()
txt = lst.currentItem().text()
self.statusBar().showMessage(txt + ' added')
def test_fcn(self):
""" dummy test function """
self.statusBar().showMessage('test')
self.dock_spread.widget().test()
def main():
print 'starting'
app = QtGui.QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())
def test():
print 'Done.'
if __name__ == '__main__':
main()
#test()