获取旧系列数据的问题(金融为Python)
我已经转换了这个公式( zlema移动平均)
但是我有很多“数据(lag lay day of days of data of data of days of Days)”,看来它无法返回查找结果。这是功能,但不幸的是,它不会产生所需的结果。
def fzlema(source,period):
zxLag = period / 2 if (period / 2) == np.round(period / 2) else (period - 1) / 2
zxLag = int(zxLag)
zxEMAData = source + (source - source.iloc[zxLag]) # Probably error is in this line
zlema = zxEMAData.ewm(span=period, adjust=False).mean()
zlema = np.round(zlema,2)
return zlema
zlema = fzlema(dataframe['close'], 50)
需要明确的是,脚本运行完美,但是我得到的是无与伦比的,因为它是在TradingView上计算的。 我尝试使用使用iLoc [..]
和tail(..)
,但都没有返回确切的结果。 我可以使用库pandas
和numpy
。
有什么观点?
I've converted this formula (ZLEMA Moving Average)
But I have many issues with "Data(Lag Days Ago)", it seems that it cant go back to find the result. Here's the function but unfortunately it doesn't produce the desired result.
def fzlema(source,period):
zxLag = period / 2 if (period / 2) == np.round(period / 2) else (period - 1) / 2
zxLag = int(zxLag)
zxEMAData = source + (source - source.iloc[zxLag]) # Probably error is in this line
zlema = zxEMAData.ewm(span=period, adjust=False).mean()
zlema = np.round(zlema,2)
return zlema
zlema = fzlema(dataframe['close'], 50)
To be clear, the script runs perfectly but what I got is unmatched as it's been calculated on Tradingview.
I tried used iloc[..]
and tail(..)
but neither return exact results.
I can use the libraries pandas
and numpy
.
Any point of view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:
只需使用
source.shift(zxlag)
SOLVED:
Simply using
source.shift(zxLag)