1313#
1414# You should have received a copy of the GNU Lesser General Public
1515# License along with this library.
16- import decimal
17- import typing
18-
1916import octobot_trading .exchanges as exchanges
2017import octobot_trading .exchanges .connectors .ccxt .constants as ccxt_constants
2118import octobot_trading .enums as trading_enums
22- import octobot_trading .errors
19+ import octobot_trading .constants as trading_constants
2320
2421
2522class BitMartConnector (exchanges .CCXTConnector ):
@@ -36,6 +33,11 @@ class BitMart(exchanges.RestExchange):
3633 FIX_MARKET_STATUS = True
3734 DEFAULT_CONNECTOR_CLASS = BitMartConnector
3835 REQUIRE_ORDER_FEES_FROM_TRADES = True # set True when get_order is not giving fees on closed orders and fees
36+ # set True when create_market_buy_order_with_cost should be used to create buy market orders
37+ # (useful to predict the exact spent amount)
38+ ENABLE_SPOT_BUY_MARKET_WITH_COST = True
39+ # broken: need v4 endpoint required, 13/03/25 ccxt still doesn't have it
40+ SUPPORT_FETCHING_CANCELLED_ORDERS = False
3941
4042 @classmethod
4143 def get_name (cls ):
@@ -53,21 +55,9 @@ def get_additional_connector_config(self):
5355 }
5456 }
5557
56- async def create_order (self , order_type : trading_enums .TraderOrderType , symbol : str , quantity : decimal .Decimal ,
57- price : decimal .Decimal = None , stop_price : decimal .Decimal = None ,
58- side : trading_enums .TradeOrderSide = None , current_price : decimal .Decimal = None ,
59- reduce_only : bool = False , params : dict = None ) -> typing .Optional [dict ]:
60- if order_type is trading_enums .TraderOrderType .BUY_MARKET :
61- # on BitMart, market orders are in quote currency (YYY in XYZ/YYY)
62- used_price = price or current_price
63- if not used_price :
64- raise octobot_trading .errors .NotSupported (f"{ self .get_name ()} requires a price parameter to create "
65- f"market orders as quantity is in quote currency" )
66- quantity = quantity * used_price
67- return await super ().create_order (order_type , symbol , quantity ,
68- price = price , stop_price = stop_price ,
69- side = side , current_price = current_price ,
70- reduce_only = reduce_only , params = params )
58+ async def get_account_id (self , ** kwargs : dict ) -> str :
59+ # not available on bitmart
60+ return trading_constants .DEFAULT_ACCOUNT_ID
7161
7262
7363class BitMartCCXTAdapter (exchanges .CCXTAdapter ):
0 commit comments