我是python的新手,程序Main
和CommonFunctions
中有两个方法。
在Main
下,我从CommonFunctions
调用函数名称技术
@staticmethod
def tech(df, ACslow_period = None, ACfast_period = None):
slow = pd.Series(((df[2] + df[3]) / 2).rolling(window=ACslow_period).mean())
fast = pd.Series(((df[2] + df[3]) / 2).rolling(window=ACfast_period).mean())
df[40] = pd.Series(fast - slow)
df[41] = pd.Series(((df[40])).rolling(ACfast_period).mean())
df[52] = (pd.Series(df[40] - df[41])))
return (df)
当我直接从文件中测试公式时,结果是:
self.CommonFunctions.tech(df, ACslow_period = 340, ACfast_period = 30)
40 41 52
0.000000109858 0.000000063136 0.000000046722
0.000000111809 0.000000064952 0.000000046857
0.000000113985 0.000000066986 0.000000046999
但是当我运行程序时,结果是:
self.CommonFunctions.tech(df, ACslow_period = 340, ACfast_period = 30)
40 41 52
-0.000000109858 0.000000000000 0.000000000000
-0.000000111809 0.000000000000 0.000000000000
-0.000000113985 0.000000000000 0.000000000000
使用以下数据:
file = https://pastebin.com/raw/WtBu2zh2
有人知道为什么结果会有所不同吗?
提前谢谢!