init
This commit is contained in:
19
HTS_etf.py
19
HTS_etf.py
@@ -409,7 +409,7 @@ class HTS_etf(HTS):
|
||||
return result
|
||||
|
||||
def buyRealTime(self, stocks, today, MAX_PRICE=30000):
|
||||
self.orderChecker = OrderChecker(self.RESOURCE_PATH, stock_code)
|
||||
#self.orderChecker = OrderChecker(self.RESOURCE_PATH, stock_code)
|
||||
|
||||
BUY_LIST = {'buy_count': 0, 'buy_avg': 0, 'buy_list': []}
|
||||
|
||||
@@ -417,10 +417,8 @@ class HTS_etf(HTS):
|
||||
THIS_TIME = datetime.now()
|
||||
|
||||
#LAST_DATA = self.getLastData(stock_code, today)
|
||||
|
||||
isFirst = True
|
||||
while datetime.strptime(today + " 060000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100",'%Y%m%d %H%M%S'):
|
||||
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 090100", '%Y%m%d %H%M%S'):
|
||||
self.bot.sendMsg("START... {} ({}) SLOW_K: {}".format(stock_code, stock_name, MAX_PRICE))
|
||||
|
||||
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
|
||||
|
||||
@@ -428,6 +426,10 @@ class HTS_etf(HTS):
|
||||
stock_code = stock['stock_code']
|
||||
stock_name = stock['stock_name']
|
||||
|
||||
if isFirst:
|
||||
self.bot.sendMsg("START... {} ({}) SLOW_K: {}".format(stock_code, stock_name, MAX_PRICE))
|
||||
isFirst = False
|
||||
|
||||
# 매도를 체크한다.
|
||||
check = self.sellStocks(stock_code, stock_name)
|
||||
|
||||
@@ -458,7 +460,7 @@ class HTS_etf(HTS):
|
||||
if buy_avg * profit_rate < data['close'][-1]:
|
||||
check = self.sellStocks(stock_code, sell_price)
|
||||
if check:
|
||||
self.orderChecker.sell(datetime.today().strftime('%Y%m%d'), stock_code)
|
||||
#self.orderChecker.sell(datetime.today().strftime('%Y%m%d'), stock_code)
|
||||
BUY_LIST['buy_avg'] = 0
|
||||
BUY_LIST['buy_count'] = 0
|
||||
BUY_LIST['buy_list'].clear()
|
||||
@@ -470,18 +472,19 @@ class HTS_etf(HTS):
|
||||
if buy_price > 0:
|
||||
# 매수를 요청 한다.
|
||||
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, buy_price)
|
||||
self.orderChecker.buy(today, "A" + stock_code, buy_count, buy_price, orderNum)
|
||||
#self.orderChecker.buy(today, "A" + stock_code, buy_count, buy_price, orderNum)
|
||||
|
||||
self.orderChecker.buy(datetime.today().strftime('%Y%m%d'), stock_code, buy_count, buy_price)
|
||||
#self.orderChecker.buy(datetime.today().strftime('%Y%m%d'), stock_code, buy_count, buy_price)
|
||||
self.bot.post(stock_code, stock_name, "[BUY] ", buy_price, buy_count, data['rsi'][-1], -1)
|
||||
|
||||
|
||||
"""
|
||||
# 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다.
|
||||
ORDER_LIST = self.requestOrderList()
|
||||
orderListToCancel = self.orderChecker.cancel(today, "A" + stock_code, ORDER_LIST, mins=3)
|
||||
if len(orderListToCancel) > 0:
|
||||
self.cancelOrderList(orderListToCancel)
|
||||
|
||||
"""
|
||||
if (int(THIS_TIME.strftime("%M")) % 50 == 0 or int(THIS_TIME.strftime("%M")) % 20 == 0):
|
||||
#self.bot.alarm_live(stock_code, stock_name)
|
||||
vm = psutil.virtual_memory()
|
||||
|
||||
Reference in New Issue
Block a user