Created
January 24, 2020 06:32
-
-
Save swr1bm86/06608e822d27e4fba8509fa5266e1d09 to your computer and use it in GitHub Desktop.
display infinite and finite ema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import plotly.graph_objects as go | |
from finta import TA | |
if __name__ == '__main__': | |
ts = pd.date_range('1/1/2000', periods=100) | |
price = pd.DataFrame(np.random.randn(100, 1), index=ts, columns=['close']) | |
# https://blog.csdn.net/Papageno_Xue/article/details/82705157 | |
ema_finite = TA.EMA(price) | |
ema_infinite = TA.EMA(price, adjust=False) | |
fig = go.Figure() | |
fig.add_trace(go.Scatter(x=ts, y=price.iloc[:, 0], | |
mode='lines', | |
name='price')) | |
fig.add_trace(go.Scatter(x=ts, y=ema_finite, | |
mode='lines', | |
name='ema-finite')) | |
fig.add_trace(go.Scatter(x=ts, y=ema_infinite, | |
mode='lines', | |
name='ema-infinite')) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the infinite and finite EMA will only diverge at the very first beginning period