This commit is contained in:
dosangyoon
2022-08-09 00:32:33 +09:00
parent 2173156d41
commit 9725368faf
4 changed files with 39 additions and 389 deletions

View File

@@ -31,6 +31,17 @@ class HTS_252670 (HTS):
self.labelMaker = LabelMaker(RESOURCE_PATH)
return
def getDefaultSell(self, log_time, stock_code):
jangoDic = self.requstJango()
if jangoDic and len(jangoDic.keys()) > 0:
for code in jangoDic:
if jangoDic[code]['매도가능'] > 0:
if code == "A"+stock_code:
orderNum = self.requestOrder(OrderType.sell, stock_code, jangoDic[code]['매도가능'], jangoDic[code]['장부가']+60)
print("SELL", log_time, jangoDic[code]['매도가능'], jangoDic[code]['장부가']+60)
return
def getSellingPrice(self, final_price):
# 만약 잔고가 있으면 장부가보다 5원 높게 매도한다.
jangoDic = self.requstJango()
@@ -56,21 +67,18 @@ class HTS_252670 (HTS):
return 0, 0
def getFinalSellingPrice(self, final_price):
def getFinalSellingPrice(self, final_price, diff):
# 만약 잔고가 있으면 장부가보다 5원 높게 매도한다.
jangoDic = self.requstJango()
if jangoDic and len(jangoDic.keys()) > 0:
for code in jangoDic:
if jangoDic[code]['매도가능'] > 0:
return jangoDic[code]['매도가능'], final_price - 5
return jangoDic[code]['매도가능'], final_price + diff
return 0, 0
def buyRealTime(self, today):
timecheckList = pd.read_csv("hts/timecheck.csv").values.tolist()
timecheck = {today + " " + str(second).zfill(6):False for second, check in timecheckList}
print ("START...")
THIS_TIME = datetime.now()
final_sell_check = False
@@ -81,7 +89,13 @@ class HTS_252670 (HTS):
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
# 3시 까지만 매수를 시도한다.
if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]:
if THIS_TIME.strftime('%S') in ("06", "16", "26", "36", "46", "56"):
# 10초마다 체크하여 체결된 내역이 있으면 60원 높게 매도를 주문한다.
self.getDefaultSell(THIS_TIME.strftime('%Y%m%d %H%M%S'), self.stock_code)
#if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]:
if THIS_TIME.strftime('%S') == "03":
# 매분 3초마다 실행한다.
# 데이터를 가지고 온다.
result = self.getRealTime(self.stock_code, today, LAST_DATA)
@@ -164,7 +178,7 @@ class HTS_252670 (HTS):
result = self.getRealTime(self.stock_code, today, LAST_DATA)
final_price = result["close"][len(result["close"]) - 1]
#selling_count, selling_price = self.getFinalSellingPrice(final_price)
#selling_count, selling_price = self.getFinalSellingPrice(final_price, -5)
selling_count, selling_price = self.getSellingPrice(final_price)
# 분석된 가격으로 매도 요청한다.