dededdew
This commit is contained in:
@@ -149,7 +149,7 @@ if __name__ == '__main__':
|
||||
|
||||
datas = sorted(datas, key=lambda x: x["id"])
|
||||
|
||||
for i in range(1, 11):
|
||||
for i in range(1, 51):
|
||||
for i1 in range(1, 51):
|
||||
|
||||
zh_project = 0 # 累计盈亏
|
||||
|
||||
@@ -266,37 +266,37 @@ def backtest(dates, tp, sl):
|
||||
# ===============================================================
|
||||
|
||||
if __name__ == '__main__':
|
||||
dates = [f"2025-6-{i}" for i in range(1, 31)]
|
||||
dates = [f"2025-9-{i}" for i in range(1, 31)]
|
||||
|
||||
for i in range(1, 11):
|
||||
for i1 in range(1, 51):
|
||||
# for i in range(1, 11):
|
||||
# for i1 in range(1, 51):
|
||||
|
||||
trades, stats = backtest(dates, tp=i1, sl=-i)
|
||||
trades, stats = backtest(dates, tp=15, sl=-50)
|
||||
|
||||
# logger.info("===== 每笔交易详情 =====")
|
||||
# for t in trades:
|
||||
# logger.info(
|
||||
# f"{t['entry_time']} {t['direction']}({t['signal']}) "
|
||||
# f"入场={t['entry']:.2f} 出场={t['exit']:.2f} 出场时间={t['exit_time']} "
|
||||
# f"差价={t['diff']:.2f}"
|
||||
# )
|
||||
# logger.info("===== 每笔交易详情 =====")
|
||||
# for t in trades:
|
||||
# logger.info(
|
||||
# f"{t['entry_time']} {t['direction']}({t['signal']}) "
|
||||
# f"入场={t['entry']:.2f} 出场={t['exit']:.2f} 出场时间={t['exit_time']} "
|
||||
# f"差价={t['diff']:.2f}"
|
||||
# )
|
||||
|
||||
total_profit = sum(t['diff'] / t['entry'] * 10000 for t in trades)
|
||||
total_fee = sum(5 + 10000 / t['entry'] * t['exit'] * 0.0005 for t in trades)
|
||||
total_profit = sum(t['diff'] / t['entry'] * 10000 for t in trades)
|
||||
total_fee = sum(5 + 10000 / t['entry'] * t['exit'] * 0.0005 for t in trades)
|
||||
|
||||
# print(f"\n一共交易笔数:{len(trades)}")
|
||||
# print(f"一共盈利:{total_profit:.2f}")
|
||||
# print(f"一共手续费:{total_fee:.2f}")
|
||||
# print(f"净利润:{total_profit - total_fee:.2f}")
|
||||
print(f"\n一共交易笔数:{len(trades)}")
|
||||
print(f"一共盈利:{total_profit:.2f}")
|
||||
print(f"一共手续费:{total_fee:.2f}")
|
||||
print(f"净利润:{total_profit - total_fee:.2f}")
|
||||
|
||||
if total_profit > total_fee * 0.1:
|
||||
print(f"止盈:{i1}, 止损:{i}")
|
||||
print(f"\n一共交易笔数:{len(trades)}")
|
||||
print(f"一共盈利:{total_profit:.2f}")
|
||||
print(f"一共手续费:{total_fee:.2f}")
|
||||
print(f"净利润:{total_profit - total_fee * 0.1}")
|
||||
|
||||
print("\n===== 信号统计 =====")
|
||||
# if total_profit > total_fee * 0.1:
|
||||
# print(f"止盈:{i1}, 止损:{i}")
|
||||
# print(f"\n一共交易笔数:{len(trades)}")
|
||||
# print(f"一共盈利:{total_profit:.2f}")
|
||||
# print(f"一共手续费:{total_fee:.2f}")
|
||||
# print(f"净利润:{total_profit - total_fee * 0.1}")
|
||||
#
|
||||
# print("\n===== 信号统计 =====")
|
||||
#
|
||||
# for k, v in stats.items():
|
||||
# win_rate = (v['wins'] / v['count'] * 100) if v['count'] > 0 else 0
|
||||
|
||||
Reference in New Issue
Block a user