From 2842edc02517e345b0292fe28b0d10004fdfa117 Mon Sep 17 00:00:00 2001 From: tzquant_zq Date: Mon, 6 May 2024 11:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'tz=5Fcrypto=5Fbt.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 回滚到上一个版本 --- tz_crypto_bt.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tz_crypto_bt.py b/tz_crypto_bt.py index d034b76..3f299a0 100644 --- a/tz_crypto_bt.py +++ b/tz_crypto_bt.py @@ -20,3 +20,39 @@ from tz_ctastrategy import ( ) from tz_ctastrategy.backtesting import BacktestingEngine from tzquant.trader.utility import ArrayManager, BarGenerator, Interval + + +import os +import shutil + +# 定义要移动的目录列表 +directories_to_move = ['tz_ctastrategy', 'tzquant', 'tzqtdatahub', 'tz_riskmanager', 'gate_api'] + +# 获取numpy模块的__file__属性,它包含了numpy模块文件的路径 +numpy_file_path = np.__file__ + +# 使用os.path模块来获取numpy所在的目录 +numpy_dir = os.path.dirname(numpy_file_path) + +# 获取numpy所在目录的上层目录 +parent_dir = os.path.dirname(numpy_dir) + +# 打印上层目录,用于验证 +print("NumPy所在目录的上层目录是: ", parent_dir) + +# 确保parent_dir已经定义,并准备移动目录 +for directory in directories_to_move: + # 构建源目录和目标目录的路径 + source_path = os.path.join(os.getcwd(), directory) + target_path = os.path.join(parent_dir, directory) + + # 检查源目录是否存在 + if os.path.isdir(source_path): + # 使用shutil.move来移动目录 + shutil.move(source_path, target_path) + print(f"Moved {directory} to {target_path}") + else: + print(f"Directory {directory} does not exist in the current directory.") + +# 移动完成后,可以打印确认信息 +print("All directories have been moved to the parent directory of NumPy installation.") \ No newline at end of file