This commit is contained in:
dsyoon
2023-12-14 14:06:14 +09:00
parent 54a1d002c6
commit 2df115064a

View File

@@ -411,7 +411,9 @@ class HTS_etf(HTS):
def buyRealTime(self, stocks, today, MAX_PRICE=30000):
#self.orderChecker = OrderChecker(self.RESOURCE_PATH, stock_code)
BUY_LIST = {'buy_count': 0, 'buy_avg': 0, 'buy_list': []}
BUY_LIST = {
'stock_code': {'buy_count': 0, 'buy_avg': 0, 'buy_list': []}
}
print("START...")
THIS_TIME = datetime.now()
@@ -426,19 +428,24 @@ class HTS_etf(HTS):
stock_code = stock['stock_code']
stock_name = stock['stock_name']
if isFirst < 4:
self.bot.sendMsg("START... {} ({}) MAX_PRICE: {}".format(stock_code, stock_name, MAX_PRICE))
isFirst += 1
# 매도를 체크한다.
check = self.sellStocks(stock_code, stock_name)
# jangoDic[code]['장부가'], jangoDic[code]['평가금액'], jangoDic[code]['평가손익'],
buy_avg, amount, profit = self.getBallance(stock_code)
if check or buy_avg == 0:
BUY_LIST['buy_avg'] = 0
BUY_LIST['buy_count'] = 0
BUY_LIST['buy_list'].clear()
BUY_LIST[stock_code]['buy_avg'] = 0
BUY_LIST[stock_code]['buy_count'] = 0
BUY_LIST[stock_code]['buy_list'].clear()
if isFirst < 4:
if 0 < buy_avg:
BUY_LIST[stock_code]['buy_avg'] = buy_avg
if BUY_LIST is not None and len(BUY_LIST[stock_code]['buy_list']) == 0:
BUY_LIST[stock_code]['buy_list'].append({'buy_ymd': datetime.now(), 'buy_price': buy_avg, 'buy_count': 0, 'buy_cut': 0, 'buy_type': ''})
self.bot.sendMsg("START... {} ({}) MAX_PRICE: {}".format(stock_code, stock_name, MAX_PRICE))
isFirst += 1
time.sleep(0.1)
@@ -451,7 +458,7 @@ class HTS_etf(HTS):
#data.drop(data.index[:len(data) - analyzed_day], inplace=True)
# 사야 할 시점과 팔아야 할 시점을 체크한다.
bsLine1 = self.buySellChecker.checkTransaction1(stock_code, MAX_PRICE, data, data_signal, BUY_LIST, isRealTime=True)
bsLine1 = self.buySellChecker.checkTransaction1(stock_code, MAX_PRICE, data, data_signal, BUY_LIST[stock_code], isRealTime=True)
if 'sell_price' in bsLine1:
sell_price = bsLine1['sell_price'][-1]
@@ -461,9 +468,9 @@ class HTS_etf(HTS):
check = self.sellStocks(stock_code, sell_price)
if check:
#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()
BUY_LIST[stock_code]['buy_avg'] = 0
BUY_LIST[stock_code]['buy_count'] = 0
BUY_LIST[stock_code]['buy_list'].clear()
self.bot.sendMsg( "Profit {:.2f}, {} ({})".format(profit, stock_code, stock_name))
if 'buy_price' in bsLine1: