|
@@ -5,6 +5,8 @@ import time
|
|
|
import queue
|
|
import queue
|
|
|
import threading
|
|
import threading
|
|
|
|
|
|
|
|
|
|
+from logger_config import logger
|
|
|
|
|
+
|
|
|
# Initialize the DataFrame
|
|
# Initialize the DataFrame
|
|
|
df_trades = pd.DataFrame(columns=['price', 'qty', 'timestamp'])
|
|
df_trades = pd.DataFrame(columns=['price', 'qty', 'timestamp'])
|
|
|
df_order_book = pd.DataFrame(columns=['bid_price', 'bid_qty', 'ask_price', 'ask_qty'])
|
|
df_order_book = pd.DataFrame(columns=['bid_price', 'bid_qty', 'ask_price', 'ask_qty'])
|
|
@@ -69,13 +71,15 @@ def on_message_depth(_ws, message):
|
|
|
if bid_price not in order_disappearances:
|
|
if bid_price not in order_disappearances:
|
|
|
order_disappearances[bid_price] = 0
|
|
order_disappearances[bid_price] = 0
|
|
|
if prev_bid_qty > bid_qty:
|
|
if prev_bid_qty > bid_qty:
|
|
|
- order_disappearances[bid_price] += (prev_bid_qty - bid_qty)
|
|
|
|
|
|
|
+ disappearances = (prev_bid_qty - bid_qty)
|
|
|
|
|
+ order_disappearances[bid_price] += disappearances if disappearances > 0 else 0
|
|
|
|
|
|
|
|
# 计算ask订单消失量
|
|
# 计算ask订单消失量
|
|
|
if ask_price not in order_disappearances:
|
|
if ask_price not in order_disappearances:
|
|
|
order_disappearances[ask_price] = 0
|
|
order_disappearances[ask_price] = 0
|
|
|
if prev_ask_qty > ask_qty:
|
|
if prev_ask_qty > ask_qty:
|
|
|
- order_disappearances[ask_price] += (prev_ask_qty - ask_qty)
|
|
|
|
|
|
|
+ disappearances = (prev_ask_qty - ask_qty)
|
|
|
|
|
+ order_disappearances[ask_price] += disappearances if disappearances > 0 else 0
|
|
|
|
|
|
|
|
previous_order_book = df_order_book
|
|
previous_order_book = df_order_book
|
|
|
calculate_fill_probabilities()
|
|
calculate_fill_probabilities()
|