Skip to content
New issue

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

CROSS函数计算结果处理错误,修正建议 #36

Open
ghost0917 opened this issue Aug 19, 2022 · 2 comments
Open

CROSS函数计算结果处理错误,修正建议 #36

ghost0917 opened this issue Aug 19, 2022 · 2 comments

Comments

@ghost0917
Copy link

def CROSS(S1, S2): # 判断向上金叉穿越 CROSS(MA(C,5),MA(C,10)) 判断向下死叉穿越 CROSS(MA(C,10),MA(C,5))
return np.concatenate(([False], np.logical_not((S1>S2)[:-1]) & (S1>S2)[1:])) # 不使用0级函数,移植方便 by jqz1226

改成:
def CROSS(S1, S2): # 判断向上金叉穿越 CROSS(MA(C,5),MA(C,10)) 判断向下死叉穿越 CROSS(MA(C,10),MA(C,5))
return np.concatenate(([False], np.logical_not((S1 > S2)[:-1]) & (S1 > S2)[1:].reset_index(drop=True)))

@tgmnb
Copy link

tgmnb commented Sep 11, 2023

我也遇到这个问题,修正有效

@hotwind2015
Copy link

计算结果确实与同花顺的有出入,改成如下代码后,结果一致了:

def CROSS(S1, S2):                  
    res = pd.Series(S1) > pd.Series(S2)
    return ((res == True) & (res.shift(-1) == False)).shift()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants