`kraken`: heh, use `trio_util` for trades streamz tooo XD
							parent
							
								
									116f7fd40f
								
							
						
					
					
						commit
						49958e68ea
					
				| 
						 | 
				
			
			@ -34,7 +34,6 @@ from typing import (
 | 
			
		|||
    Union,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
from async_generator import aclosing
 | 
			
		||||
from bidict import bidict
 | 
			
		||||
import pendulum
 | 
			
		||||
import trio
 | 
			
		||||
| 
						 | 
				
			
			@ -672,11 +671,9 @@ async def trades_dialogue(
 | 
			
		|||
                        token=token,
 | 
			
		||||
                    ),
 | 
			
		||||
                ) as ws,
 | 
			
		||||
                aclosing(stream_messages(ws)) as stream,
 | 
			
		||||
                stream_messages(ws) as stream,
 | 
			
		||||
                trio.open_nursery() as nurse,
 | 
			
		||||
            ):
 | 
			
		||||
                stream = stream_messages(ws)
 | 
			
		||||
 | 
			
		||||
                # task for processing inbound requests from ems
 | 
			
		||||
                nurse.start_soon(
 | 
			
		||||
                    handle_order_requests,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,6 +78,7 @@ class OHLC(Struct):
 | 
			
		|||
    ticks: list[Any] = []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@trio_async_generator
 | 
			
		||||
async def stream_messages(
 | 
			
		||||
    ws: NoBsWs,
 | 
			
		||||
):
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +134,8 @@ async def process_data_feed_msgs(
 | 
			
		|||
    Parse and pack data feed messages.
 | 
			
		||||
 | 
			
		||||
    '''
 | 
			
		||||
    async for msg in stream_messages(ws):
 | 
			
		||||
    async with stream_messages(ws) as ws_stream:
 | 
			
		||||
        async for msg in ws_stream:
 | 
			
		||||
            match msg:
 | 
			
		||||
                case {
 | 
			
		||||
                    'errorMessage': errmsg
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue