天择加密量化开放框架下载
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.

68 lines
2.1 KiB

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