This commit is contained in:
dsyoon
2021-10-16 15:22:22 +09:00
parent c1eb4c8fc8
commit c3ecc09239
2 changed files with 4 additions and 4 deletions

View File

@@ -161,7 +161,7 @@ class HTS:
# acc = "782446178"
# accFlag[0] = "01"
objStockOrder = win32com.client.Dispatch("CpTrade.CpTd0311")
objStockOrder.SetInputValue(0, type) # 1: 매도, 2: 매수
objStockOrder.SetInputValue(0, type.value) # 1: 매도, 2: 매수
objStockOrder.SetInputValue(1, acc) # 계좌번호
objStockOrder.SetInputValue(2, accFlag[0]) # 상품구분 - 주식 상품 중 첫번째
objStockOrder.SetInputValue(3, "A"+stock_code) # 종목코드
@@ -588,7 +588,7 @@ class HTS:
# 미체결 기록을 가져온다.
orderList = self.requestOrderList()
# 매수 주문을 기록한다.
orderListToCancel = orderChecker.add("2", orderNum, BUY_COUNT, bs_buy_price, orderList)
orderListToCancel = orderChecker.add(OrderType.buy, orderNum, BUY_COUNT, bs_buy_price, orderList)
# 두 시간 이전 미체결을 취소한다.
self.cancelOrderList(orderListToCancel)
# 로그 출력

View File

@@ -33,7 +33,7 @@ class OrderChecker:
if len(orderList) > 0:
# 만약 두시간 전 주문을 찾는다.
orderNum_df = self.order_df.loc[self.order_df["datetime"] <= before_two_hour]
orderNum_df = orderNum_df.loc[orderNum_df["type"] == OrderType.buy]
orderNum_df = orderNum_df.loc[orderNum_df["type"] == OrderType.buy.value]
orderNumSet = set(list(orderNum_df["orderNum"]))
for item in orderList:
if item.orderNum in orderNumSet:
@@ -41,7 +41,7 @@ class OrderChecker:
# 해당 orderNum 제외하기
self.order_df = self.order_df.loc[self.order_df["orderNum"] != item.orderNum]
self.order_df = self.order_df.append({"type": type, "orderNum": orderNum, "count": count, "price": price, "datetime": datetime.now()}, ignore_index=True)
self.order_df = self.order_df.append({"type": type.value, "orderNum": orderNum, "count": count, "price": price, "datetime": datetime.now()}, ignore_index=True)
self.order_df.to_csv(self.saveFileName)
return orderListToCancel