init
This commit is contained in:
36
stock/analysis/Envelope.py
Normal file
36
stock/analysis/Envelope.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import pandas as pd
|
||||
|
||||
from stock.analysis.Common import Common
|
||||
import finterstellar as fs
|
||||
|
||||
class Envelope:
|
||||
|
||||
common = None
|
||||
|
||||
def __init__(self):
|
||||
self.common = Common()
|
||||
return
|
||||
|
||||
# c=9, b=26, l=52
|
||||
def apply(self, df, w=13, s=0.08):
|
||||
# 입력받은 값이 dataframe이라는 것을 정의해줌
|
||||
df = pd.DataFrame(df["close"])
|
||||
|
||||
fs.envelope(df, w=w, spread=s)
|
||||
|
||||
return df.fillna(df["close"][0])
|
||||
|
||||
# 일목균형표의 구성을 훑어보면 주가를 선행과 후행으로 과거의 주가를 통해 미래 혹은 현재의 주식의 가격의 추세를 예측해보려는 지표라는 것을 이해할 수 있다.
|
||||
# 또한 구름층의 색을 통해서 주식의 추세를 손쉽게 확인할 수 있을 것 같다는 것도 이해할 수 있다면 끝 !
|
||||
def analyze(self, stock):
|
||||
df = pd.DataFrame()
|
||||
df = df.from_dict(stock['PRICE'])
|
||||
df = self.apply(df)
|
||||
|
||||
|
||||
for i in range(len(df.close)):
|
||||
stock['PRICE'][i]['envelope_upper'] = df.ub.values[i]
|
||||
stock['PRICE'][i]['envelope_middle'] = df.center.values[i]
|
||||
stock['PRICE'][i]['envelope_lower'] = df.lb.values[i]
|
||||
|
||||
return
|
||||
Reference in New Issue
Block a user