@@ -622,13 +622,32 @@ def test_lucitlicmgr(self):
622622
623623 def test_live_api_ws (self ):
624624 print (f"Test Websocket API ..." )
625+ market = "BUSDUSDT"
625626 ubwam = BinanceWebSocketApiManager (exchange = 'binance.com-testnet' )
626627 api_stream = ubwam .create_stream (api = True ,
627628 api_key = BINANCE_COM_TESTNET_API_KEY ,
628629 api_secret = BINANCE_COM_TESTNET_API_SECRET ,
629630 stream_label = "Bobs Websocket API" ,
630631 process_stream_data = handle_socket_message )
631632 time .sleep (5 )
633+ current_average_price = ubwam .api .spot .get_current_average_price (stream_id = api_stream , symbol = market ,
634+ return_response = True )
635+ print (f"current_average_price: { current_average_price } \r \n " )
636+ order_book = ubwam .api .spot .get_order_book (stream_id = api_stream , symbol = market , limit = 2 , return_response = True )
637+ print (f"Orderbook, lastUpdateId={ order_book ['result' ]['lastUpdateId' ]} : { order_book ['result' ]['asks' ]} , "
638+ f"{ order_book ['result' ]['bids' ]} \r \n " )
639+ aggregate_trades = ubwam .api .spot .get_aggregate_trades (stream_id = api_stream , symbol = market , return_response = True )
640+ print (f"aggregate_trades: { aggregate_trades ['result' ][:5 ]} \r \n " )
641+ historical_trades = ubwam .api .spot .get_historical_trades (stream_id = api_stream , symbol = market ,
642+ return_response = True )
643+ print (f"historical_trades: { historical_trades ['result' ][:5 ]} \r \n " )
644+ recent_trades = ubwam .api .spot .get_recent_trades (stream_id = api_stream , symbol = market , return_response = True )
645+ print (f"recent_trades: { recent_trades ['result' ][:5 ]} \r \n " )
646+ klines = ubwam .api .spot .get_klines (stream_id = api_stream , symbol = market , interval = "1m" , return_response = True )
647+ print (f"A few klines: { klines ['result' ][:5 ]} \r \n " )
648+ ui_klines = ubwam .api .spot .get_ui_klines (stream_id = api_stream , symbol = market , interval = "1d" ,
649+ return_response = True )
650+ print (f"A few ui_klines: { ui_klines ['result' ][:5 ]} \r \n " )
632651 ubwam .api .spot .get_listen_key (stream_id = api_stream )
633652 ubwam .api .spot .get_server_time (stream_id = api_stream )
634653 ubwam .api .spot .get_account_status (stream_id = api_stream )
@@ -639,11 +658,16 @@ def test_live_api_ws(self):
639658 ubwam .api .spot .ping (stream_id = api_stream )
640659 ubwam .api .spot .get_exchange_info (stream_id = api_stream , symbols = ['BUSDUSDT' ])
641660 ubwam .api .spot .get_order_book (stream_id = api_stream , symbol = "BUSDUSDT" , limit = 2 )
642- ubwam .api .spot .cancel_order (stream_id = api_stream , symbol = "BUSDUSDT" , orig_client_order_id = orig_client_order_id )
661+ replaced_client_order_id = ubwam .api .spot .cancel_and_replace_order (stream_id = api_stream , price = 1.1 ,
662+ order_type = "LIMIT" ,
663+ quantity = 15.0 , side = "SELL" , symbol = market ,
664+ cancel_orig_client_order_id = orig_client_order_id )
665+ ubwam .api .spot .cancel_order (stream_id = api_stream , symbol = "BUSDUSDT" ,
666+ orig_client_order_id = replaced_client_order_id )
643667 ubwam .api .spot .get_open_orders (stream_id = api_stream , symbol = "BUSDUSDT" )
644668 ubwam .api .spot .get_open_orders (stream_id = api_stream )
645669 ubwam .api .spot .cancel_open_orders (stream_id = api_stream , symbol = "BUSDUSDT" )
646- ubwam .api .spot .get_order (stream_id = api_stream , symbol = "BUSDUSDT" , orig_client_order_id = orig_client_order_id )
670+ ubwam .api .spot .get_order (stream_id = api_stream , symbol = "BUSDUSDT" , orig_client_order_id = replaced_client_order_id )
647671 time .sleep (5 )
648672 ubwam .stop_manager ()
649673
0 commit comments