init
This commit is contained in:
@@ -121,7 +121,19 @@ class HTS_Stocks (HTS):
|
||||
return all_stocks, valid_company
|
||||
|
||||
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:
|
||||
@@ -132,23 +144,26 @@ class HTS_Stocks (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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
return slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month
|
||||
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, p_slow_k, slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month
|
||||
|
||||
def getMaxPrice(self, code, valid_company):
|
||||
max_price = 100000
|
||||
@@ -170,6 +185,13 @@ class HTS_Stocks (HTS):
|
||||
print ("START...")
|
||||
THIS_TIME = datetime.now()
|
||||
|
||||
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
|
||||
|
||||
all_stocks, valid_company = self.getCompanyInfo()
|
||||
|
||||
while datetime.strptime(today + " 070000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100", '%Y%m%d %H%M%S'):
|
||||
@@ -208,9 +230,9 @@ class HTS_Stocks (HTS):
|
||||
data.drop(data.index[:len(data) - self.analyzed_day], inplace=True)
|
||||
bsLine, data = self.buySellChecker.checkTransactionWithEnvelope(data, stock_code, self.analyzed_day, isRealTime=False)
|
||||
|
||||
slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = self.getSlowK(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))):
|
||||
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))):
|
||||
|
||||
# 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다.
|
||||
ORDER_LIST = self.requestOrderList()
|
||||
|
||||
Reference in New Issue
Block a user