Finance6 python - RSI 구하기 ( pandas ) 저번에 스토캐스틱을 구해봤고, 이번에는 파이썬에 판다스를 통해 rsi 를 구해보겠습니다. RSI 우선 코드는 다음과 같습니다. rsi # rsi def rsi(source, length): au = source.diff() ad = source.diff() au[au 0] = 0 au = au.rolling(windows=length).mean() ad = ad.rolling(windows=length).mean() rs = au/-ad return rs / (rs + 1) * 100 rsi 상대강도 지수 적용 # rsi 상대강도 지수 적용 def rsi(source, length): au = source.diff() ad = source.diff() au[au < 0] =.. 2023. 6. 24. python - 스토캐스틱 ( stochastic ) 구하기 ( pandas ) 저번에 전고점, 전저점을 알아보았습니다. 이번에는 파이썬에서 판다스를 활용하여 스토캐스틱을 구해보겠습니다. 스토캐스틱 ( stochastic ) 먼저 코드는 다음과 같습니다. 코드 top = df['close'] - df['low'].rolling(window=length).min() bot = df['high'].rolling(window=length).max() - df['low'].rolling(window=length).min() K = top / bot * 100 # K 가 스토캐스틱 값 함수 # 스토캐스틱 def fstochastic(close, high, low, length): top = close - low.rolling(window=length).min() bot = high.rolli.. 2023. 6. 21. python - 차트 전고점, 전저점 구하기 ( pandas ) 저번에 이평선을 구하는 법을 만들고, 이번에는 파이썬에서 판다스를 활용해 최근 최대, 최소 값을 구하는 코드를 만들어보았습니다. 최대, 최소 값 ( max, min ) 우선 구하는 코드는 다음과 같습니다. # 최대값 df['close'].rolling(window=5).max() # 최솟값 df['close'].rolling(window=5).min() # 최대 최소값 def recent_max(source, length): return source.rolling(window=length).max() def recent_min(source, length): return source.rolling(window=length).min() 아래 코드는 위 코드를 함수로 만든 것입니다. 활용하기 그러면 위의 코드.. 2023. 6. 18. python - 이평선 구하기 ( pandas ) 저번에 ccxt를 활용하여 비트코인 데이터를 가져왔습니다. 이번에는 파이썬에서 판다스 모듈을 활용하여 이동평균선을 구해보겠습니다. 이동평균선 (moving average) 이동평균선을 구하는 코드는 다음과 같습니다. df['close'].rolling(window=60).mean() def ma(source, length): return source.rolling(window=length).mean() 코드는 위화 같습니다. 아래 코드는 위의 코드를 함수로 만든 것입니다. 활용하기 저번 코드를 가져와서 적용해 보겠습니다. import pandas as pd import ccxt import fical as fi symbol = 'BTC/USDT' timeframe = '1h' candle = 100 bi.. 2023. 6. 15. 이전 1 2 다음