11"""User hub implementation for the ProjectX Gateway API."""
22
3+ import asyncio
34import logging
45from typing import Callable , Dict , List , Optional , Set
56
@@ -229,7 +230,7 @@ def subscribe_accounts(self, callback=None):
229230 self ._account_callbacks .append (callback )
230231
231232 if self ._is_connected :
232- self .invoke ("SubscribeAccounts" )
233+ asyncio . create_task ( self .invoke ("SubscribeAccounts" ) )
233234 self ._account_subscribed = True
234235
235236 return self
@@ -242,7 +243,7 @@ def unsubscribe_accounts(self):
242243 self: For method chaining
243244 """
244245 if self ._is_connected and self ._account_subscribed :
245- self .invoke ("UnsubscribeAccounts" )
246+ asyncio . create_task ( self .invoke ("UnsubscribeAccounts" ) )
246247 self ._account_subscribed = False
247248
248249 return self
@@ -265,7 +266,7 @@ def subscribe_orders(self, account_id, callback=None):
265266 self ._order_callbacks [account_id ].append (callback )
266267
267268 if self ._is_connected :
268- self .invoke ("SubscribeOrders" , account_id )
269+ asyncio . create_task ( self .invoke ("SubscribeOrders" , account_id ) )
269270 self ._subscribed_orders .add (account_id )
270271
271272 return self
@@ -281,7 +282,7 @@ def unsubscribe_orders(self, account_id):
281282 self: For method chaining
282283 """
283284 if self ._is_connected and account_id in self ._subscribed_orders :
284- self .invoke ("UnsubscribeOrders" , account_id )
285+ asyncio . create_task ( self .invoke ("UnsubscribeOrders" , account_id ) )
285286 self ._subscribed_orders .discard (account_id )
286287
287288 return self
@@ -304,7 +305,7 @@ def subscribe_positions(self, account_id, callback=None):
304305 self ._position_callbacks [account_id ].append (callback )
305306
306307 if self ._is_connected :
307- self .invoke ("SubscribePositions" , account_id )
308+ asyncio . create_task ( self .invoke ("SubscribePositions" , account_id ) )
308309 self ._subscribed_positions .add (account_id )
309310
310311 return self
@@ -320,7 +321,7 @@ def unsubscribe_positions(self, account_id):
320321 self: For method chaining
321322 """
322323 if self ._is_connected and account_id in self ._subscribed_positions :
323- self .invoke ("UnsubscribePositions" , account_id )
324+ asyncio . create_task ( self .invoke ("UnsubscribePositions" , account_id ) )
324325 self ._subscribed_positions .discard (account_id )
325326
326327 return self
@@ -343,7 +344,7 @@ def subscribe_trades(self, account_id, callback=None):
343344 self ._trade_callbacks [account_id ].append (callback )
344345
345346 if self ._is_connected :
346- self .invoke ("SubscribeTrades" , account_id )
347+ asyncio . create_task ( self .invoke ("SubscribeTrades" , account_id ) )
347348 self ._subscribed_trades .add (account_id )
348349
349350 return self
@@ -359,7 +360,7 @@ def unsubscribe_trades(self, account_id):
359360 self: For method chaining
360361 """
361362 if self ._is_connected and account_id in self ._subscribed_trades :
362- self .invoke ("UnsubscribeTrades" , account_id )
363+ asyncio . create_task ( self .invoke ("UnsubscribeTrades" , account_id ) )
363364 self ._subscribed_trades .discard (account_id )
364365
365366 return self
0 commit comments