diff --git a/hts/OrderChecker.py b/hts/OrderChecker.py index 9d064a6..23f089b 100644 --- a/hts/OrderChecker.py +++ b/hts/OrderChecker.py @@ -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()) \ No newline at end of file + 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") \ No newline at end of file