Compare commits

..

No commits in common. "790052c2a2db2833df627cec420920e999b95a3b" and "91f297f30860665e02d8d49a31662c2613a29088" have entirely different histories.

5 changed files with 171 additions and 541 deletions

1
app.py
View File

@ -18,7 +18,6 @@ def index():
return flask.render_template("index.html", pages = pages.GenLists)
if __name__ == '__main__':
args = parser.parse_args()
app.run(host=args.host, port=args.port, debug=args.debug)

18
gen.py
View File

@ -75,8 +75,8 @@ def isVolumeMulPriceGreaterThan(stock: pd.DataFrame, threshold: int, nday: int)
return stock.iloc[nday]['VOLUME'] * stock.iloc[nday]['CLOSE'] > threshold
def isMACDCrossSignal(signal: pd.Series, macd: pd.Series, nday: int, order=1) -> bool:
return (signal.iloc[nday] > macd.iloc[nday] and
signal.iloc[nday+order] < macd.iloc[nday+order])
return (signal.iloc[nday] < macd.iloc[nday] and
signal.iloc[nday+order] > macd.iloc[nday+order])
def isRelativeDiffLessThan(a:pd.Series,b:pd.Series, threshold: float,nday:int) -> bool:
return (a.iloc[nday] - b.iloc[nday]) / b.iloc[nday] < threshold
@ -103,9 +103,6 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp
d60 = stock["CLOSE"].loc[::-1].rolling(window=60
).mean().dropna().loc[::-1]
if (d60.iloc[nday+2] > d60.iloc[nday+1] and d60.iloc[nday+1] < d60.iloc[nday]):
collector.collect("60일선반등",corp, stock.index[nday])
if (isRelativeDiffLessThan(d5, d20, 0.01, nday) and
isRelativeDiffLessThan(d5, d60, 0.01, nday)):
collector.collect("cross 2", corp, stock.index[nday])
@ -136,10 +133,10 @@ def collect(data: DataStore, collector: OutputCollector, corp: database.KRXCorp
if (isVolumeNTimes(stock, 5, nday)):
collector.collect("volumeX5", corp, stock.index[nday])
ewm5 = stock["CLOSE"].loc[::-1].ewm(span=5).mean().loc[::-1]
ewm10 = stock["CLOSE"].loc[::-1].ewm(span=10).mean().loc[::-1]
macd = (ewm5 - ewm10)
signal = macd.loc[::-1].ewm(span=4).mean().loc[::-1]
ewm12 = stock["CLOSE"].loc[::-1].ewm(span=12).mean().loc[::-1]
ewm26 = stock["CLOSE"].loc[::-1].ewm(span=26).mean().loc[::-1]
macd = (ewm12 - ewm26)
signal = macd.ewm(span=9).mean()
if (isMACDCrossSignal(macd, signal, nday)):
collector.collect("macd", corp, stock.index[nday])
@ -186,10 +183,11 @@ if __name__ == "__main__":
days = v.corpListByDate.keys()
days = list(days)
days.append(datetime.date.today().isoformat())
days.sort(reverse=True)
days = days[:5]
html = template.render(collected=v, title=k, days=days, lastUpdate=datetime.date.today().isoformat())
html = template.render(collected=v, title=k, days=days)
if args.printStdout:
print(html)
else:

View File

@ -34,12 +34,7 @@ d20d5의 조건에서 더해서 거래량이 이전 날짜보다 5배 증가한
거래량이 이전 날짜보다 5 증가한 시점을 찾습니다.
"""},
{name:"macd",desc: """\
signal과 macd가 서로 교차한 시점을 찾습니다. signal이 올라가고
macd가 아래로 내려가는 시점을 찾습니다. macd 5일선과 10일선으로 이루어지고
시그널을 구하기 위한 이동 평균은 4일입니다.
signal과 macd가 서로 교차한 시점을 찾습니다. signal이 아래로 떨어지고
macd가 위로 올라가는 시점을 찾습니다.
"""},
{
name:"60일선반등",desc: """\
60일선이 반등하는 시점을 찾습니다."""
}
]

View File

@ -40,7 +40,6 @@
<body>
<div style="margin: auto; max-width: 750px;">
<h1>{{title}} Stock List</h1>
<h3>{{lastUpdate}}</h3>
<section class="description">
{{collected.description}}
</section>

File diff suppressed because one or more lines are too long