This commit is contained in:
dosangyoon
2021-10-17 00:36:44 +09:00
parent 8bcb2beeed
commit 7cf8b77580
3 changed files with 33 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ class OrderChecker:
before_two_hour = datetime.now() - timedelta(hours=2)
# 두 시간 전 주문을 찾는다.
if len(orderList) > 0:
if orderList is not None and 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.value]
@@ -47,6 +47,21 @@ class OrderChecker:
return orderListToCancel
def remove(self, type, orderList):
orderListToCancel = []
if orderList is not None and len(orderList) > 0:
orderNum_df = self.order_df.loc[self.order_df["type"] == type.value]
orderNumSet = set(list(orderNum_df["orderNum"]))
for item in orderList:
if item.orderNum in orderNumSet:
orderListToCancel.append(item)
# 해당 orderNum 제외하기
self.order_df = self.order_df.loc[self.order_df["orderNum"] != item.orderNum]
self.order_df.to_csv(self.saveFileName)
return orderListToCancel
if __name__ == "__main__":
a = pd.DataFrame(columns=["type", "orderNum", "count", "price", "datetime"])
a = a.astype({"type": str, "orderNum": int, "count": int, "price": int})