| | |
| | | from strategy.strategy_variable import StockVariables |
| | | |
| | | if __name__ == "__main__": |
| | | global_dict = {'x': 10} |
| | | codes = "" |
| | | with open("低吸脚本.py", mode='r', encoding='utf-8') as f: |
| | | lines = f.readlines() |
| | | codes = "\n".join(lines) |
| | | # 注释掉里面的import与变量 |
| | | codes = codes.replace("from ", "#from ").replace("sv = ", "#sv = ") |
| | | |
| | | stock_variables = StockVariables() |
| | | stock_variables.当前价 = 10.23 |
| | | stock_variables.昨日最高价 = 10.00 |
| | | global_dict = { |
| | | "sv": stock_variables} |
| | | exec(codes, global_dict) |
| | | print(global_dict['compute_result']) |
| | | # 统计当日的平均溢价率 |
| | | def statistic_average(): |
| | | rate_list = [] |
| | | with open(r"C:\Users\Administrator\Desktop\3个票涨停之后买.txt", mode='r', encoding='utf-8') as f: |
| | | lines = f.readlines() |
| | | for line in lines: |
| | | if line.find('回测结果:') < 0: |
| | | continue |
| | | if line.find('当日盈亏:') < 0: |
| | | continue |
| | | r = round(float(line.split("当日盈亏:")[1].split(",")[0].replace("%", "")), 2) |
| | | rate_list.append(r) |
| | | print("平均利润率:", round(sum(rate_list) / len(rate_list), 2)) |
| | | print("总利润率:", round(sum(rate_list), 2)) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | statistic_average() |