This commit is contained in:
dsyoon
2023-02-27 09:10:06 +09:00
parent 396bee8e5f
commit a699fcc9cb
2 changed files with 43 additions and 17 deletions

View File

@@ -131,13 +131,27 @@ class HTS_etf (HTS):
def getSlowK(self, stock_code):
slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = -1, -1, -1, -1
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_weekly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchone()
if items is not None and len(items)>1:
slow_k_week, p_slow_k_week = items[0], items[1]
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_monthly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchone()
if items is not None and len(items)>1:
slow_k_month, p_slow_k_month = items[0], items[1]
items = self.cursor_stock.fetchall()
if items is not None and len(items) > 1:
for i, item in enumerate(items):
if i == 0:
slow_k_week = item[0]
elif i == 1:
p_slow_k_week = item[0]
else:
break
self.cursor_stock.execute(
'select stochastic_slow_k, max(ymd) from stock_analysis_monthly where code=? group by 1 order by ymd desc',
(stock_code,))
items = self.cursor_stock.fetchall()
if items is not None and len(items) > 1:
for i, item in enumerate(items):
if i == 0:
slow_k_month = item[0]
elif i == 1:
p_slow_k_month = item[0]
else:
break
if slow_k_week is None or p_slow_k_week is None:
slow_k_week, p_slow_k_week = -1, -1

View File

@@ -120,18 +120,30 @@ class HTS_Stocks (HTS):
def getSlowK(self, stock_code):
slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = -1, -1, -1, -1
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_weekly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchone()
items = self.cursor_stock.fetchall()
if items is not None and len(items)>1:
slow_k_week, p_slow_k_week = items[0], items[1]
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_monthly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchone()
if items is not None and len(items)>1:
slow_k_month, p_slow_k_month = items[0], items[1]
for i, item in enumerate(items):
if i == 0:
slow_k_week = item[0]
elif i == 1:
p_slow_k_week = item[0]
else:
break
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis_monthly where code=? group by 1 order by ymd desc', (stock_code, ))
items = self.cursor_stock.fetchall()
if items is not None and len(items)>1:
for i, item in enumerate(items):
if i == 0:
slow_k_month = item[0]
elif i == 1:
p_slow_k_month = item[0]
else:
break
if slow_k_week is None or p_slow_k_week is None:
slow_k_week, p_slow_k_week = -1, -1
if slow_k_month is None or p_slow_k_month is None:
slow_k_month, p_slow_k_month = -1, -1
if slow_k_week is None or p_slow_k_week is None:
slow_k_week, p_slow_k_week = -1, -1
if slow_k_month is None or p_slow_k_month is None:
slow_k_month, p_slow_k_month = -1, -1
return slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month