|
|
@@ -2,8 +2,6 @@ import threading
|
|
|
import websocket
|
|
|
import json
|
|
|
import pandas as pd
|
|
|
-import numpy as np
|
|
|
-import time
|
|
|
import warnings
|
|
|
import logging
|
|
|
import colorlog
|
|
|
@@ -41,10 +39,11 @@ previous_order_book = None
|
|
|
fill_probabilities = {}
|
|
|
order_disappearances = {}
|
|
|
order_executions = {}
|
|
|
+last_trade_price = None
|
|
|
|
|
|
|
|
|
def on_message_trade(_ws, message):
|
|
|
- global df_trades, order_executions
|
|
|
+ global df_trades, order_executions, last_trade_price
|
|
|
json_message = json.loads(message)
|
|
|
trade = {
|
|
|
'price': float(json_message['p']),
|
|
|
@@ -57,6 +56,7 @@ def on_message_trade(_ws, message):
|
|
|
|
|
|
# 记录每个价格的实际成交总量
|
|
|
price = trade['price']
|
|
|
+ last_trade_price = price
|
|
|
if price not in order_executions:
|
|
|
order_executions[price] = 0
|
|
|
order_executions[price] += trade['qty']
|