File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed
Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 11import logging
22import threading
33
4+ import pandas as pd
5+
46
57def run (* fs ):
68 for f in fs :
@@ -43,8 +45,8 @@ def on_tick_changes(data: list):
4345 # Callback when receiving changes from tick_analytics
4446 # Print the new average price if the avg price for a symbol in the last 10s is greater than 300
4547 def on_tick_analytics_changes (data : pd .DataFrame ):
46- COLOR = ' \033 [92m'
47- ENDC = ' \033 [0m'
48+ COLOR = " \033 [92m"
49+ ENDC = " \033 [0m"
4850 for _ , row in data .iterrows ():
4951 # Print the new average price if the avg price for a symbol in the last 10s is greater than 300
5052 if (row ["op" ] == "UpdateInsert" or row ["op" ] == "Insert" ) and row [
@@ -132,15 +134,21 @@ def demo_boll():
132134
133135 def handle_binance_klines_update (data ):
134136 k = data ["data" ]["k" ]
137+ df = pd .DataFrame (
138+ {
139+ "symbol" : k ["s" ],
140+ "timestamp" : datetime .fromtimestamp (k ["t" ] / 1000 ),
141+ "open" : float (k ["o" ]),
142+ "high" : float (k ["h" ]),
143+ "low" : float (k ["l" ]),
144+ "close" : float (k ["c" ]),
145+ "volume" : float (k ["v" ]),
146+ },
147+ index = [0 ],
148+ )
135149 rw .insert (
136150 table_name = "usdm_futures_klins_1m" ,
137- symbol = k ["s" ],
138- timestamp = datetime .fromtimestamp (k ["t" ] / 1000 ),
139- open = float (k ["o" ]),
140- high = float (k ["h" ]),
141- low = float (k ["l" ]),
142- close = float (k ["c" ]),
143- volume = float (k ["v" ]),
151+ data = df ,
144152 )
145153
146154 def subscribe_binance ():
You can’t perform that action at this time.
0 commit comments