[Fix] close #2160
This commit is contained in:
parent
cb835d5932
commit
09adbf5cf0
@ -25,6 +25,7 @@ from .base import (
|
||||
STOPORDER_PREFIX,
|
||||
StopOrder,
|
||||
StopOrderStatus,
|
||||
INTERVAL_DELTA_MAP
|
||||
)
|
||||
from .template import CtaTemplate
|
||||
|
||||
@ -221,6 +222,7 @@ class BacktestingEngine:
|
||||
# Load 30 days of data each time and allow for progress update
|
||||
progress_delta = timedelta(days=30)
|
||||
total_delta = self.end - self.start
|
||||
interval_delta = INTERVAL_DELTA_MAP[self.interval]
|
||||
|
||||
start = self.start
|
||||
end = self.start + progress_delta
|
||||
@ -252,8 +254,11 @@ class BacktestingEngine:
|
||||
progress_bar = "#" * int(progress * 10)
|
||||
self.output(f"加载进度:{progress_bar} [{progress:.0%}]")
|
||||
|
||||
start = end
|
||||
end += progress_delta
|
||||
start = end + interval_delta
|
||||
end += (progress_delta + interval_delta)
|
||||
|
||||
if data:
|
||||
print(data[0].datetime, data[-1].datetime)
|
||||
|
||||
self.output(f"历史数据加载完成,数据量:{len(self.history_data)}")
|
||||
|
||||
@ -354,6 +359,7 @@ class BacktestingEngine:
|
||||
end_balance = 0
|
||||
max_drawdown = 0
|
||||
max_ddpercent = 0
|
||||
max_drawdown_duration = 0
|
||||
total_net_pnl = 0
|
||||
daily_net_pnl = 0
|
||||
total_commission = 0
|
||||
|
@ -4,8 +4,9 @@ Defines constants and objects used in CtaStrategy App.
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from datetime import timedelta
|
||||
|
||||
from vnpy.trader.constant import Direction, Offset
|
||||
from vnpy.trader.constant import Direction, Offset, Interval
|
||||
|
||||
APP_NAME = "CtaStrategy"
|
||||
STOPORDER_PREFIX = "STOP"
|
||||
@ -44,3 +45,9 @@ class StopOrder:
|
||||
EVENT_CTA_LOG = "eCtaLog"
|
||||
EVENT_CTA_STRATEGY = "eCtaStrategy"
|
||||
EVENT_CTA_STOPORDER = "eCtaStopOrder"
|
||||
|
||||
INTERVAL_DELTA_MAP = {
|
||||
Interval.MINUTE: timedelta(minutes=1),
|
||||
Interval.HOUR: timedelta(hours=1),
|
||||
Interval.DAILY: timedelta(days=1),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user