init
This commit is contained in:
27
HTS_etf.py
27
HTS_etf.py
@@ -128,20 +128,22 @@ class HTS_etf (HTS):
|
||||
return count
|
||||
|
||||
def getSlowK(self, stock_code):
|
||||
slow_k_week, slow_k_month = -1, -1
|
||||
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)>0:
|
||||
slow_k_week = items[0]
|
||||
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)>0:
|
||||
slow_k_month = items[0]
|
||||
if items is not None and len(items)>1:
|
||||
slow_k_month, p_slow_k_month = items[0], items[1]
|
||||
|
||||
if slow_k_week is None: slow_k_week = -1
|
||||
if slow_k_month is None: slow_k_month = -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, slow_k_month
|
||||
return slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month
|
||||
|
||||
def buyRealTime(self, today, stocks, analyzed_day=1000):
|
||||
|
||||
@@ -166,10 +168,6 @@ class HTS_etf (HTS):
|
||||
|
||||
print("%5d: %8s, %-50s"%(idx, stock['stock_code'], stock['stock_name']))
|
||||
|
||||
slow_k_week, slow_k_month = self.getSlowK(stock['stock_code'])
|
||||
if slow_k_week < 0 or 50 < slow_k_week or slow_k_month < 0 or 50 < slow_k_month:
|
||||
continue
|
||||
|
||||
try:
|
||||
# 데이터를 가지고 온다.
|
||||
result = self.getRealTime(stock['stock_code'], today, LAST_DATA[stock['stock_code']])
|
||||
@@ -199,6 +197,11 @@ class HTS_etf (HTS):
|
||||
bs_buy_weight = bsLine['buy_weight'][0]
|
||||
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'])
|
||||
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))):
|
||||
|
||||
# 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다.
|
||||
ORDER_LIST = self.requestOrderList()
|
||||
orderListToCancel = self.orderChecker.cancel(today, "A" + stock['stock_code'], ORDER_LIST, mins=10)
|
||||
|
||||
Reference in New Issue
Block a user