File "/tmp/strategy/user_code.py", line 359, in order_target_value_y
return order_target_value_(context,securityy,value)
NameError: name 'context' is not defined
按这个配置聚宽回测端,为啥会这样
老师,请问我的策略下单函数已经按照要求加了下划线(问题没显示出来)改成这样
def open_position(security, value):
order = order_target_value_(context,security, value)
return order is not None and order.filled > 0
def close_position(position):
order = order_target_value__ (context,position.security, 0)
return order is not None
为什么报错" File "/tmp/strategy/user_code.py", line 749, in open_position
order = order_target_value_(context,security, value)
NameError: name 'context' is not defined"
谢谢~
抱歉,通过查找以往的聊天记录,发现是自己的错误。已解决。谢谢。
-----------------------------
日志输出错误日志
2024-10-08 14:40:00 - INFO - {'time': '2024-10-08 14:40:00', 'action': 'BUY', 'code': '002718.XSHE', 'pct': 0.1979, 'strategy': 'smallgo'}
2024-10-08 14:40:00 - ERROR - TypeError("int() argument must be a string, a bytes-like object or a number, not 'tuple'",)
2024-10-08 14:40:00 - INFO - {'time': '2024-10-08 14:40:00', 'action': 'BUY', 'code': '002830.XSHE', 'pct': 0.2357, 'strategy': 'smallgo'}
2024-10-08 14:40:00 - ERROR - TypeError("int() argument must be a string, a bytes-like object or a number, not 'tuple'",)
2024-10-08 14:40:00 - INFO - {'time': '2024-10-08 14:40:00', 'action': 'BUY', 'code': '002629.XSHE', 'pct': 0.325, 'strategy': 'smallgo'}
2024-10-08 14:40:00 - ERROR - TypeError("int() argument must be a string, a bytes-like object or a number, not 'tuple'",)
2024-10-08 14:40:00 - INFO - {'time': '2024-10-08 14:40:00', 'action': 'BUY', 'code': '003023.XSHE', 'pct': 0.4625, 'strategy': 'smallgo'}
2024-10-08 14:40:00 - ERROR - TypeError("int() argument must be a string, a bytes-like object or a number, not 'tuple'",)
2024-10-08 14:40:00 - INFO - {'time': '2024-10-08 14:40:00', 'action': 'BUY', 'code': '002620.XSHE', 'pct': 0.8877, 'strategy': 'smallgo'}
2024-10-08 14:40:00 - ERROR - TypeError("int() argument must be a string, a bytes-like object or a number, not 'tuple'",)
2024-10-09 14:40:00 - INFO - {'time': '2024-10-09 14:40:00', 'action': 'SELL', 'code': '002629.XSHE', 'pct': 0.0, 'strategy': 'smallgo'}
2024-10-09 14:40:00 - ERROR - TypeError("int() argument must be a string, a bytes-like object or a number, not 'tuple'",)