init
This commit is contained in:
51
HTS_etf.py
51
HTS_etf.py
@@ -132,7 +132,19 @@ class HTS_etf (HTS):
|
||||
return count
|
||||
|
||||
def getSlowK(self, stock_code):
|
||||
slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = -1, -1, -1, -1
|
||||
slow_k, p_slow_k, slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = -1, -1, -1, -1, -1, -1
|
||||
|
||||
self.cursor_stock.execute('select stochastic_slow_k, max(ymd) from stock_analysis 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 = item[0]
|
||||
elif i == 1:
|
||||
p_slow_k = item[0]
|
||||
else:
|
||||
break
|
||||
|
||||
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.fetchall()
|
||||
if items is not None and len(items) > 1:
|
||||
@@ -143,31 +155,38 @@ class HTS_etf (HTS):
|
||||
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
|
||||
|
||||
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 is None or p_slow_k is None:
|
||||
slow_k , p_slow_k = -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
|
||||
return slow_k, p_slow_k, slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month
|
||||
|
||||
def buyRealTime(self, today, stocks, analyzed_day=1000):
|
||||
|
||||
print ("START...")
|
||||
THIS_TIME = datetime.now()
|
||||
final_sell_check = False
|
||||
|
||||
slow_k_kospi, p_slow_k_kospi, slow_k_week_kospi, p_slow_k_week_kospi, slow_k_month_kospi, p_slow_k_month_kospi = self.getSlowK("^KS11")
|
||||
if (50 < slow_k_kospi or 50 < p_slow_k_kospi or (slow_k_kospi < 50 and p_slow_k_kospi < 50 and slow_k_kospi < p_slow_k_kospi)):
|
||||
return
|
||||
if ((0 < slow_k_week_kospi < 50 and 0 < slow_k_month_kospi < 50) and
|
||||
not ((20 < slow_k_week_kospi and slow_k_week_kospi < p_slow_k_week_kospi) or (20 < slow_k_month_kospi and slow_k_month_kospi < p_slow_k_month_kospi))):
|
||||
return
|
||||
|
||||
LAST_DATA = {}
|
||||
for stock in stocks:
|
||||
@@ -218,7 +237,7 @@ class HTS_etf (HTS):
|
||||
bs_sell_price = bsLine['sell'][0]
|
||||
|
||||
|
||||
slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = self.getSlowK(stock['stock_code'])
|
||||
slow_k, p_slow_k, slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = self.getSlowK(stock['stock_code'])
|
||||
if ((0 < slow_k_week < 50 and 0 < slow_k_month < 50) and
|
||||
not ((20 < slow_k_week and slow_k_week < p_slow_k_week) or (20 < slow_k_month and slow_k_month < p_slow_k_month))):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user