Skip to content

Commit 1a43283

Browse files
author
lin
committed
V2.1.7.7
1 parent 343b8a4 commit 1a43283

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ folder by using the multi-threads for speeding.
6767

6868
4. V2.1.7.6 : update the position. 对订阅的交易对,都会推送其头寸的更新.
6969

70+
5. V2.1.7.7 : add the position_update_interval and
71+
order_update_interval, 添加对订单和仓位信息的更新频率.
72+
7073
## 联系方式
7174
微信: bitquant51
7275

howtrader/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.1.7.6"
1+
__version__ = "2.1.7.7"

howtrader/trader/engine.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ def __init__(self, main_engine: MainEngine, event_engine: EventEngine):
365365
self.add_function()
366366
self.register_event()
367367

368-
self.timer_count = 0 # for counting the timer.
368+
self.order_update_interval = 0 # for counting the timer.
369+
self.position_update_interval = 0
369370

370371
def add_function(self) -> None:
371372
"""Add query function to main engine."""
@@ -434,17 +435,21 @@ def process_timer(self, event: Event) -> None:
434435
"""
435436
update the orders, positions by timer, for we may be disconnected from server update push.
436437
"""
437-
if self.timer_count >= SETTINGS.get('order_update_timer', 120):
438-
self.timer_count = 0
438+
439+
self.order_update_interval += 1
440+
self.position_update_interval += 1
441+
442+
if self.order_update_interval >= SETTINGS.get('order_update_interval', 120):
443+
self.order_update_interval = 0
439444
orders = self.get_all_active_orders()
440445
for order in orders:
441446
if order.datetime and (datetime.now(order.datetime.tzinfo) - order.datetime).seconds > SETTINGS.get('order_update_timer', 120):
442447
req = order.create_query_request()
443448
self.main_engine.query_order(req, order.gateway_name)
444449

450+
if self.position_update_interval >= SETTINGS.get('position_update_interval', 120):
445451
self.main_engine.query_position()
446-
else:
447-
self.timer_count += 1
452+
self.position_update_interval = 0
448453

449454
def get_tick(self, vt_symbol: str) -> Optional[TickData]:
450455
"""

howtrader/trader/setting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
SETTINGS: Dict[str, Any] = {
1212
"font.family": "Arial",
1313
"font.size": 12,
14-
"order_update_timer": 120,
14+
"order_update_interval": 120,
15+
"position_update_interval": 120,
1516
"log.active": True,
1617
"log.level": CRITICAL,
1718
"log.console": True,

0 commit comments

Comments
 (0)