-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
43 lines (33 loc) · 1.04 KB
/
run.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
from datetime import datetime
from vnpy.trader.ui import create_qapp, QtCore
from vnpy.trader.constant import Exchange, Interval
from vnpy.trader.database import get_database
from vnpy.chart import ChartWidget, VolumeItem, CandleItem
if __name__ == "__main__":
app = create_qapp()
database = get_database()
bars = database.load_bar_data(
"IF888",
Exchange.CFFEX,
interval=Interval.MINUTE,
start=datetime(2019, 7, 1),
end=datetime(2019, 7, 17)
)
widget = ChartWidget()
widget.add_plot("candle", hide_x_axis=True)
widget.add_plot("volume", maximum_height=200)
widget.add_item(CandleItem, "candle", "candle")
widget.add_item(VolumeItem, "volume", "volume")
widget.add_cursor()
n = 1000
history = bars[:n]
new_data = bars[n:]
widget.update_history(history)
def update_bar():
bar = new_data.pop(0)
widget.update_bar(bar)
timer = QtCore.QTimer()
timer.timeout.connect(update_bar)
# timer.start(100)
widget.show()
app.exec_()