@@ -87,17 +87,14 @@ async def wrapper(self, *args, **kwargs):
8787 if api_key_index == - 1 and nonce == - 1 :
8888 api_key_index , nonce = self .nonce_manager .next_nonce ()
8989 err = self .switch_api_key (api_key_index )
90- if "nonce" in kwargs :
91- del kwargs ["nonce" ]
92- if "api_key_index" in kwargs :
93- del kwargs ["api_key_index" ]
9490 if err != None :
9591 raise Exception (f"error switching api key: { err } " )
9692
9793 # Call the original function with modified kwargs
9894 ret : TxHash
9995 try :
100- created_tx , ret , err = await func (self , * args , ** kwargs , nonce = nonce , api_key_index = api_key_index )
96+ partial_arguments = {k : v for k , v in bound_args .arguments .items () if k not in ("self" , "nonce" , "api_key_index" )}
97+ created_tx , ret , err = await func (self , ** partial_arguments , nonce = nonce , api_key_index = api_key_index )
10198 if ret .code != CODE_OK :
10299 self .nonce_manager .acknowledge_failure (api_key_index )
103100 except lighter .exceptions .BadRequestException as e :
@@ -629,6 +626,70 @@ async def cancel_order(self, market_index, order_index, nonce=-1, api_key_index=
629626 logging .debug (f"Cancel Order Send Tx Response: { api_response } " )
630627 return CancelOrder .from_json (tx_info ), api_response , None
631628
629+ async def create_tp_order (self , market_index , client_order_index , base_amount , trigger_price , price , is_ask , reduce_only = False , nonce = - 1 , api_key_index = - 1 ) -> (CreateOrder , TxHash , str ):
630+ return await self .create_order (
631+ market_index ,
632+ client_order_index ,
633+ base_amount ,
634+ price ,
635+ is_ask ,
636+ self .ORDER_TYPE_TAKE_PROFIT ,
637+ self .DEFAULT_IOC_EXPIRY ,
638+ reduce_only ,
639+ trigger_price ,
640+ self .DEFAULT_28_DAY_ORDER_EXPIRY ,
641+ nonce ,
642+ api_key_index = api_key_index ,
643+ )
644+
645+ async def create_tp_limit_order (self , market_index , client_order_index , base_amount , trigger_price , price , is_ask , reduce_only = False , nonce = - 1 , api_key_index = - 1 ) -> (CreateOrder , TxHash , str ):
646+ return await self .create_order (
647+ market_index ,
648+ client_order_index ,
649+ base_amount ,
650+ price ,
651+ is_ask ,
652+ self .ORDER_TYPE_TAKE_PROFIT_LIMIT ,
653+ self .ORDER_TIME_IN_FORCE_GOOD_TILL_TIME ,
654+ reduce_only ,
655+ trigger_price ,
656+ self .DEFAULT_28_DAY_ORDER_EXPIRY ,
657+ nonce ,
658+ api_key_index ,
659+ )
660+
661+ async def create_sl_order (self , market_index , client_order_index , base_amount , trigger_price , price , is_ask , reduce_only = False , nonce = - 1 , api_key_index = - 1 ) -> (CreateOrder , TxHash , str ):
662+ return await self .create_order (
663+ market_index ,
664+ client_order_index ,
665+ base_amount ,
666+ price ,
667+ is_ask ,
668+ self .ORDER_TYPE_STOP_LOSS ,
669+ self .DEFAULT_IOC_EXPIRY ,
670+ reduce_only ,
671+ trigger_price ,
672+ self .DEFAULT_28_DAY_ORDER_EXPIRY ,
673+ nonce ,
674+ api_key_index = api_key_index ,
675+ )
676+
677+ async def create_sl_limit_order (self , market_index , client_order_index , base_amount , trigger_price , price , is_ask , reduce_only = False , nonce = - 1 , api_key_index = - 1 ) -> (CreateOrder , TxHash , str ):
678+ return await self .create_order (
679+ market_index ,
680+ client_order_index ,
681+ base_amount ,
682+ price ,
683+ is_ask ,
684+ self .ORDER_TYPE_STOP_LOSS_LIMIT ,
685+ self .ORDER_TIME_IN_FORCE_GOOD_TILL_TIME ,
686+ reduce_only ,
687+ trigger_price ,
688+ self .DEFAULT_28_DAY_ORDER_EXPIRY ,
689+ nonce ,
690+ api_key_index ,
691+ )
692+
632693 @process_api_key_and_nonce
633694 async def withdraw (self , usdc_amount , nonce = - 1 , api_key_index = - 1 ) -> (Withdraw , TxHash ):
634695 usdc_amount = int (usdc_amount * self .USDC_TICKER_SCALE )
0 commit comments