This commit is contained in:
vn.py 2019-09-17 23:28:36 +08:00
parent 8baafc5cf9
commit 0c1dc817b9
2 changed files with 18 additions and 12 deletions

View File

@ -76,7 +76,7 @@ def main():
main_engine.add_gateway(CoinbaseGateway) main_engine.add_gateway(CoinbaseGateway)
main_engine.add_app(CtaStrategyApp) main_engine.add_app(CtaStrategyApp)
# main_engine.add_app(CtaBacktesterApp) main_engine.add_app(CtaBacktesterApp)
# main_engine.add_app(CsvLoaderApp) # main_engine.add_app(CsvLoaderApp)
# main_engine.add_app(AlgoTradingApp) # main_engine.add_app(AlgoTradingApp)
# main_engine.add_app(DataRecorderApp) # main_engine.add_app(DataRecorderApp)

View File

@ -354,9 +354,12 @@ class BacktesterEngine(BaseEngine):
contract = self.main_engine.get_contract(vt_symbol) contract = self.main_engine.get_contract(vt_symbol)
try:
# If history data provided in gateway, then query # If history data provided in gateway, then query
if contract and contract.history_data: if contract and contract.history_data:
data = self.main_engine.query_history(req, contract.gateway_name) data = self.main_engine.query_history(
req, contract.gateway_name
)
# Otherwise use RQData to query data # Otherwise use RQData to query data
else: else:
data = rqdata_client.query_history(req) data = rqdata_client.query_history(req)
@ -366,6 +369,9 @@ class BacktesterEngine(BaseEngine):
self.write_log(f"{vt_symbol}-{interval}历史数据下载完成") self.write_log(f"{vt_symbol}-{interval}历史数据下载完成")
else: else:
self.write_log(f"数据下载失败,无法获取{vt_symbol}的历史数据") self.write_log(f"数据下载失败,无法获取{vt_symbol}的历史数据")
except Exception:
msg = f"数据下载失败,触发异常:\n{traceback.format_exc()}"
self.write_log(msg)
# Clear thread object handler. # Clear thread object handler.
self.thread = None self.thread = None