We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
myTT中现在的SLOPE函数:
def SLOPE(S, N, RS=False): # 返S序列N周期回线性回归斜率 (默认只返回斜率,不返回整个直线序列) M = pd.Series(S[-N:]) poly = np.polyfit(M.index, M.values, deg=1) Y = np.polyval(poly, M.index) if RS: return Y[1] - Y[0], Y return Y[1] - Y[0]
存在如下问题: 1) 有三个参数,与通达信不一致; 2)违背了array in, array out的原则; 3)写法繁琐
array in, array out
特修改如下:
def SLOPE(S, N): # type: (np.ndarray, int) -> np.ndarray """ 通达信SLOPE。返S序列N周期回线性回归斜率,N暂时不支持变量。 """ M = pd.Series(S) return M.rolling(window=N).apply(lambda y: np.polyfit(y.index, y.values, deg=1)[0], raw=False)
The text was updated successfully, but these errors were encountered:
def SLOPE(S, N): #返S序列N周期回线性回归斜率 return pd.Series(S).rolling(N).apply(lambda x: np.polyfit(x.index,x.values,deg=1)[0],raw=False).values
感谢! FORCAST() 还需要研究
Sorry, something went wrong.
def FORCAST(S,N): #返S序列N周期回线性回归后的预测值 M=pd.Series(S[-N:]); poly = np.polyfit(M.index, M.values,deg=1); return np.polyval(poly, M.index)[-1]
还是只能返回最后单值
2021年11月12日修改
def slope(S, N): # type: (np.ndarray, int) -> np.ndarray """ 通达信SLOPE。返S序列N周期回线性回归斜率,N暂时不支持变量。 """ return pd.Series(S).rolling(window=N).apply(lambda y: np.polyfit(range(N), y, deg=1)[0], raw=False).values
No branches or pull requests
myTT中现在的SLOPE函数:
存在如下问题:
1) 有三个参数,与通达信不一致;
2)违背了
array in, array out
的原则;3)写法繁琐
特修改如下:
The text was updated successfully, but these errors were encountered: