This commit is contained in:
dosangyoon
2021-10-18 19:25:05 +09:00
parent 119a36629f
commit 91c3686a68

View File

@@ -18,7 +18,8 @@ class OrderChecker:
else:
order_df = pd.DataFrame(columns=["stock_code", "type", "orderNum", "count", "price", "datetime"])
#order_df = order_df.astype({"stock_code": str, "type": str, "orderNum": int, "count": int, "price": int})
order_df = order_df.astype({"stock_code": str, "type": str, "orderNum": int, "count": int, "price": int})
order_df.drop(['Unnamed: 0'], axis=1, inplace=True)
order_df['datetime'] = pd.to_datetime(order_df['datetime'])
return order_df
@@ -88,14 +89,22 @@ if __name__ == "__main__":
a['datetime'] = pd.to_datetime(a['datetime'])
this_time = datetime.now()
a = a.append({"type": "0", "orderNum": 1, "count": 3, "price": 7, "datetime": this_time}, ignore_index=True)
a = a.append({"type": "1", "orderNum": 3, "count": 0, "price": 6, "datetime": this_time - timedelta(hours=2)}, ignore_index=True)
a = a.append({"type": "2", "orderNum": 3, "count": 0, "price": 3, "datetime": this_time + timedelta(hours=1)}, ignore_index=True)
a = a.append({"type": "1", "orderNum": 9, "count": 9, "price": 8, "datetime": this_time}, ignore_index=True)
a = a.append({"stock_code": "a", "type": "0", "orderNum": 1, "count": 3, "price": 7, "datetime": this_time}, ignore_index=True)
a = a.append({"stock_code": "a", "type": "1", "orderNum": 3, "count": 0, "price": 6, "datetime": this_time - timedelta(hours=2)}, ignore_index=True)
a = a.append({"stock_code": "a", "type": "2", "orderNum": 3, "count": 0, "price": 3, "datetime": this_time + timedelta(hours=1)}, ignore_index=True)
a = a.append({"stock_code": "a", "type": "1", "orderNum": 9, "count": 9, "price": 8, "datetime": this_time}, ignore_index=True)
b = a.loc[a["orderNum"] != 3]
print(b.tail())
print()
b = a.loc[a["datetime"] < this_time]
print(b.tail())
print(b.tail())
a.to_csv("test.csv")
a = pd.read_csv("test.csv")
a.drop(['Unnamed: 0'], axis=1, inplace=True)
a = a.astype({"stock_code": str, "type": str, "orderNum": int, "count": int, "price": int})
a['datetime'] = pd.to_datetime(a['datetime'])
print("done")