[bug fix]

This commit is contained in:
msincenselee 2020-04-10 16:39:30 +08:00
parent 1e95f7bd76
commit 78c592a118
6 changed files with 39 additions and 14 deletions

View File

@ -33,7 +33,7 @@ for underlying_symbol in api_01.future_contracts.keys():
index_symbol = underlying_symbol + '99'
print(f'开始更新:{index_symbol}')
# csv数据文件名
bar_file_path = os.path.abspath(os.path.join(bar_data_folder, f'{underlying_symbol}99_{start_date}_1m.csv'))
bar_file_path = os.path.abspath(os.path.join(bar_data_folder, 'tdx', f'{underlying_symbol}99_{start_date}_1m.csv'))
# 如果文件存在,
if os.path.exists(bar_file_path):

View File

@ -545,8 +545,8 @@ class BackTestingEngine(object):
for symbol, symbol_data in data_dict.items():
self.write_log(u'配置{}数据:{}'.format(symbol, symbol_data))
self.set_price_tick(symbol, symbol_data.get('price_tick', 1))
self.set_volume_tick(symbol, symbol_data.get('min_volume', 1))
self.set_price_tick(symbol, symbol_data.get('price_tick', 0.01))
self.set_volume_tick(symbol, symbol_data.get('min_volume', 0.01))
self.set_slippage(symbol, symbol_data.get('slippage', 0))
self.set_size(symbol, symbol_data.get('symbol_size', 10))
margin_rate = symbol_data.get('margin_rate', 0.1)
@ -561,7 +561,7 @@ class BackTestingEngine(object):
product=Product(symbol_data.get('product', "期货")),
size=symbol_data.get('symbol_size', 10),
price_tick=symbol_data.get('price_tick', 0.01),
volume_tick=symbol_data.get('min_volume', 0.1),
volume_tick=symbol_data.get('min_volume', 0.01),
margin_rate=margin_rate
)
@ -827,7 +827,7 @@ class BackTestingEngine(object):
direction=direction,
offset=offset,
type=order_type,
price=round_to(value=price, target=self.get_price_tick(symbol)),
price=round_to(value=price, target=self.get_price_tick(vt_symbol)),
volume=volume,
status=Status.NOTTRADED,
time=str(self.last_dt)

View File

@ -194,7 +194,7 @@ class CtaTemplate(ABC):
"""
Send buy order to open a long position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_upper_limit(vt_symbol):
self.write_error(u'涨停价不做FAK/FOK委托')
return []
@ -214,7 +214,7 @@ class CtaTemplate(ABC):
"""
Send sell order to close a long position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_lower_limit(vt_symbol):
self.write_error(u'跌停价不做FAK/FOK sell委托')
return []
@ -234,7 +234,7 @@ class CtaTemplate(ABC):
"""
Send short order to open as short position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_lower_limit(vt_symbol):
self.write_error(u'跌停价不做FAK/FOK short委托')
return []
@ -254,7 +254,7 @@ class CtaTemplate(ABC):
"""
Send cover order to close a short position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_upper_limit(vt_symbol):
self.write_error(u'涨停价不做FAK/FOK cover委托')
return []

View File

@ -193,7 +193,7 @@ class CtaTemplate(ABC):
"""
Send buy order to open a long position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_upper_limit(vt_symbol):
self.write_error(u'涨停价不做FAK/FOK委托')
return []
@ -214,7 +214,7 @@ class CtaTemplate(ABC):
"""
Send sell order to close a long position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_lower_limit(vt_symbol):
self.write_error(u'跌停价不做FAK/FOK sell委托')
return []
@ -235,7 +235,7 @@ class CtaTemplate(ABC):
"""
Send short order to open as short position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_lower_limit(vt_symbol):
self.write_error(u'跌停价不做FAK/FOK short委托')
return []
@ -256,7 +256,7 @@ class CtaTemplate(ABC):
"""
Send cover order to close a short position.
"""
if OrderType in [OrderType.FAK, OrderType.FOK]:
if order_type in [OrderType.FAK, OrderType.FOK]:
if self.is_upper_limit(vt_symbol):
self.write_error(u'涨停价不做FAK/FOK cover委托')
return []

View File

@ -759,6 +759,10 @@ class CtaLineBar(object):
def on_bar(self, bar: BarData):
"""OnBar事件"""
if not bar.interval:
bar.interval = self.interval
bar.interval_num = self.bar_interval
# 计算相关数据
bar_mid3 = round((bar.close_price + bar.high_price + bar.low_price) / 3, self.round_n)
bar_mid4 = round((2 * bar.close_price + bar.high_price + bar.low_price) / 4, self.round_n)
@ -816,7 +820,7 @@ class CtaLineBar(object):
# 回调上层调用者
if self.cb_on_bar:
self.cb_on_bar(bar)
self.cb_on_bar(bar=bar)
def check_rt_funcs(self, func):
"""
@ -3621,6 +3625,24 @@ class CtaLineBar(object):
return False
@property
def rt_skd_dead_cross(self):
"""是否实时SKD死叉"""
ret = self.is_skd_high_dead_cross(runtime=True, high_skd=15) and \
self.cur_skd_count > 0 and \
self.rt_skd_cross_price > 0 and \
self.cur_price <= self.rt_skd_cross_price
return ret
@property
def rt_skd_golden_cross(self):
"""是否实时SKD金叉"""
ret = self.is_skd_low_golden_cross(runtime=True, low_skd=85) and \
self.cur_skd_count < 0 and \
self.rt_skd_cross_price > 0 and \
self.cur_price >= self.rt_skd_cross_price
return ret
def is_skd_high_dead_cross(self, runtime=False, high_skd=None):
"""
检查是否高位死叉

View File

@ -118,6 +118,9 @@ class MainWindow(QtWidgets.QMainWindow):
all_apps = self.main_engine.get_all_apps()
for app in all_apps:
try:
if getattr(app, 'widget_name') is None:
continue
ui_module = import_module(app.app_module + ".ui")
widget_class = getattr(ui_module, app.widget_name)