Skip to content

Commit 69d49bc

Browse files
committed
[Mod] type declaration
1 parent e55f560 commit 69d49bc

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

vnpy_excelrtd/engine.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
""""""
2-
3-
from typing import Set
1+
from typing import Set, Optional
42

53
from vnpy.event import Event, EventEngine
64
from vnpy.rpc import RpcServer
@@ -9,12 +7,12 @@
97
from vnpy.trader.event import EVENT_TICK
108

119

12-
APP_NAME: str = "ExcelRtd"
10+
APP_NAME = "ExcelRtd"
1311

14-
EVENT_RTD_LOG: str = "eRtdLog"
12+
EVENT_RTD_LOG = "eRtdLog"
1513

16-
REP_ADDRESS: str = "tcp://*:9001"
17-
PUB_ADDRESS: str = "tcp://*:9002"
14+
REP_ADDRESS = "tcp://*:9001"
15+
PUB_ADDRESS = "tcp://*:9002"
1816

1917

2018
class RtdEngine(BaseEngine):
@@ -60,7 +58,7 @@ def subscribe(self, vt_symbol: str) -> None:
6058
"""
6159
Subscribe tick data update.
6260
"""
63-
contract: ContractData = self.main_engine.get_contract(vt_symbol)
61+
contract: Optional[ContractData] = self.main_engine.get_contract(vt_symbol)
6462
if not contract:
6563
return
6664

vnpy_excelrtd/ui/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class RtdManager(QtWidgets.QWidget):
1111
""""""
12-
signal_log = QtCore.pyqtSignal(Event)
12+
signal_log: QtCore.pyqtSignal = QtCore.pyqtSignal(Event)
1313

1414
def __init__(self, main_engine: MainEngine, event_engine: EventEngine) -> None:
1515
""""""

vnpy_excelrtd/vnpy_rtd.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
""""""
2-
31
from typing import Dict, Set, Any
42
from collections import defaultdict
53

@@ -9,8 +7,8 @@
97
from vnpy.trader.object import TickData
108

119

12-
REQ_ADDRESS: str = "tcp://localhost:9001"
13-
SUB_ADDRESS: str = "tcp://localhost:9002"
10+
REQ_ADDRESS = "tcp://localhost:9001"
11+
SUB_ADDRESS = "tcp://localhost:9002"
1412

1513

1614
rtd_client: "RtdClient" = None
@@ -68,7 +66,7 @@ def __init__(self) -> None:
6866
def callback(self, topic: str, data: Any) -> None:
6967
""""""
7068
tick: TickData = data
71-
buf: dict = self.rtds[tick.vt_symbol]
69+
buf: Set[ObjectRtd] = self.rtds[tick.vt_symbol]
7270

7371
for rtd in buf:
7472
rtd.update(tick)
@@ -77,7 +75,7 @@ def add_rtd(self, rtd: ObjectRtd) -> None:
7775
"""
7876
Add a new RTD into the engine..
7977
"""
80-
buf: dict = self.rtds[rtd.name]
78+
buf: Set[ObjectRtd] = self.rtds[rtd.name]
8179
buf.add(rtd)
8280
self.write_log(f"新增RTD连接:{rtd.name} {rtd.field}")
8381

@@ -88,7 +86,7 @@ def remove_rtd(self, rtd: ObjectRtd) -> None:
8886
"""
8987
Remove an existing RTD from the engine.
9088
"""
91-
buf: dict = self.rtds[self.name]
89+
buf: Set[ObjectRtd] = self.rtds[self.name]
9290
if self in buf:
9391
buf.remove(rtd)
9492
self.write_log(f"移除RTD连接:{rtd.name} {rtd.field}")

0 commit comments

Comments
 (0)