小白请教utility里的函数比如布林带的源码:
def boll(
self,
n: int,
dev: float,
array: bool = False
) -> Union[
Tuple[np.ndarray, np.ndarray],
Tuple[float, float]
]:
"""
Bollinger Channel.
"""
mid: Union[float, np.ndarray] = self.sma(n, array)
std: Union[float, np.ndarray] = self.std(n, 1, array)
up: Union[float, np.ndarray] = mid + std * dev
down: Union[float, np.ndarray] = mid - std * dev
return up, down
如果策略最大只需要30根K线数据,为了提升性能是否有必要将最后一行改为
result:up, down
if array:
return result
return result[-30]
其他函数依次类推?