This commit is contained in:
dsyoon
2021-10-14 23:33:38 +09:00
parent 5d8ca4500d
commit 1b7dc224f3

View File

@@ -1,9 +1,6 @@
import pandas as pd import pandas as pd
from stockpredictor.analysis.Common import Common from stockpredictor.analysis.Common import Common
from plotly import tools, subplots
import numpy as np import numpy as np
import plotly.graph_objs as go
import plotly.io as po
# [청송촌놈] 파생을 알아야 시장이 보인다. 청송이 종목 고르는법! https://www.youtube.com/watch?v=weABtgZDeGg # [청송촌놈] 파생을 알아야 시장이 보인다. 청송이 종목 고르는법! https://www.youtube.com/watch?v=weABtgZDeGg
# 6. Pandas와 Plotly를 이용한 MACD 차트 그리기 https://excelsior-cjh.tistory.com/110 # 6. Pandas와 Plotly를 이용한 MACD 차트 그리기 https://excelsior-cjh.tistory.com/110
@@ -20,27 +17,6 @@ class RSI:
self.common = Common() self.common = Common()
return return
def draw(self, stock):
item_name = stock["NAME"]
item_code = stock["CODE"]
df = pd.DataFrame(stock["PRICE"])
rsi = go.Scatter(x=df.DATE, y=df['rsi'], name="RSI")
signal = go.Scatter(x=df.DATE, y=df['rsis'], name="RSI Signal")
data = [rsi, signal]
layout = go.Layout(title='{} RSI 그래프'.format(item_name))
fig = subplots.make_subplots(rows=2, cols=1, shared_xaxes=True)
for trace in data:
fig.append_trace(trace, 1,1)
fig = go.Figure(data=data, layout=layout)
path = "/Users/dsyoon/workspace/StockPredictor/resources/analysis/html"
po.write_html(fig, file=path + "/rsi" + item_code+'.html', auto_open=False)
return fig
def apply(sefl, df, period=14): def apply(sefl, df, period=14):
# df.diff를 통해 (기준일 종가 - 기준일 전일 종가)를 계산하여 0보다 크면 증가분을 감소했으면 0을 넣어줌 # df.diff를 통해 (기준일 종가 - 기준일 전일 종가)를 계산하여 0보다 크면 증가분을 감소했으면 0을 넣어줌
U = np.where(df.close.diff(1) > 0, df.close.diff(1), 0) U = np.where(df.close.diff(1) > 0, df.close.diff(1), 0)