获取旧系列数据的问题(金融为Python)

发布于 2025-02-11 00:28:27 字数 921 浏览 2 评论 0原文

我已经转换了这个公式( 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(..),但都没有返回确切的结果。 我可以使用库pandasnumpy

有什么观点?

I've converted this formula (ZLEMA Moving Average)

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深已缘浅 2025-02-18 00:28:27

已解决:

只需使用source.shift(zxlag)

SOLVED:

Simply using source.shift(zxLag)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文