48 lines
1.5 KiB
Bash
48 lines
1.5 KiB
Bash
import os
|
|
import shutil
|
|
|
|
# 定义源目录
|
|
source_dir = "./result"
|
|
|
|
# 定义目标目录和文件名
|
|
target_strategy_path = "./freqtrade/template/FreqaiExampleStrategy.py"
|
|
target_config_path = "./config_examples/config_freqai.okx.json"
|
|
|
|
# 查找 *FreqaiExampleStrategy.py 文件
|
|
strategy_file = None
|
|
for file in os.listdir(source_dir):
|
|
if file.endswith("FreqaiExampleStrategy.py"):
|
|
strategy_file = os.path.join(source_dir, file)
|
|
break
|
|
|
|
# 查找 *config.json 文件
|
|
config_file = None
|
|
for file in os.listdir(source_dir):
|
|
if file.endswith("config.json"):
|
|
config_file = os.path.join(source_dir, file)
|
|
break
|
|
|
|
# 复制 *FreqaiExampleStrategy.py 文件
|
|
if strategy_file:
|
|
try:
|
|
target_strategy_dir = os.path.dirname(target_strategy_path)
|
|
os.makedirs(target_strategy_dir, exist_ok=True)
|
|
shutil.copy2(strategy_file, target_strategy_path)
|
|
print(f"成功复制 {strategy_file} 到 {target_strategy_path}")
|
|
except Exception as e:
|
|
print(f"复制 {strategy_file} 时出错: {e}")
|
|
else:
|
|
print("未找到 *FreqaiExampleStrategy.py 文件")
|
|
|
|
# 复制 *config.json 文件
|
|
if config_file:
|
|
try:
|
|
target_config_dir = os.path.dirname(target_config_path)
|
|
os.makedirs(target_config_dir, exist_ok=True)
|
|
shutil.copy2(config_file, target_config_path)
|
|
print(f"成功复制 {config_file} 到 {target_config_path}")
|
|
except Exception as e:
|
|
print(f"复制 {config_file} 时出错: {e}")
|
|
else:
|
|
print("未找到 *config.json 文件")
|