@@ -42,10 +42,25 @@ async def test_get_empty_linear_and_inverse_positions(self):
4242 await self .inner_test_get_empty_linear_and_inverse_positions ()
4343
4444 async def inner_test_get_empty_linear_and_inverse_positions (self ):
45+ if self .exchange_manager .exchange .SUPPORTS_SET_MARGIN_TYPE :
46+ await self .set_margin_type (trading_enums .MarginType .ISOLATED )
47+ await self ._inner_test_get_empty_linear_and_inverse_positions_for_margin_type (
48+ trading_enums .MarginType .ISOLATED
49+ )
50+ await self .set_margin_type (trading_enums .MarginType .CROSS )
51+ await self ._inner_test_get_empty_linear_and_inverse_positions_for_margin_type (
52+ trading_enums .MarginType .CROSS
53+ )
54+ else :
55+ await self ._inner_test_get_empty_linear_and_inverse_positions_for_margin_type (None )
56+
57+ async def _inner_test_get_empty_linear_and_inverse_positions_for_margin_type (
58+ self , margin_type : trading_enums .MarginType
59+ ):
4560 positions = await self .get_positions ()
4661 self ._check_positions_content (positions )
4762 position = await self .get_position (self .SYMBOL )
48- self ._check_position_content (position , self .SYMBOL )
63+ self ._check_position_content (position , self .SYMBOL , margin_type = margin_type )
4964 for contract_type in (trading_enums .FutureContractType .LINEAR_PERPETUAL ,
5065 trading_enums .FutureContractType .INVERSE_PERPETUAL ):
5166 if not self .has_empty_position (self .get_filtered_positions (positions , contract_type )):
@@ -134,11 +149,13 @@ def _check_positions_content(self, positions):
134149 for position in positions :
135150 self ._check_position_content (position , None )
136151
137- def _check_position_content (self , position , symbol , position_mode = None ):
152+ def _check_position_content (self , position , symbol , position_mode = None , margin_type = None ):
138153 if symbol :
139154 assert position [trading_enums .ExchangeConstantsPositionColumns .SYMBOL .value ] == symbol
140155 else :
141156 assert position [trading_enums .ExchangeConstantsPositionColumns .SYMBOL .value ]
157+ if margin_type :
158+ assert position [trading_enums .ExchangeConstantsPositionColumns .MARGIN_TYPE .value ] == margin_type
142159 leverage = position [trading_enums .ExchangeConstantsPositionColumns .LEVERAGE .value ]
143160 assert isinstance (leverage , decimal .Decimal )
144161 # should not be 0 in octobot
@@ -149,11 +166,28 @@ def _check_position_content(self, position, symbol, position_mode=None):
149166 assert position [trading_enums .ExchangeConstantsPositionColumns .POSITION_MODE .value ] is position_mode
150167
151168 async def inner_test_create_and_cancel_limit_orders (self , symbol = None , settlement_currency = None ):
169+ if self .exchange_manager .exchange .SUPPORTS_SET_MARGIN_TYPE :
170+ await self .set_margin_type (trading_enums .MarginType .ISOLATED )
171+ await self ._inner_test_create_and_cancel_limit_orders_for_margin_type (
172+ symbol = symbol , settlement_currency = settlement_currency , margin_type = trading_enums .MarginType .ISOLATED
173+ )
174+ await self .set_margin_type (trading_enums .MarginType .CROSS )
175+ await self ._inner_test_create_and_cancel_limit_orders_for_margin_type (
176+ symbol = symbol , settlement_currency = settlement_currency , margin_type = trading_enums .MarginType .CROSS
177+ )
178+ else :
179+ await self ._inner_test_create_and_cancel_limit_orders_for_margin_type (
180+ symbol = symbol , settlement_currency = settlement_currency , margin_type = None
181+ )
182+
183+ async def _inner_test_create_and_cancel_limit_orders_for_margin_type (
184+ self , symbol = None , settlement_currency = None , margin_type = None
185+ ):
152186 # test with linear symbol
153- await super ().inner_test_create_and_cancel_limit_orders ()
187+ await super ().inner_test_create_and_cancel_limit_orders (margin_type = margin_type )
154188 # test with inverse symbol
155189 await super ().inner_test_create_and_cancel_limit_orders (
156- symbol = self .INVERSE_SYMBOL , settlement_currency = self .ORDER_CURRENCY
190+ symbol = self .INVERSE_SYMBOL , settlement_currency = self .ORDER_CURRENCY , margin_type = margin_type
157191 )
158192
159193 async def inner_test_create_and_fill_market_orders (self ):
0 commit comments