Skip to content

Commit

Permalink
refractor
Browse files Browse the repository at this point in the history
  • Loading branch information
51bitquant committed Jun 10, 2023
1 parent c11396a commit e5ab85e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions cta_script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys

from time import sleep
from datetime import datetime, time
from logging import INFO

from howtrader.event import EventEngine
Expand All @@ -24,6 +23,7 @@
"proxy_port": 0,
}


def run():
"""
Running in the child process.
Expand All @@ -36,7 +36,7 @@ def run():
cta_engine: CtaEngine = main_engine.add_app(CtaStrategyApp)
main_engine.write_log("setup main engine")

log_engine: LogEngine = main_engine.get_engine("log")
log_engine: LogEngine = main_engine.get_engine("log")
event_engine.register(EVENT_CTA_LOG, log_engine.process_log_event)
main_engine.write_log("register event listener")

Expand All @@ -58,5 +58,6 @@ def run():
while True:
sleep(10)


if __name__ == "__main__":
run()
2 changes: 1 addition & 1 deletion examples/backtest_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
setting.add_parameter("atr_ma_length", 10, 30, 1)

result = engine.run_ga_optimization(setting) # 优化策略参数
print(result) # 打印回测的结果,结果中会有比较好的结果值。
print(result) # 打印回测的结果,结果中会有比较好的结果值。
2 changes: 1 addition & 1 deletion main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def main():

# if you don't use
# main_engine.add_app(DataManagerApp)
# main_engine.add_app(AlgoTradingApp)
# main_engine.add_app(DataRecorderApp)
# main_engine.add_app(AlgoTradingApp)
# main_engine.add_app(RiskManagerApp)
# main_engine.add_app(SpreadTradingApp)

Expand Down
5 changes: 4 additions & 1 deletion tv_script.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

from time import sleep
from logging import INFO

Expand Down Expand Up @@ -46,18 +47,19 @@ def webhook():
def start_tv_server():
app.run(host="127.0.0.1", port=port)


SETTINGS["log.active"] = True
SETTINGS["log.level"] = INFO
SETTINGS["log.console"] = True


usdt_gateway_setting = {
"key": "",
"secret": "",
"proxy_host": "",
"proxy_port": 0,
}


def run():
"""
Running in the child process.
Expand Down Expand Up @@ -109,5 +111,6 @@ def run():
while True:
sleep(10)


if __name__ == "__main__":
run()

0 comments on commit e5ab85e

Please sign in to comment.