From fca99969ff549ab61c284a55ba77cb4306903493 Mon Sep 17 00:00:00 2001 From: easonxu77 Date: Thu, 6 Mar 2025 17:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=9E=E6=B5=8B=E3=80=81?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=92=8C=E5=AE=9E=E7=9B=98=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example_run.py | 26 ++++++++++++++++++++++++++ mycode.py | 0 2 files changed, 26 insertions(+) create mode 100644 example_run.py create mode 100644 mycode.py diff --git a/example_run.py b/example_run.py new file mode 100644 index 00000000..f28321a9 --- /dev/null +++ b/example_run.py @@ -0,0 +1,26 @@ +from datetime import date +from tqsdk import TqApi, TqSim, TqAccount, TqBacktest, TqAuth + +def run_backtest(): + api = TqApi(backtest=TqBacktest(start_dt=date(2021, 1, 1), end_dt=date(2021, 12, 31)), web_gui=True, auth=TqAuth("13760685574", "xdy19870920")) + +def run_simulation(): + api = TqApi(TqSim(init_balance=100000), web_gui=True, auth=TqAuth("13760685574", "xdy19870920")) + +def run_real_trading(): + api = TqApi(TqAccount("期货公司", "账户", "密码"), web_gui=True, auth=TqAuth("13760685574", "xdy19870920")) + +def main(): + print("请选择运行模式: 1. 回测 2. 模拟 3. 实盘") + choice = input("输入选择(1/2/3): ") + if choice == '1': + run_backtest() + elif choice == '2': + run_simulation() + elif choice == '3': + run_real_trading() + else: + print("无效选择,请输入1, 2或3") + +if __name__ == "__main__": + main() diff --git a/mycode.py b/mycode.py new file mode 100644 index 00000000..e69de29b