Skip to content

Commit cce0e1f

Browse files
committed
[Exchange] fix open position check and set_symbol_position_mode
tmp
1 parent 0abddc5 commit cce0e1f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

octobot_trading/exchanges/connectors/ccxt/ccxt_connector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ async def set_symbol_margin_type(self, symbol: str, isolated: bool):
460460
marginType=self.CCXT_ISOLATED if isolated else self.CCXT_CROSSED)
461461

462462
async def set_symbol_position_mode(self, symbol: str, one_way: bool):
463-
return await self.client.set_position_mode(self, hedged=not one_way, symbol=symbol)
463+
return await self.client.set_position_mode(hedged=not one_way, symbol=symbol)
464464

465465
async def set_symbol_partial_take_profit_stop_loss(self, symbol: str, inverse: bool,
466466
tp_sl_mode: enums.TakeProfitStopLossMode):

octobot_trading/exchanges/traders/trader.pxd

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ cdef class Trader(util.Initializable):
4040
cpdef object set_risk(self, object risk)
4141
cpdef object convert_order_to_trade(self, object order)
4242

43-
cdef bint _has_open_position(self, str symbol)
43+
# any() cant be cythonized
44+
# cdef bool _has_open_position(self, str symbol)

octobot_trading/exchanges/traders/trader.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -671,5 +671,8 @@ def _has_open_position(self, symbol):
671671
:param symbol: the position symbol
672672
:return: True if open position for :symbol: exists
673673
"""
674-
return len(self.exchange_manager.exchange_personal_data.positions_manager.get_symbol_positions(
675-
symbol=symbol)) != 0
674+
return any(
675+
position.size
676+
for position in self.exchange_manager.exchange_personal_data.positions_manager.get_symbol_positions(
677+
symbol=symbol
678+
))

0 commit comments

Comments
 (0)