天择加密量化开放框架下载
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.0 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. # -*- coding: utf-8 -*-
  2. # tzquant
  3. import os
  4. import shutil
  5. import numpy as np
  6. # 定义要移动的目录列表
  7. directories_to_move = ['tz_ctastrategy', 'tzquant', 'tzqtdatahub', 'tz_riskmanager', 'gate_api']
  8. # 获取numpy模块的__file__属性,它包含了numpy模块文件的路径
  9. numpy_file_path = np.__file__
  10. # 使用os.path模块来获取numpy所在的目录
  11. numpy_dir = os.path.dirname(numpy_file_path)
  12. # 获取numpy所在目录的上层目录
  13. parent_dir = os.path.dirname(numpy_dir)
  14. # 打印上层目录,用于验证
  15. print("NumPy所在目录的上层目录是: ", parent_dir)
  16. # 确保parent_dir已经定义,并准备移动目录
  17. for directory in directories_to_move:
  18. # 构建源目录和目标目录的路径
  19. source_path = os.path.join(os.getcwd(), directory)
  20. target_path = os.path.join(parent_dir, directory)
  21. # 检查源目录是否存在
  22. if os.path.isdir(source_path):
  23. # 使用shutil.move来移动目录
  24. if os.path.exists(target_path):
  25. if os.path.isdir(target_path):
  26. shutil.rmtree(target_path) # 删除整个目录及其内容
  27. else:
  28. os.remove(target_path) # 删除文件
  29. shutil.move(source_path, target_path)
  30. print(f"Moved {directory} to {target_path}")
  31. else:
  32. print(f"Directory {directory} does not exist in the current directory.")
  33. # 移动完成后,可以打印确认信息
  34. print("All directories have been moved to the parent directory of NumPy installation.")
  35. import os
  36. import sys
  37. import time
  38. import pandas as pd
  39. from datetime import datetime
  40. from tz_ctastrategy import (
  41. ArrayManager,
  42. BarData,
  43. BarGenerator,
  44. CtaTemplate,
  45. OrderData,
  46. StopOrder,
  47. TickData,
  48. TradeData,
  49. )
  50. from tz_ctastrategy.backtesting_mul import BacktestingEngine
  51. from tz_ctastrategy.template import CtaTemplate
  52. from tzquant.trader.constant import OrderType
  53. from tzquant.trader.object import *