# -*- coding: utf-8 -*- # tzquant import os import sys import time import numpy as np import pandas as pd from datetime import datetime sys.path.append(os.path.abspath('./tz_crypto')) from tz_ctastrategy import ( BarData, CtaTemplate, OrderData, StopOrder, TickData, TradeData, ) 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来移动目录 if os.path.exists(target_path): if os.path.isdir(target_path): shutil.rmtree(target_path) # 删除整个目录及其内容 else: os.remove(target_path) # 删除文件 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.")