[bug fix]
This commit is contained in:
parent
1e95f7bd76
commit
78c592a118
@ -33,7 +33,7 @@ for underlying_symbol in api_01.future_contracts.keys():
|
|||||||
index_symbol = underlying_symbol + '99'
|
index_symbol = underlying_symbol + '99'
|
||||||
print(f'开始更新:{index_symbol}')
|
print(f'开始更新:{index_symbol}')
|
||||||
# csv数据文件名
|
# 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):
|
if os.path.exists(bar_file_path):
|
||||||
|
@ -545,8 +545,8 @@ class BackTestingEngine(object):
|
|||||||
|
|
||||||
for symbol, symbol_data in data_dict.items():
|
for symbol, symbol_data in data_dict.items():
|
||||||
self.write_log(u'配置{}数据:{}'.format(symbol, symbol_data))
|
self.write_log(u'配置{}数据:{}'.format(symbol, symbol_data))
|
||||||
self.set_price_tick(symbol, symbol_data.get('price_tick', 1))
|
self.set_price_tick(symbol, symbol_data.get('price_tick', 0.01))
|
||||||
self.set_volume_tick(symbol, symbol_data.get('min_volume', 1))
|
self.set_volume_tick(symbol, symbol_data.get('min_volume', 0.01))
|
||||||
self.set_slippage(symbol, symbol_data.get('slippage', 0))
|
self.set_slippage(symbol, symbol_data.get('slippage', 0))
|
||||||
self.set_size(symbol, symbol_data.get('symbol_size', 10))
|
self.set_size(symbol, symbol_data.get('symbol_size', 10))
|
||||||
margin_rate = symbol_data.get('margin_rate', 0.1)
|
margin_rate = symbol_data.get('margin_rate', 0.1)
|
||||||
@ -561,7 +561,7 @@ class BackTestingEngine(object):
|
|||||||
product=Product(symbol_data.get('product', "期货")),
|
product=Product(symbol_data.get('product', "期货")),
|
||||||
size=symbol_data.get('symbol_size', 10),
|
size=symbol_data.get('symbol_size', 10),
|
||||||
price_tick=symbol_data.get('price_tick', 0.01),
|
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
|
margin_rate=margin_rate
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ class BackTestingEngine(object):
|
|||||||
direction=direction,
|
direction=direction,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
type=order_type,
|
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,
|
volume=volume,
|
||||||
status=Status.NOTTRADED,
|
status=Status.NOTTRADED,
|
||||||
time=str(self.last_dt)
|
time=str(self.last_dt)
|
||||||
|
@ -194,7 +194,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send buy order to open a long position.
|
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):
|
if self.is_upper_limit(vt_symbol):
|
||||||
self.write_error(u'涨停价不做FAK/FOK委托')
|
self.write_error(u'涨停价不做FAK/FOK委托')
|
||||||
return []
|
return []
|
||||||
@ -214,7 +214,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send sell order to close a long position.
|
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):
|
if self.is_lower_limit(vt_symbol):
|
||||||
self.write_error(u'跌停价不做FAK/FOK sell委托')
|
self.write_error(u'跌停价不做FAK/FOK sell委托')
|
||||||
return []
|
return []
|
||||||
@ -234,7 +234,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send short order to open as short position.
|
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):
|
if self.is_lower_limit(vt_symbol):
|
||||||
self.write_error(u'跌停价不做FAK/FOK short委托')
|
self.write_error(u'跌停价不做FAK/FOK short委托')
|
||||||
return []
|
return []
|
||||||
@ -254,7 +254,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send cover order to close a short position.
|
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):
|
if self.is_upper_limit(vt_symbol):
|
||||||
self.write_error(u'涨停价不做FAK/FOK cover委托')
|
self.write_error(u'涨停价不做FAK/FOK cover委托')
|
||||||
return []
|
return []
|
||||||
|
@ -193,7 +193,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send buy order to open a long position.
|
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):
|
if self.is_upper_limit(vt_symbol):
|
||||||
self.write_error(u'涨停价不做FAK/FOK委托')
|
self.write_error(u'涨停价不做FAK/FOK委托')
|
||||||
return []
|
return []
|
||||||
@ -214,7 +214,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send sell order to close a long position.
|
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):
|
if self.is_lower_limit(vt_symbol):
|
||||||
self.write_error(u'跌停价不做FAK/FOK sell委托')
|
self.write_error(u'跌停价不做FAK/FOK sell委托')
|
||||||
return []
|
return []
|
||||||
@ -235,7 +235,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send short order to open as short position.
|
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):
|
if self.is_lower_limit(vt_symbol):
|
||||||
self.write_error(u'跌停价不做FAK/FOK short委托')
|
self.write_error(u'跌停价不做FAK/FOK short委托')
|
||||||
return []
|
return []
|
||||||
@ -256,7 +256,7 @@ class CtaTemplate(ABC):
|
|||||||
"""
|
"""
|
||||||
Send cover order to close a short position.
|
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):
|
if self.is_upper_limit(vt_symbol):
|
||||||
self.write_error(u'涨停价不做FAK/FOK cover委托')
|
self.write_error(u'涨停价不做FAK/FOK cover委托')
|
||||||
return []
|
return []
|
||||||
|
@ -759,6 +759,10 @@ class CtaLineBar(object):
|
|||||||
|
|
||||||
def on_bar(self, bar: BarData):
|
def on_bar(self, bar: BarData):
|
||||||
"""OnBar事件"""
|
"""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_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)
|
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:
|
if self.cb_on_bar:
|
||||||
self.cb_on_bar(bar)
|
self.cb_on_bar(bar=bar)
|
||||||
|
|
||||||
def check_rt_funcs(self, func):
|
def check_rt_funcs(self, func):
|
||||||
"""
|
"""
|
||||||
@ -3621,6 +3625,24 @@ class CtaLineBar(object):
|
|||||||
|
|
||||||
return False
|
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):
|
def is_skd_high_dead_cross(self, runtime=False, high_skd=None):
|
||||||
"""
|
"""
|
||||||
检查是否高位死叉
|
检查是否高位死叉
|
||||||
|
@ -118,6 +118,9 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
all_apps = self.main_engine.get_all_apps()
|
all_apps = self.main_engine.get_all_apps()
|
||||||
for app in all_apps:
|
for app in all_apps:
|
||||||
try:
|
try:
|
||||||
|
if getattr(app, 'widget_name') is None:
|
||||||
|
continue
|
||||||
|
|
||||||
ui_module = import_module(app.app_module + ".ui")
|
ui_module = import_module(app.app_module + ".ui")
|
||||||
widget_class = getattr(ui_module, app.widget_name)
|
widget_class = getattr(ui_module, app.widget_name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user